Merge "Fixed Warning in OCException"
[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                                                 bool isObservable,
76                                                 const std::vector<std::string>& resourceTypes,
77                                                 const std::vector<std::string>& interfaces)
78         {
79             return OCPlatform_impl::Instance().constructResourceObject(host, uri, isObservable,
80                                                 resourceTypes, interfaces);
81         }
82
83         OCStackResult findResource(const std::string& host,
84                                                 const std::string& resourceName,
85                                                 FindCallback resourceHandler)
86         {
87             return OCPlatform_impl::Instance().findResource(host, resourceName, resourceHandler);
88         }
89
90         OCStackResult findResource(const std::string& host,
91                                                 const std::string& resourceName,
92                                                 FindCallback resourceHandler, QualityOfService QoS)
93         {
94             return OCPlatform_impl::Instance().findResource(host, resourceName,
95                                                 resourceHandler, QoS);
96         }
97
98         OCStackResult getDeviceInfo(const std::string& host,
99                                                 const std::string& deviceURI,
100                                                 FindDeviceCallback deviceInfoHandler)
101         {
102             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, deviceInfoHandler);
103         }
104
105         OCStackResult getDeviceInfo(const std::string& host,
106                                                 const std::string& deviceURI,
107                                                 FindDeviceCallback deviceInfoHandler,
108                                                 QualityOfService QoS)
109         {
110             return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
111                     deviceInfoHandler, QoS);
112         }
113
114
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)
121         {
122             return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
123                                                 resourceTypeName, resourceInterface,
124                                                 entityHandler, resourceProperty);
125         }
126
127         OCStackResult registerResource(OCResourceHandle& resourceHandle,
128                                                 const std::shared_ptr< OCResource > resource)
129         {
130             return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
131         }
132
133         OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
134         {
135             return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
136         }
137
138         OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
139         {
140             return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
141         }
142
143         OCStackResult unbindResource(OCResourceHandle collectionHandle,
144                                                 OCResourceHandle resourceHandle)
145         {
146             return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
147         }
148
149         OCStackResult unbindResources(const OCResourceHandle collectionHandle,
150                                                 const std::vector<OCResourceHandle>& resourceHandles
151                                                 )
152         {
153             return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
154         }
155
156         OCStackResult bindResource(const OCResourceHandle collectionHandle,
157                                                 const OCResourceHandle resourceHandle)
158         {
159             return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
160         }
161
162         OCStackResult bindResources(const OCResourceHandle collectionHandle,
163                                                 const std::vector<OCResourceHandle>& resourceHandles
164                                                 )
165         {
166             return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
167         }
168
169         OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
170                                                 const std::string& resourceTypeName)
171         {
172             return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
173         }
174
175         OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
176                                                 const std::string& resourceInterfaceName)
177         {
178             return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
179                                                 resourceInterfaceName);
180         }
181
182         OCStackResult startPresence(const unsigned int announceDurationSeconds)
183         {
184             return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
185         }
186
187         OCStackResult stopPresence()
188         {
189             return OCPlatform_impl::Instance().stopPresence();
190         }
191
192         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
193                                                 const std::string& host,
194                                                 SubscribeCallback presenceHandler)
195         {
196             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
197                                                 presenceHandler);
198         }
199
200         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
201                                                 const std::string& host,
202                                                 const std::string& resourceType,
203                                                 SubscribeCallback presenceHandler)
204         {
205             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
206                                                 resourceType, presenceHandler);
207         }
208
209         OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
210         {
211             return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
212         }
213
214         OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
215         {
216             return OCPlatform_impl::Instance().sendResponse(pResponse);
217         }
218     } // namespace OCPlatform
219 } //namespace OC