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_
26 #include <boost/atomic.hpp>
28 #include "BrokerTypes.h"
29 #include "ResourcePresence.h"
30 #include "PresenceSubscriber.h"
31 #include "ExpiryTimer.h"
40 typedef long long TimerID;
45 void initializeDevicePresence(PrimitiveResourcePtr pResource);
47 void addPresenceResource(ResourcePresence * rPresence);
48 void removePresenceResource(ResourcePresence * rPresence);
50 bool isEmptyResourcePresence() const;
51 const std::string getAddress() const;
52 DEVICE_STATE getDeviceState() const;
54 std::list<ResourcePresence * > resourcePresenceList;
57 boost::atomic<DEVICE_STATE> state;
58 boost::atomic_bool isRunningTimeOut;
60 std::mutex timeoutMutex;
61 std::condition_variable condition;
63 ExpiryTimer presenceTimer;
64 TimerID presenceTimerHandle;
66 SubscribeCB pSubscribeRequestCB;
67 PresenceSubscriber presenceSubscriber;
69 void changeAllPresenceMode(BROKER_MODE mode);
70 void subscribeCB(OCStackResult ret,const unsigned int seq, const std::string& Hostaddress);
71 void timeOutCB(TimerID id);
73 } // namespace Service
76 #endif /* RB_DEVICEPRESENCE_H_ */