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);
73 OCResource::Ptr constructResourceObject(const std::string& host,
74 const std::string& uri,
76 const std::vector<std::string>& resourceTypes,
77 const std::vector<std::string>& interfaces)
79 return OCPlatform_impl::Instance().constructResourceObject(host, uri, isObservable,
80 resourceTypes, interfaces);
83 OCStackResult findResource(const std::string& host,
84 const std::string& resourceName,
85 FindCallback resourceHandler)
87 return OCPlatform_impl::Instance().findResource(host, resourceName, resourceHandler);
90 OCStackResult findResource(const std::string& host,
91 const std::string& resourceName,
92 FindCallback resourceHandler, QualityOfService QoS)
94 return OCPlatform_impl::Instance().findResource(host, resourceName,
95 resourceHandler, QoS);
98 OCStackResult getDeviceInfo(const std::string& host,
99 const std::string& deviceURI,
100 FindDeviceCallback deviceInfoHandler)
102 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, deviceInfoHandler);
105 OCStackResult getDeviceInfo(const std::string& host,
106 const std::string& deviceURI,
107 FindDeviceCallback deviceInfoHandler,
108 QualityOfService QoS)
110 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
111 deviceInfoHandler, QoS);
115 OCStackResult registerResource(OCResourceHandle& resourceHandle,
116 std::string& resourceURI,
117 const std::string& resourceTypeName,
118 const std::string& resourceInterface,
119 EntityHandler entityHandler,
120 uint8_t resourceProperty)
122 return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
123 resourceTypeName, resourceInterface,
124 entityHandler, resourceProperty);
127 OCStackResult registerResource(OCResourceHandle& resourceHandle,
128 const std::shared_ptr< OCResource > resource)
130 return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
133 OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
135 return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
138 OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
140 return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
143 OCStackResult unbindResource(OCResourceHandle collectionHandle,
144 OCResourceHandle resourceHandle)
146 return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
149 OCStackResult unbindResources(const OCResourceHandle collectionHandle,
150 const std::vector<OCResourceHandle>& resourceHandles
153 return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
156 OCStackResult bindResource(const OCResourceHandle collectionHandle,
157 const OCResourceHandle resourceHandle)
159 return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
162 OCStackResult bindResources(const OCResourceHandle collectionHandle,
163 const std::vector<OCResourceHandle>& resourceHandles
166 return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
169 OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
170 const std::string& resourceTypeName)
172 return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
175 OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
176 const std::string& resourceInterfaceName)
178 return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
179 resourceInterfaceName);
182 OCStackResult startPresence(const unsigned int announceDurationSeconds)
184 return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
187 OCStackResult stopPresence()
189 return OCPlatform_impl::Instance().stopPresence();
192 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
193 const std::string& host,
194 SubscribeCallback presenceHandler)
196 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
200 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
201 const std::string& host,
202 const std::string& resourceType,
203 SubscribeCallback presenceHandler)
205 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
206 resourceType, presenceHandler);
209 OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
211 return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
214 OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
216 return OCPlatform_impl::Instance().sendResponse(pResponse);
218 } // namespace OCPlatform