1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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_
28 #include "experimental/logger.h"
29 #include "PrimitiveResource.h"
36 #define BROKER_TAG "BROKER" /*!< broker tag information */
37 #define BROKER_DEVICE_PRESENCE_TIMEROUT (15000l) /*!< broker device presence timeout value */
38 #define BROKER_SAFE_SECOND (5l) /*!< broker safe secons */
39 #define BROKER_SAFE_MILLISECOND (BROKER_SAFE_SECOND * (1000)) /*!< safe millisecons */
40 #define BROKER_TRANSPORT OCConnectivityType::CT_ADAPTER_IP /*!< transport type */
44 * brief : resourcePresence state
45 * ALIVE - It means that 'getCB' function receives 'OK' message
46 * REQUESTED - It means that broker receives the request for presence checking
47 * LOST_SIGNAL - In case that 'getCB' function receives the message except 'OK'
48 * DESTROYED - In case that the presence checking is dismissed for the resource ,
49 * or there is no matched value in the Broker Callback list
50 * NONE - To be determined.
52 enum class BROKER_STATE
63 * brief : devicePresence state
64 * ALIVE - It means that 'subscribeCB' function receives 'OK' message
65 * REQUESTED - It means that broker receives the request for presence checking
66 * LOST_SIGNAL - In case that 'subscribeCB' function receives the message except 'OK'
68 enum class DEVICE_STATE
70 ALIVE = 0, /*!< alive state */
71 REQUESTED, /*!< requested state */
72 LOST_SIGNAL /*!< lost signal state */
75 enum class BROKER_MODE
77 DEVICE_PRESENCE_MODE = 0, /*!< device presence mode */
78 NON_PRESENCE_MODE /*!< none device presence mode */
81 typedef unsigned int BrokerID; /*!< broker ID */
83 typedef std::function<void(BROKER_STATE)> BrokerCB;
84 struct BrokerRequesterInfo
86 BrokerRequesterInfo(BrokerID _id, BrokerCB _cb) : brokerId(_id), brokerCB(_cb){}
87 BrokerID brokerId; /*!< broker Id */
88 BrokerCB brokerCB; /*!< broker callback */
90 typedef std::shared_ptr<BrokerRequesterInfo> BrokerRequesterInfoPtr;
92 class ResourcePresence;
95 typedef std::function<void(std::shared_ptr<OC::OCResource>)> FindCB;
97 typedef std::shared_ptr<PrimitiveResource> PrimitiveResourcePtr;
99 typedef std::shared_ptr<ResourcePresence> ResourcePresencePtr;
100 typedef std::shared_ptr<DevicePresence> DevicePresencePtr;
101 typedef std::list< ResourcePresencePtr > PresenceList;
103 struct BrokerCBResourcePair
105 BrokerCBResourcePair(ResourcePresencePtr pResource, BrokerCB cb)
106 : pResource(pResource), brokerCB(cb){}
107 ResourcePresencePtr pResource;
110 typedef std::map<BrokerID, BrokerCBResourcePair> BrokerIDMap;
112 typedef std::function<void(OCStackResult, const unsigned int,
113 const std::string&)> SubscribeCB;
115 typedef std::function<void(const HeaderOptions&, const ResponseStatement&, int)> RequestGetCB;
116 typedef std::function<void(long long)> TimerCB;
117 } /* namespace Service */
118 } /* namespace OIC */
120 #endif /* RB_BROKERTYPES_H_ */