Refine codes using an enum with std atomic in DevicePresence
authorcoderhyme <jhyo.kim@samsung.com>
Wed, 19 Aug 2015 15:34:59 +0000 (00:34 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Fri, 21 Aug 2015 00:19:14 +0000 (00:19 +0000)
commit054a7873e98240f3016fe404186aff95371c7440
tree44ff2ad0b277579acae0f84d23a3d77250f0419b
parent07c132888e0a3943d84d43b5cf5e61a1a7df5b32
Refine codes using an enum with std atomic in DevicePresence

DevicePresence::state, a variable to keep the state of the class, is an enum type. It needs to be declared as an atomic to make it thread-safe.
std::atomic with user-defined type is not available on GCC 4.6.3, therefore std::atomic_int is used instead. The enum is scoped enum, which means it is enum class. It means it is not interchangeable with int implictly.
That's why a separate method is declared to set the value from int value. Plus, the values is controlled in the class, so it is safe to cast to int and vice versa.

Change-Id: I2689c550af293c41a9757646924f210e7fccab74
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2244
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/resource-encapsulation/src/resourceBroker/include/BrokerTypes.h
service/resource-encapsulation/src/resourceBroker/include/DevicePresence.h
service/resource-encapsulation/src/resourceBroker/src/DevicePresence.cpp