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,
75 OCConnectivityType connectivityType,
77 const std::vector<std::string>& resourceTypes,
78 const std::vector<std::string>& interfaces)
80 return OCPlatform_impl::Instance().constructResourceObject(host,
81 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,
101 return OCPlatform_impl::Instance().findResource(host, resourceName,
102 connectivityType, resourceHandler, QoS);
105 OCStackResult getDeviceInfo(const std::string& host,
106 const std::string& deviceURI,
107 OCConnectivityType connectivityType,
108 FindDeviceCallback deviceInfoHandler)
110 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
111 connectivityType, deviceInfoHandler);
114 OCStackResult getDeviceInfo(const std::string& host,
115 const std::string& deviceURI,
116 OCConnectivityType connectivityType,
117 FindDeviceCallback deviceInfoHandler,
118 QualityOfService QoS)
120 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
121 deviceInfoHandler, QoS);
124 OCStackResult getPlatformInfo(const std::string& host,
125 const std::string& platformURI,
126 OCConnectivityType connectivityType,
127 FindPlatformCallback platformInfoHandler)
129 return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI,
130 connectivityType, platformInfoHandler);
133 OCStackResult getPlatformInfo(const std::string& host,
134 const std::string& platformURI,
135 OCConnectivityType connectivityType,
136 FindPlatformCallback platformInfoHandler,
137 QualityOfService QoS)
139 return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI, connectivityType,
140 platformInfoHandler, QoS);
143 OCStackResult registerResource(OCResourceHandle& resourceHandle,
144 std::string& resourceURI,
145 const std::string& resourceTypeName,
146 const std::string& resourceInterface,
147 EntityHandler entityHandler,
148 uint8_t resourceProperty)
150 return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
151 resourceTypeName, resourceInterface,
152 entityHandler, resourceProperty);
155 OCStackResult registerResource(OCResourceHandle& resourceHandle,
156 const std::shared_ptr< OCResource > resource)
158 return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
161 OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
163 return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
166 OCStackResult registerPlatformInfo(const OCPlatformInfo platformInfo)
168 return OCPlatform_impl::Instance().registerPlatformInfo(platformInfo);
171 OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
173 return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
176 OCStackResult unbindResource(OCResourceHandle collectionHandle,
177 OCResourceHandle resourceHandle)
179 return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
182 OCStackResult unbindResources(const OCResourceHandle collectionHandle,
183 const std::vector<OCResourceHandle>& resourceHandles
186 return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
189 OCStackResult bindResource(const OCResourceHandle collectionHandle,
190 const OCResourceHandle resourceHandle)
192 return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
195 OCStackResult bindResources(const OCResourceHandle collectionHandle,
196 const std::vector<OCResourceHandle>& resourceHandles
199 return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
202 OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
203 const std::string& resourceTypeName)
205 return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
208 OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
209 const std::string& resourceInterfaceName)
211 return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
212 resourceInterfaceName);
215 OCStackResult startPresence(const unsigned int announceDurationSeconds)
217 return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
220 OCStackResult stopPresence()
222 return OCPlatform_impl::Instance().stopPresence();
225 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
226 const std::string& host,
227 OCConnectivityType connectivityType,
228 SubscribeCallback presenceHandler)
230 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
231 connectivityType, presenceHandler);
234 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
235 const std::string& host,
236 const std::string& resourceType,
237 OCConnectivityType connectivityType,
238 SubscribeCallback presenceHandler)
240 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
241 resourceType, connectivityType, presenceHandler);
244 OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
246 return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
249 OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
251 return OCPlatform_impl::Instance().sendResponse(pResponse);
253 } // namespace OCPlatform