Merge "Fix build warnings" into connectivity-abstraction
[platform/upstream/iotivity.git] / resource / src / OCPlatform.cpp
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 //******************************************************************
22 // File name:
23 //     OCPlatform.cpp
24 //
25 // Description: Implementation of the OCPlatform.
26 //
27 //
28 //
29 //*********************************************************************
30 #include <OCPlatform.h>
31 namespace OC
32 {
33     namespace OCPlatform
34     {
35         void Configure(const PlatformConfig& config)
36         {
37             OCPlatform_impl::Configure(config);
38         }
39
40         OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler)
41         {
42             return OCPlatform_impl::Instance().setDefaultDeviceEntityHandler(entityHandler);
43         }
44
45         OCStackResult notifyAllObservers(OCResourceHandle resourceHandle,
46                                                 QualityOfService QoS)
47         {
48             return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle, QoS);
49         }
50
51         OCStackResult notifyAllObservers(OCResourceHandle resourceHandle)
52         {
53             return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle);
54         }
55
56         OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
57                                                 ObservationIds& observationIds,
58                                                 const std::shared_ptr<OCResourceResponse> pResponse)
59         {
60             return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
61                                                 observationIds, pResponse);
62         }
63
64         OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
65                                                 ObservationIds& observationIds,
66                                                 const std::shared_ptr<OCResourceResponse> pResponse,
67                                                 QualityOfService QoS)
68         {
69             return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
70                                                     observationIds, pResponse, QoS);
71         }
72
73 #ifdef CA_INT
74         OCResource::Ptr constructResourceObject(const std::string& host,
75                                                 const std::string& uri,
76                                                 OCConnectivityType connectivityType,
77                                                 bool isObservable,
78                                                 const std::vector<std::string>& resourceTypes,
79                                                 const std::vector<std::string>& interfaces)
80         {
81             return OCPlatform_impl::Instance().constructResourceObject(host, uri, connectivityType,
82                                                 isObservable,
83                                                 resourceTypes, interfaces);
84         }
85
86         OCStackResult findResource(const std::string& host,
87                                                 const std::string& resourceName,
88                                                 OCConnectivityType connectivityType,
89                                                 FindCallback resourceHandler)
90         {
91             return OCPlatform_impl::Instance().findResource(host, resourceName,
92                    connectivityType, resourceHandler);
93         }
94
95         OCStackResult findResource(const std::string& host,
96                                                 const std::string& resourceName,
97                                                 OCConnectivityType connectivityType,
98                                                 FindCallback resourceHandler, QualityOfService QoS)
99         {
100             return OCPlatform_impl::Instance().findResource(host, resourceName, connectivityType,
101                                                 resourceHandler, QoS);
102         }
103
104         OCStackResult getDeviceInfo(const std::string& host,
105                                                 const std::string& deviceURI,
106                                                 OCConnectivityType connectivityType,
107                                                 FindDeviceCallback deviceInfoHandler)
108         {
109             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
110                    connectivityType, deviceInfoHandler);
111         }
112
113         OCStackResult getDeviceInfo(const std::string& host,
114                                                 const std::string& deviceURI,
115                                                 OCConnectivityType connectivityType,
116                                                 FindDeviceCallback deviceInfoHandler,
117                                                 QualityOfService QoS)
118         {
119             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
120                     deviceInfoHandler, QoS);
121         }
122 #endif
123
124         OCStackResult findResource(const std::string& host,
125                                                 const std::string& resourceName,
126                                                 FindCallback resourceHandler)
127         {
128 //TODO-CA Revisit this API
129 #ifdef CA_INT
130             return OCPlatform_impl::Instance().findResource(host, resourceName,
131                                                     OC_WIFI, resourceHandler);
132 #else
133             return OCPlatform_impl::Instance().findResource(host, resourceName, resourceHandler);
134 #endif
135         }
136
137         OCStackResult findResource(const std::string& host,
138                                                 const std::string& resourceName,
139                                                 FindCallback resourceHandler, QualityOfService QoS)
140         {
141 //TODO-CA Revisit this API
142 #ifdef CA_INT
143             return OCPlatform_impl::Instance().findResource(host, resourceName,
144                                                 OC_WIFI, resourceHandler, QoS);
145 #else
146             return OCPlatform_impl::Instance().findResource(host, resourceName,
147                                                 resourceHandler, QoS);
148 #endif
149         }
150
151         OCResource::Ptr constructResourceObject(const std::string& host,
152                                                 const std::string& uri,
153                                                 bool isObservable,
154                                                 const std::vector<std::string>& resourceTypes,
155                                                 const std::vector<std::string>& interfaces)
156         {
157 //TODO-CA Revisit this API
158 #ifdef CA_INT
159             return OCPlatform_impl::Instance().constructResourceObject(host, uri, OC_WIFI,
160                                                 isObservable, resourceTypes, interfaces);
161 #else
162             return OCPlatform_impl::Instance().constructResourceObject(host, uri, isObservable,
163                                                 resourceTypes, interfaces);
164 #endif
165         }
166
167         OCStackResult getDeviceInfo(const std::string& host,
168                                                 const std::string& deviceURI,
169                                                 FindDeviceCallback deviceInfoHandler)
170         {
171 #ifdef CA_INT
172             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, OC_WIFI,
173                                                             deviceInfoHandler);
174 #else
175             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, deviceInfoHandler);
176 #endif
177         }
178
179         OCStackResult getDeviceInfo(const std::string& host,
180                                                 const std::string& deviceURI,
181                                                 FindDeviceCallback deviceInfoHandler,
182                                                 QualityOfService QoS)
183         {
184 #ifdef CA_INT
185             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, OC_WIFI,
186                                                             deviceInfoHandler, QoS);
187 #else
188             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, deviceInfoHandler, QoS);
189 #endif
190         }
191
192
193         OCStackResult registerResource(OCResourceHandle& resourceHandle,
194                                                 std::string& resourceURI,
195                                                 const std::string& resourceTypeName,
196                                                 const std::string& resourceInterface,
197                                                 EntityHandler entityHandler,
198                                                 uint8_t resourceProperty)
199         {
200             return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
201                                                 resourceTypeName, resourceInterface,
202                                                 entityHandler, resourceProperty);
203         }
204
205         OCStackResult registerResource(OCResourceHandle& resourceHandle,
206                                                 const std::shared_ptr< OCResource > resource)
207         {
208             return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
209         }
210
211         OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
212         {
213             return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
214         }
215
216         OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
217         {
218             return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
219         }
220
221         OCStackResult unbindResource(OCResourceHandle collectionHandle,
222                                                 OCResourceHandle resourceHandle)
223         {
224             return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
225         }
226
227         OCStackResult unbindResources(const OCResourceHandle collectionHandle,
228                                                 const std::vector<OCResourceHandle>& resourceHandles
229                                                 )
230         {
231             return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
232         }
233
234         OCStackResult bindResource(const OCResourceHandle collectionHandle,
235                                                 const OCResourceHandle resourceHandle)
236         {
237             return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
238         }
239
240         OCStackResult bindResources(const OCResourceHandle collectionHandle,
241                                                 const std::vector<OCResourceHandle>& resourceHandles
242                                                 )
243         {
244             return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
245         }
246
247         OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
248                                                 const std::string& resourceTypeName)
249         {
250             return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
251         }
252
253         OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
254                                                 const std::string& resourceInterfaceName)
255         {
256             return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
257                                                 resourceInterfaceName);
258         }
259
260         OCStackResult startPresence(const unsigned int announceDurationSeconds)
261         {
262             return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
263         }
264
265         OCStackResult stopPresence()
266         {
267             return OCPlatform_impl::Instance().stopPresence();
268         }
269
270 #ifdef CA_INT
271         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
272                                                 const std::string& host,
273                                                 OCConnectivityType connectivityType,
274                                                 SubscribeCallback presenceHandler)
275         {
276             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
277                                                 connectivityType, presenceHandler);
278         }
279
280         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
281                                                 const std::string& host,
282                                                 const std::string& resourceType,
283                                                 OCConnectivityType connectivityType,
284                                                 SubscribeCallback presenceHandler)
285         {
286             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
287                                                 resourceType, connectivityType, presenceHandler);
288         }
289 #endif
290         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
291                                                 const std::string& host,
292                                                 SubscribeCallback presenceHandler)
293         {
294 //TODO-CA Revisit this API
295 #ifdef CA_INT
296             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
297                                                 OC_WIFI, presenceHandler);
298 #else
299             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
300                                                 presenceHandler);
301 #endif
302         }
303
304         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
305                                                 const std::string& host,
306                                                 const std::string& resourceType,
307                                                 SubscribeCallback presenceHandler)
308         {
309 //TODO-CA Revisit this API
310 #ifdef CA_INT
311             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
312                                                 resourceType, OC_WIFI,
313                                                 presenceHandler);
314 #else
315             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
316                                                 resourceType, presenceHandler);
317 #endif
318         }
319
320         OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
321         {
322             return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
323         }
324
325         OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
326         {
327             return OCPlatform_impl::Instance().sendResponse(pResponse);
328         }
329     } // namespace OCPlatform
330 } //namespace OC