Imported Upstream version 0.9.1
[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         OCResource::Ptr constructResourceObject(const std::string& host,
74                                                 const std::string& uri,
75                                                 OCConnectivityType connectivityType,
76                                                 bool isObservable,
77                                                 const std::vector<std::string>& resourceTypes,
78                                                 const std::vector<std::string>& interfaces)
79         {
80             return OCPlatform_impl::Instance().constructResourceObject(host, uri, connectivityType,
81                                                 isObservable,
82                                                 resourceTypes, interfaces);
83         }
84
85         OCStackResult findResource(const std::string& host,
86                                                 const std::string& resourceName,
87                                                 OCConnectivityType connectivityType,
88                                                 FindCallback resourceHandler)
89         {
90             return OCPlatform_impl::Instance().findResource(host, resourceName,
91                    connectivityType, resourceHandler);
92         }
93
94         OCStackResult findResource(const std::string& host,
95                                                 const std::string& resourceName,
96                                                 OCConnectivityType connectivityType,
97                                                 FindCallback resourceHandler, QualityOfService QoS)
98         {
99             return OCPlatform_impl::Instance().findResource(host, resourceName, connectivityType,
100                                                 resourceHandler, QoS);
101         }
102
103         OCStackResult getDeviceInfo(const std::string& host,
104                                                 const std::string& deviceURI,
105                                                 OCConnectivityType connectivityType,
106                                                 FindDeviceCallback deviceInfoHandler)
107         {
108             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
109                    connectivityType, deviceInfoHandler);
110         }
111
112         OCStackResult getDeviceInfo(const std::string& host,
113                                                 const std::string& deviceURI,
114                                                 OCConnectivityType connectivityType,
115                                                 FindDeviceCallback deviceInfoHandler,
116                                                 QualityOfService QoS)
117         {
118             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
119                     deviceInfoHandler, QoS);
120         }
121
122         OCStackResult getPlatformInfo(const std::string& host,
123                                                 const std::string& platformURI,
124                                                 OCConnectivityType connectivityType,
125                                                 FindPlatformCallback platformInfoHandler)
126         {
127             return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI,
128                    connectivityType, platformInfoHandler);
129         }
130
131         OCStackResult getPlatformInfo(const std::string& host,
132                                                 const std::string& platformURI,
133                                                 OCConnectivityType connectivityType,
134                                                 FindPlatformCallback platformInfoHandler,
135                                                 QualityOfService QoS)
136         {
137             return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI, connectivityType,
138                     platformInfoHandler, QoS);
139         }
140
141         OCStackResult registerResource(OCResourceHandle& resourceHandle,
142                                                 std::string& resourceURI,
143                                                 const std::string& resourceTypeName,
144                                                 const std::string& resourceInterface,
145                                                 EntityHandler entityHandler,
146                                                 uint8_t resourceProperty)
147         {
148             return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
149                                                 resourceTypeName, resourceInterface,
150                                                 entityHandler, resourceProperty);
151         }
152
153         OCStackResult registerResource(OCResourceHandle& resourceHandle,
154                                                 const std::shared_ptr< OCResource > resource)
155         {
156             return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
157         }
158
159         OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
160         {
161             return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
162         }
163
164         OCStackResult registerPlatformInfo(const OCPlatformInfo platformInfo)
165         {
166             return OCPlatform_impl::Instance().registerPlatformInfo(platformInfo);
167         }
168
169         OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
170         {
171             return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
172         }
173
174         OCStackResult unbindResource(OCResourceHandle collectionHandle,
175                                                 OCResourceHandle resourceHandle)
176         {
177             return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
178         }
179
180         OCStackResult unbindResources(const OCResourceHandle collectionHandle,
181                                                 const std::vector<OCResourceHandle>& resourceHandles
182                                                 )
183         {
184             return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
185         }
186
187         OCStackResult bindResource(const OCResourceHandle collectionHandle,
188                                                 const OCResourceHandle resourceHandle)
189         {
190             return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
191         }
192
193         OCStackResult bindResources(const OCResourceHandle collectionHandle,
194                                                 const std::vector<OCResourceHandle>& resourceHandles
195                                                 )
196         {
197             return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
198         }
199
200         OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
201                                                 const std::string& resourceTypeName)
202         {
203             return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
204         }
205
206         OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
207                                                 const std::string& resourceInterfaceName)
208         {
209             return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
210                                                 resourceInterfaceName);
211         }
212
213         OCStackResult startPresence(const unsigned int announceDurationSeconds)
214         {
215             return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
216         }
217
218         OCStackResult stopPresence()
219         {
220             return OCPlatform_impl::Instance().stopPresence();
221         }
222
223         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
224                                                 const std::string& host,
225                                                 OCConnectivityType connectivityType,
226                                                 SubscribeCallback presenceHandler)
227         {
228             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
229                                                 connectivityType, presenceHandler);
230         }
231
232         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
233                                                 const std::string& host,
234                                                 const std::string& resourceType,
235                                                 OCConnectivityType connectivityType,
236                                                 SubscribeCallback presenceHandler)
237         {
238             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
239                                                 resourceType, connectivityType, presenceHandler);
240         }
241
242         OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
243         {
244             return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
245         }
246
247         OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
248         {
249             return OCPlatform_impl::Instance().sendResponse(pResponse);
250         }
251     } // namespace OCPlatform
252 } //namespace OC
253