1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
//******************************************************************
//
// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//******************************************************************
// File name:
// OCPlatform.cpp
//
// Description: Implementation of the OCPlatform.
//
//
//
//*********************************************************************
#include <OCPlatform.h>
namespace OC
{
namespace OCPlatform
{
void Configure(const PlatformConfig& config)
{
OCPlatform_impl::Configure(config);
}
OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler)
{
return OCPlatform_impl::Instance().setDefaultDeviceEntityHandler(entityHandler);
}
OCStackResult notifyAllObservers(OCResourceHandle resourceHandle,
QualityOfService QoS)
{
return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle, QoS);
}
OCStackResult notifyAllObservers(OCResourceHandle resourceHandle)
{
return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle);
}
OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
ObservationIds& observationIds,
const std::shared_ptr<OCResourceResponse> pResponse)
{
return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
observationIds, pResponse);
}
OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
ObservationIds& observationIds,
const std::shared_ptr<OCResourceResponse> pResponse,
QualityOfService QoS)
{
return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
observationIds, pResponse, QoS);
}
OCResource::Ptr constructResourceObject(const std::string& host,
const std::string& uri,
bool isObservable,
const std::vector<std::string>& resourceTypes,
const std::vector<std::string>& interfaces)
{
return OCPlatform_impl::Instance().constructResourceObject(host, uri, isObservable,
resourceTypes, interfaces);
}
OCStackResult findResource(const std::string& host,
const std::string& resourceName,
FindCallback resourceHandler)
{
return OCPlatform_impl::Instance().findResource(host, resourceName, resourceHandler);
}
OCStackResult findResource(const std::string& host,
const std::string& resourceName,
FindCallback resourceHandler, QualityOfService QoS)
{
return OCPlatform_impl::Instance().findResource(host, resourceName,
resourceHandler, QoS);
}
OCStackResult getDeviceInfo(const std::string& host,
const std::string& deviceURI,
FindDeviceCallback deviceInfoHandler)
{
return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, deviceInfoHandler);
}
OCStackResult getDeviceInfo(const std::string& host,
const std::string& deviceURI,
FindDeviceCallback deviceInfoHandler,
QualityOfService QoS)
{
return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
deviceInfoHandler, QoS);
}
OCStackResult registerResource(OCResourceHandle& resourceHandle,
std::string& resourceURI,
const std::string& resourceTypeName,
const std::string& resourceInterface,
EntityHandler entityHandler,
uint8_t resourceProperty)
{
return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
resourceTypeName, resourceInterface,
entityHandler, resourceProperty);
}
OCStackResult registerResource(OCResourceHandle& resourceHandle,
const std::shared_ptr< OCResource > resource)
{
return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
}
OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
{
return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
}
OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
{
return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
}
OCStackResult unbindResource(OCResourceHandle collectionHandle,
OCResourceHandle resourceHandle)
{
return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
}
OCStackResult unbindResources(const OCResourceHandle collectionHandle,
const std::vector<OCResourceHandle>& resourceHandles
)
{
return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
}
OCStackResult bindResource(const OCResourceHandle collectionHandle,
const OCResourceHandle resourceHandle)
{
return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
}
OCStackResult bindResources(const OCResourceHandle collectionHandle,
const std::vector<OCResourceHandle>& resourceHandles
)
{
return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
}
OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
const std::string& resourceTypeName)
{
return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
}
OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
const std::string& resourceInterfaceName)
{
return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
resourceInterfaceName);
}
OCStackResult startPresence(const unsigned int announceDurationSeconds)
{
return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
}
OCStackResult stopPresence()
{
return OCPlatform_impl::Instance().stopPresence();
}
OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
const std::string& host,
SubscribeCallback presenceHandler)
{
return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
presenceHandler);
}
OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
const std::string& host,
const std::string& resourceType,
SubscribeCallback presenceHandler)
{
return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
resourceType, presenceHandler);
}
OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
{
return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
}
OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
{
return OCPlatform_impl::Instance().sendResponse(pResponse);
}
} // namespace OCPlatform
} //namespace OC
|