From: coderhyme Date: Fri, 12 Jun 2015 06:01:58 +0000 (+0900) Subject: Fix PresenceSubscriber to work correctly with move constructor X-Git-Tag: 1.2.0+RC1~1430^2~155 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1fb3dfac835245d8b089821888b0a54cc059221e;p=platform%2Fupstream%2Fiotivity.git Fix PresenceSubscriber to work correctly with move constructor Change-Id: Id9fae6f0fe89e90d3a78827a12eac0810c3ada4b Signed-off-by: coderhyme Reviewed-on: https://gerrit.iotivity.org/gerrit/1250 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- diff --git a/service/basis/common/primitiveResource/include/PresenceSubscriber.h b/service/basis/common/primitiveResource/include/PresenceSubscriber.h index 93ba659..121f760 100644 --- a/service/basis/common/primitiveResource/include/PresenceSubscriber.h +++ b/service/basis/common/primitiveResource/include/PresenceSubscriber.h @@ -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 diff --git a/service/basis/common/primitiveResource/src/PresenceSubscriber.cpp b/service/basis/common/primitiveResource/src/PresenceSubscriber.cpp index 19eb996..58e9f8c 100644 --- a/service/basis/common/primitiveResource/src/PresenceSubscriber.cpp +++ b/service/basis/common/primitiveResource/src/PresenceSubscriber.cpp @@ -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;