Merge "Implemented libcoap's tinyDTLS interface"
[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
99         OCStackResult registerResource(OCResourceHandle& resourceHandle,
100                                                 std::string& resourceURI,
101                                                 const std::string& resourceTypeName,
102                                                 const std::string& resourceInterface,
103                                                 EntityHandler entityHandler,
104                                                 uint8_t resourceProperty)
105         {
106             return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
107                                                 resourceTypeName, resourceInterface,
108                                                 entityHandler, resourceProperty);
109         }
110
111         OCStackResult registerResource(OCResourceHandle& resourceHandle,
112                                                 const std::shared_ptr< OCResource > resource)
113         {
114             return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
115         }
116
117         OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
118         {
119             return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
120         }
121
122         OCStackResult unbindResource(OCResourceHandle collectionHandle,
123                                                 OCResourceHandle resourceHandle)
124         {
125             return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
126         }
127
128         OCStackResult unbindResources(const OCResourceHandle collectionHandle,
129                                                 const std::vector<OCResourceHandle>& resourceHandles
130                                                 )
131         {
132             return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
133         }
134
135         OCStackResult bindResource(const OCResourceHandle collectionHandle,
136                                                 const OCResourceHandle resourceHandle)
137         {
138             return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
139         }
140
141         OCStackResult bindResources(const OCResourceHandle collectionHandle,
142                                                 const std::vector<OCResourceHandle>& resourceHandles
143                                                 )
144         {
145             return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
146         }
147
148         OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
149                                                 const std::string& resourceTypeName)
150         {
151             return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
152         }
153
154         OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
155                                                 const std::string& resourceInterfaceName)
156         {
157             return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
158                                                 resourceInterfaceName);
159         }
160
161         OCStackResult startPresence(const unsigned int announceDurationSeconds)
162         {
163             return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
164         }
165
166         OCStackResult stopPresence()
167         {
168             return OCPlatform_impl::Instance().stopPresence();
169         }
170
171         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
172                                                 const std::string& host,
173                                                 SubscribeCallback presenceHandler)
174         {
175             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
176                                                 presenceHandler);
177         }
178
179         OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
180         {
181             return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
182         }
183     } // namespace OCPlatform
184 } //namespace OC