1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 //******************************************************************
25 // Description: Implementation of the OCPlatform.
29 //*********************************************************************
30 #include <OCPlatform.h>
35 void Configure(const PlatformConfig& config)
37 OCPlatform_impl::Configure(config);
40 OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler)
42 return OCPlatform_impl::Instance().setDefaultDeviceEntityHandler(entityHandler);
45 OCStackResult notifyAllObservers(OCResourceHandle resourceHandle,
48 return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle, QoS);
51 OCStackResult notifyAllObservers(OCResourceHandle resourceHandle)
53 return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle);
56 OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
57 ObservationIds& observationIds,
58 const std::shared_ptr<OCResourceResponse> pResponse)
60 return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
61 observationIds, pResponse);
64 OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
65 ObservationIds& observationIds,
66 const std::shared_ptr<OCResourceResponse> pResponse,
69 return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
70 observationIds, pResponse, QoS);
73 OCResource::Ptr constructResourceObject(const std::string& host,
74 const std::string& uri,
76 const std::vector<std::string>& resourceTypes,
77 const std::vector<std::string>& interfaces)
79 return OCPlatform_impl::Instance().constructResourceObject(host, uri, isObservable,
80 resourceTypes, interfaces);
83 OCStackResult findResource(const std::string& host,
84 const std::string& resourceName,
85 FindCallback resourceHandler)
87 return OCPlatform_impl::Instance().findResource(host, resourceName, resourceHandler);
90 OCStackResult findResource(const std::string& host,
91 const std::string& resourceName,
92 FindCallback resourceHandler, QualityOfService QoS)
94 return OCPlatform_impl::Instance().findResource(host, resourceName,
95 resourceHandler, QoS);
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)
106 return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
107 resourceTypeName, resourceInterface,
108 entityHandler, resourceProperty);
111 OCStackResult registerResource(OCResourceHandle& resourceHandle,
112 const std::shared_ptr< OCResource > resource)
114 return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
117 OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
119 return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
122 OCStackResult unbindResource(OCResourceHandle collectionHandle,
123 OCResourceHandle resourceHandle)
125 return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
128 OCStackResult unbindResources(const OCResourceHandle collectionHandle,
129 const std::vector<OCResourceHandle>& resourceHandles
132 return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
135 OCStackResult bindResource(const OCResourceHandle collectionHandle,
136 const OCResourceHandle resourceHandle)
138 return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
141 OCStackResult bindResources(const OCResourceHandle collectionHandle,
142 const std::vector<OCResourceHandle>& resourceHandles
145 return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
148 OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
149 const std::string& resourceTypeName)
151 return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
154 OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
155 const std::string& resourceInterfaceName)
157 return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
158 resourceInterfaceName);
161 OCStackResult startPresence(const unsigned int announceDurationSeconds)
163 return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
166 OCStackResult stopPresence()
168 return OCPlatform_impl::Instance().stopPresence();
171 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
172 const std::string& host,
173 SubscribeCallback presenceHandler)
175 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
179 OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
181 return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
183 } // namespace OCPlatform