1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH 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 //******************************************************************
25 // Description: Implementation of the OCPlatform.
29 //*********************************************************************
30 #include <OCPlatform.h>
35 void Configure(const PlatformConfig& config)
37 OCPlatform_impl::Configure(config);
40 OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler)
42 return OCPlatform_impl::Instance().setDefaultDeviceEntityHandler(entityHandler);
45 OCStackResult notifyAllObservers(OCResourceHandle resourceHandle,
48 return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle, QoS);
51 OCStackResult notifyAllObservers(OCResourceHandle resourceHandle)
53 return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle);
56 OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
57 ObservationIds& observationIds,
58 const std::shared_ptr<OCResourceResponse> pResponse)
60 return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
61 observationIds, pResponse);
64 OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
65 ObservationIds& observationIds,
66 const std::shared_ptr<OCResourceResponse> pResponse,
69 return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
70 observationIds, pResponse, QoS);
74 OCResource::Ptr constructResourceObject(const std::string& host,
75 const std::string& uri,
76 OCConnectivityType connectivityType,
78 const std::vector<std::string>& resourceTypes,
79 const std::vector<std::string>& interfaces)
81 return OCPlatform_impl::Instance().constructResourceObject(host, uri, connectivityType,
83 resourceTypes, interfaces);
86 OCStackResult findResource(const std::string& host,
87 const std::string& resourceName,
88 OCConnectivityType connectivityType,
89 FindCallback resourceHandler)
91 return OCPlatform_impl::Instance().findResource(host, resourceName,
92 connectivityType, resourceHandler);
95 OCStackResult findResource(const std::string& host,
96 const std::string& resourceName,
97 OCConnectivityType connectivityType,
98 FindCallback resourceHandler, QualityOfService QoS)
100 return OCPlatform_impl::Instance().findResource(host, resourceName, connectivityType,
101 resourceHandler, QoS);
104 OCStackResult getDeviceInfo(const std::string& host,
105 const std::string& deviceURI,
106 OCConnectivityType connectivityType,
107 FindDeviceCallback deviceInfoHandler)
109 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
110 connectivityType, deviceInfoHandler);
113 OCStackResult getDeviceInfo(const std::string& host,
114 const std::string& deviceURI,
115 OCConnectivityType connectivityType,
116 FindDeviceCallback deviceInfoHandler,
117 QualityOfService QoS)
119 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
120 deviceInfoHandler, QoS);
124 OCStackResult findResource(const std::string& host,
125 const std::string& resourceName,
126 FindCallback resourceHandler)
128 return OCPlatform_impl::Instance().findResource(host, resourceName, resourceHandler);
131 OCStackResult findResource(const std::string& host,
132 const std::string& resourceName,
133 FindCallback resourceHandler, QualityOfService QoS)
135 return OCPlatform_impl::Instance().findResource(host, resourceName,
136 resourceHandler, QoS);
139 OCResource::Ptr constructResourceObject(const std::string& host,
140 const std::string& uri,
142 const std::vector<std::string>& resourceTypes,
143 const std::vector<std::string>& interfaces)
145 return OCPlatform_impl::Instance().constructResourceObject(host, uri, isObservable,
146 resourceTypes, interfaces);
149 OCStackResult getDeviceInfo(const std::string& host,
150 const std::string& deviceURI,
151 FindDeviceCallback deviceInfoHandler)
153 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, deviceInfoHandler);
156 OCStackResult getDeviceInfo(const std::string& host,
157 const std::string& deviceURI,
158 FindDeviceCallback deviceInfoHandler,
159 QualityOfService QoS)
161 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, deviceInfoHandler, QoS);
165 OCStackResult registerResource(OCResourceHandle& resourceHandle,
166 std::string& resourceURI,
167 const std::string& resourceTypeName,
168 const std::string& resourceInterface,
169 EntityHandler entityHandler,
170 uint8_t resourceProperty)
172 return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
173 resourceTypeName, resourceInterface,
174 entityHandler, resourceProperty);
177 OCStackResult registerResource(OCResourceHandle& resourceHandle,
178 const std::shared_ptr< OCResource > resource)
180 return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
183 OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
185 return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
188 OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
190 return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
193 OCStackResult unbindResource(OCResourceHandle collectionHandle,
194 OCResourceHandle resourceHandle)
196 return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
199 OCStackResult unbindResources(const OCResourceHandle collectionHandle,
200 const std::vector<OCResourceHandle>& resourceHandles
203 return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
206 OCStackResult bindResource(const OCResourceHandle collectionHandle,
207 const OCResourceHandle resourceHandle)
209 return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
212 OCStackResult bindResources(const OCResourceHandle collectionHandle,
213 const std::vector<OCResourceHandle>& resourceHandles
216 return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
219 OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
220 const std::string& resourceTypeName)
222 return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
225 OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
226 const std::string& resourceInterfaceName)
228 return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
229 resourceInterfaceName);
232 OCStackResult startPresence(const unsigned int announceDurationSeconds)
234 return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
237 OCStackResult stopPresence()
239 return OCPlatform_impl::Instance().stopPresence();
243 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
244 const std::string& host,
245 OCConnectivityType connectivityType,
246 SubscribeCallback presenceHandler)
248 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
249 connectivityType, presenceHandler);
252 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
253 const std::string& host,
254 const std::string& resourceType,
255 OCConnectivityType connectivityType,
256 SubscribeCallback presenceHandler)
258 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
259 resourceType, connectivityType, presenceHandler);
262 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
263 const std::string& host,
264 SubscribeCallback presenceHandler)
266 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
270 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
271 const std::string& host,
272 const std::string& resourceType,
273 SubscribeCallback presenceHandler)
275 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
276 resourceType, presenceHandler);
280 OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
282 return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
285 OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
287 return OCPlatform_impl::Instance().sendResponse(pResponse);
289 } // namespace OCPlatform