mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-23 14:47:44 +08:00
uORB: Subscription add copy/move constructor and assignment
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user