Fix PresenceSubscriber to work correctly with move constructor
authorcoderhyme <jhyo.kim@samsung.com>
Fri, 12 Jun 2015 06:01:58 +0000 (15:01 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 15 Jun 2015 10:28:33 +0000 (10:28 +0000)
Change-Id: Id9fae6f0fe89e90d3a78827a12eac0810c3ada4b
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1250
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/basis/common/primitiveResource/include/PresenceSubscriber.h
service/basis/common/primitiveResource/src/PresenceSubscriber.cpp

index 93ba659..121f760 100644 (file)
@@ -33,7 +33,7 @@ class PresenceSubscriber
 public:
     PresenceSubscriber();
 
-    PresenceSubscriber(PresenceSubscriber&&) = default;
+    PresenceSubscriber(PresenceSubscriber&&);
 
     /**
      * @throw PlatformException
@@ -49,7 +49,7 @@ public:
 
     ~PresenceSubscriber();
 
-    PresenceSubscriber& operator=(PresenceSubscriber&&) = default;
+    PresenceSubscriber& operator=(PresenceSubscriber&&);
 
     /**
      * @throw PlatformException
index 19eb996..58e9f8c 100644 (file)
@@ -64,6 +64,12 @@ PresenceSubscriber::PresenceSubscriber() :
 {
 }
 
+PresenceSubscriber::PresenceSubscriber(PresenceSubscriber&& from) :
+    m_handle{ nullptr }
+{
+    std::swap(m_handle, from.m_handle);
+}
+
 PresenceSubscriber::PresenceSubscriber(const std::string& host,
         OCConnectivityType connectivityType, SubscribeCallback presenceHandler) :
         m_handle{ nullptr }
@@ -92,6 +98,13 @@ PresenceSubscriber::~PresenceSubscriber()
     }
 }
 
+PresenceSubscriber& PresenceSubscriber::operator=(PresenceSubscriber&& from)
+{
+    unsubscribe();
+    std::swap(m_handle, from.m_handle);
+    return *this;
+}
+
 void PresenceSubscriber::unsubscribe()
 {
     if (m_handle == nullptr) return;