From 8579b5dd26a536a1aa763faa25a0dea0885a2df1 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Wed, 23 Sep 2020 10:04:54 -0400 Subject: [PATCH] uORB: Subscription add copy/move constructor and assignment --- src/modules/uORB/Subscription.hpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/modules/uORB/Subscription.hpp b/src/modules/uORB/Subscription.hpp index c7ab1548f2..195fbb0a9c 100644 --- a/src/modules/uORB/Subscription.hpp +++ b/src/modules/uORB/Subscription.hpp @@ -84,6 +84,30 @@ public: subscribe(); } + // Copy constructor + Subscription(const Subscription &other) : _orb_id(other._orb_id), _instance(other._instance) {} + + // Move constructor + Subscription(const Subscription &&other) noexcept : _orb_id(other._orb_id), _instance(other._instance) {} + + // copy assignment + Subscription &operator=(const Subscription &other) + { + unsubscribe(); + _orb_id = other._orb_id; + _instance = other._instance; + return *this; + } + + // move assignment + Subscription &operator=(Subscription &&other) noexcept + { + unsubscribe(); + _orb_id = other._orb_id; + _instance = other._instance; + return *this; + } + ~Subscription() { unsubscribe();