1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef RB_DEVICEPRESENCE_H_
22 #define RB_DEVICEPRESENCE_H_
28 #include "BrokerTypes.h"
29 #include "ResourcePresence.h"
30 #include "PresenceSubscriber.h"
31 #include "ExpiryTimer.h"
40 typedef long long TimerID;
45 DevicePresence(DevicePresence &&) = delete;
46 DevicePresence(const DevicePresence &) = delete;
48 DevicePresence & operator = (DevicePresence &&) = delete;
49 DevicePresence & operator = (const DevicePresence &) = delete;
51 void initializeDevicePresence(PrimitiveResourcePtr pResource);
53 void addPresenceResource(ResourcePresence * rPresence);
54 void removePresenceResource(ResourcePresence * rPresence);
56 bool isEmptyResourcePresence() const;
57 const std::string getAddress() const;
58 DEVICE_STATE getDeviceState() const noexcept;
61 std::list<ResourcePresence * > resourcePresenceList;
64 std::atomic_int state;
65 std::atomic_bool isRunningTimeOut;
67 std::mutex timeoutMutex;
68 std::condition_variable condition;
70 ExpiryTimer presenceTimer;
71 TimerID presenceTimerHandle;
73 SubscribeCB pSubscribeRequestCB;
74 PresenceSubscriber presenceSubscriber;
76 void changeAllPresenceMode(BROKER_MODE mode);
77 void subscribeCB(OCStackResult ret,const unsigned int seq, const std::string& Hostaddress);
78 void timeOutCB(TimerID id);
80 void setDeviceState(DEVICE_STATE);
82 } // namespace Service
85 #endif /* RB_DEVICEPRESENCE_H_ */