Repo Merge: Moving resource API down a directory
[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 unregisterResource(const OCResourceHandle& resourceHandle)
112         {
113             return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
114         }
115
116         OCStackResult unbindResource(OCResourceHandle collectionHandle,
117                                                 OCResourceHandle resourceHandle)
118         {
119             return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
120         }
121
122         OCStackResult unbindResources(const OCResourceHandle collectionHandle,
123                                                 const std::vector<OCResourceHandle>& resourceHandles
124                                                 )
125         {
126             return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
127         }
128
129         OCStackResult bindResource(const OCResourceHandle collectionHandle,
130                                                 const OCResourceHandle resourceHandle)
131         {
132             return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
133         }
134
135         OCStackResult bindResources(const OCResourceHandle collectionHandle,
136                                                 const std::vector<OCResourceHandle>& resourceHandles
137                                                 )
138         {
139             return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
140         }
141
142         OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
143                                                 const std::string& resourceTypeName)
144         {
145             return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
146         }
147
148         OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
149                                                 const std::string& resourceInterfaceName)
150         {
151             return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
152                                                 resourceInterfaceName);
153         }
154
155         OCStackResult startPresence(const unsigned int announceDurationSeconds)
156         {
157             return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
158         }
159
160         OCStackResult stopPresence()
161         {
162             return OCPlatform_impl::Instance().stopPresence();
163         }
164
165         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
166                                                 const std::string& host,
167                                                 SubscribeCallback presenceHandler)
168         {
169             return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
170                                                 presenceHandler);
171         }
172
173         OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
174         {
175             return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
176         }
177     } // namespace OCPlatform
178 } //namespace OC