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_RESOURCEPRESENCE_H_
22 #define RB_RESOURCEPRESENCE_H_
29 #include <condition_variable>
31 #include "BrokerTypes.h"
32 #include "ExpiryTimer.h"
38 class ResourcePresence : public std::enable_shared_from_this<ResourcePresence>
44 void initializeResourcePresence(PrimitiveResourcePtr pResource);
46 void addBrokerRequester(BrokerID _id, BrokerCB _cb);
47 void removeBrokerRequester(BrokerID _id);
48 void removeAllBrokerRequester();
50 void requestResourceState() const;
51 void changePresenceMode(BROKER_MODE newMode);
53 bool isEmptyRequester() const;
54 int requesterListSize() const;
55 const PrimitiveResourcePtr getPrimitiveResource() const;
56 BROKER_STATE getResourceState() const;
59 std::unique_ptr<std::list<BrokerRequesterInfoPtr>> requesterList;
60 PrimitiveResourcePtr primitiveResource;
61 ExpiryTimer expiryTimer;
67 std::atomic_long receivedTime;
69 unsigned int timeoutHandle;
75 void registerDevicePresence();
77 void getCB(const HeaderOptions &hos, const ResponseStatement& rep, int eCode);
78 void timeOutCB(unsigned int msg);
80 void verifiedGetResponse(int eCode);
82 void pollingCB(unsigned int msg = 0);
84 void executeAllBrokerCB(BROKER_STATE changedState);
85 void setResourcestate(BROKER_STATE _state);
87 } // namespace Service
90 #endif /* RB_RESOURCEPRESENCE_H_ */