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_BROKERTYPES_H_
22 #define RB_BROKERTYPES_H_
29 #include "PrimitiveResource.h"
35 #define BROKER_TAG PCF("BROKER")
36 #define BROKER_DEVICE_PRESENCE_TIMEROUT (15000l)
37 #define BROKER_SAFE_SECOND (5l)
38 #define BROKER_SAFE_MILLISECOND (BROKER_SAFE_SECOND * (1000))
39 #define BROKER_TRANSPORT OCConnectivityType::CT_ADAPTER_IP
43 * brief : resourcePresence state
44 * ALIVE - It means that 'getCB' function receives 'OK' message
45 * REQUESTED - It means that broker receives the request for presence checking
46 * LOST_SIGNAL - In case that 'getCB' function receives the message except 'OK'
47 * DESTROYED - In case that the presence checking is dismissed for the resource ,
48 * or there is no matched value in the Broker Callback list
49 * NONE - To be determined.
51 enum class BROKER_STATE
62 * brief : devicePresence state
63 * ALIVE - It means that 'subscribeCB' function receives 'OK' message
64 * REQUESTED - It means that broker receives the request for presence checking
65 * LOST_SIGNAL - In case that 'subscribeCB' function receives the message except 'OK'
67 enum class DEVICE_STATE
74 enum class BROKER_MODE
76 DEVICE_PRESENCE_MODE = 0,
80 typedef unsigned int BrokerID;
82 typedef std::function<void(BROKER_STATE)> BrokerCB;
83 struct BrokerRequesterInfo
85 BrokerRequesterInfo(BrokerID _id, BrokerCB _cb) : brokerId(_id), brokerCB(_cb){}
89 typedef std::shared_ptr<BrokerRequesterInfo> BrokerRequesterInfoPtr;
91 class ResourcePresence;
94 typedef std::function<void(std::shared_ptr<OC::OCResource>)> FindCB;
96 typedef std::shared_ptr<PrimitiveResource> PrimitiveResourcePtr;
98 typedef std::shared_ptr<ResourcePresence> ResourcePresencePtr;
99 typedef std::shared_ptr<DevicePresence> DevicePresencePtr;
100 typedef std::list< ResourcePresencePtr > PresenceList;
102 struct BrokerCBResourcePair
104 BrokerCBResourcePair(ResourcePresencePtr pResource, BrokerCB cb)
105 : pResource(pResource), brokerCB(cb){}
106 ResourcePresencePtr pResource;
109 typedef std::map<BrokerID, BrokerCBResourcePair> BrokerIDMap;
111 typedef std::function<void(OCStackResult, const unsigned int,
112 const std::string&)> SubscribeCB;
114 typedef std::function<void(const HeaderOptions&, const ResponseStatement&, int)> RequestGetCB;
115 typedef std::function<void(long long)> TimerCB;
116 } // namespace Service
119 #endif // RB_BROKERTYPES_H_