1 //******************************************************************
3 // Copyright 2015 Samsung Electronics 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 #ifndef _VIRTUAL_RESOURCE_H_
22 #define _VIRTUAL_RESOURCE_H_
33 #define TAG PCF("MirrorResource")
34 //-----------------------------------------------------------------------------
35 // Definition of Constant
36 //-----------------------------------------------------------------------------
37 #define VR_TAG "__NM__"
38 #define RH_TAG "__RM__"
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
45 * Resource Coordinating Parameter Type
50 * for mirrorResourceHandle
52 OIC_SOURCE_ADDRESS = 0,
53 OIC_MIRROR_ADDRESS = 1,
54 OIC_REQUEST_HANDLE = 0,
55 OIC_MIRROR_HANDLE = 1,
60 OIC_REQUEST_BY_CLIENT = 0,
61 OIC_REQUEST_BY_COORDINATOR = 1,
64 } OICResourceCoordinatorParamType;
67 * Property of Mirror Resource
69 typedef struct MirrorResourceProperty
71 int countResourceType;
74 char **resourceInterfaceName;
75 } MirrorResourceProperty;
78 * Mirror Resource Object
80 typedef struct MirrorResource
82 OCDoHandle resourceHandle[2]; // OIC_REQUEST_HANDLE = 0, OIC_VIRTUAL_HANDLE = 1
83 char *address[2]; // OIC_SOURCE_ADDRESS = 0, OIC_VIRTUAL_ADDRESS = 1
86 MirrorResourceProperty prop;
88 struct MirrorResource *next;
91 * for multiple resource
93 // virtualRepresentation rep2;
98 * Mirror Resource List
100 typedef struct MirrorResourceList
102 struct MirrorResource *headerNode;
103 struct MirrorResource *tailNode;
104 } MirrorResourceList;
109 typedef struct RequestHandle
111 void *requestHandle[2]; // OIC_REQUEST_BY_CLIENT = 0, OIC_REQUEST_BY_COORDINATOR = 1
112 OCResourceHandle resourceHandle;
113 OCRequestHandle entityRequestHandle;
117 unsigned char isAliveCheck;
119 struct RequestHandle *next;
123 * Request Object List
125 typedef struct RequestHandleList
127 struct RequestHandle *headerNode;
128 struct RequestHandle *tailNode;
131 //-----------------------------------------------------------------------------
132 // Function prototypes for mirrorResourceHandle
133 //-----------------------------------------------------------------------------
136 * Create an empty mirror resource list
139 * pointer to empty Mirror resource list
141 MirrorResourceList *createMirrorResourceList();
144 * Create an empty mirror resource.
147 * pointer to empty mirror resource
149 MirrorResource *createMirrorResource();
152 * Insert the mirror resource in the mirror resource list
154 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be inserted
155 * @param mirrorResource - pointer to mirror resource list to be inserted
157 * OIC_HOSTING_INVALID_PARAM - if list or vResource is null
158 * OIC_HOSTING_OK - successfully inserted
160 OCStackResult insertMirrorResource(MirrorResourceList *mirrorResourceList,
161 MirrorResource *mirrorResource);
164 * Delete the mirror resource from the mirror resource list
166 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be deleted
167 * @param mirrorResource - pointer to mirror resource list to be deleted
169 * OIC_HOSTING_INVALID_PARAM - if mirrorResourceList or mirrorResource is null
170 * OIC_HOSTING_ERROR - mirror resource delete process error
171 * OIC_HOSTING_OK - successfully deleted
173 OCStackResult deleteMirrorResourceFromList(MirrorResourceList *mirrorResourceList,
174 MirrorResource *mirrorResource);
177 * Destroy mirror resource
179 * @param mirrorResource - pointer to mirror resource to be destroyed
181 * OIC_HOSTING_INVALID_PARAM - if mirrorResource is null
182 * OIC_HOSTING_OK - successfully destroyed
184 OCStackResult destroyMirrorResource(MirrorResource *mirrorResource);
187 * Destroy mirror resource list
189 * @param mirrorResourceList - pointer to mirror resource list to be destroyed
191 * OIC_HOSTING_INVALID_PARAM - if mirrorResourceList is null
192 * OIC_HOSTING_OK - successfully destroyed
194 OCStackResult destroyMirrorResourceList(MirrorResourceList *mirrorResourceList);
197 * Find mirror resource using handle
199 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be found
200 * @param handle - handle value to be found
201 * @param paramType - handle type to be found
203 * NOTE: every parameter(handle and type) will be compared
206 * pointer to the found mirror resource
207 * NULL - mirror resource not found
209 MirrorResource *findMirrorResourceUsingHandle(MirrorResourceList *mirrorResourceList,
210 OCResourceHandle handle, OICResourceCoordinatorParamType paramType);
213 * find virtual resource using address function 사용하는지 확인 필요.
215 //virtualResource *findvResourceUsingAddress(virtualResourceList *list,
216 // const char *Address, OICResourceHostingParamType type, const char *subData);
219 * Find mirror resource using Address and URI
221 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be found
222 * @param address - pointer to address to be found
223 * @param paramType - address type to be found
224 * @param uri - pointer to uri to be found
226 * NOTE: every parameter(address, type and uri) will be compared
229 * pointer to the found mirror resource
230 * NULL - invalid input parameter or mirror resource not found
232 MirrorResource *findMirrorResourceUsingAddressAndURI(MirrorResourceList *mirrorResourceList,
233 const char *address, OICResourceCoordinatorParamType paramType, const char *uri);
236 * Find mirror resource list using Address and Hosting Parameter Type
238 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be found
239 * @param address - pointer to address to be found
240 * @param paramType - address type to be found
242 * NOTE: every parameter(address, type and uri) will be compared
245 * pointer to the found mirror resource
246 * NULL - invalid input parameter or mirror resource list not found
248 MirrorResourceList *findMirrorResourceListUsingAddress(MirrorResourceList *mirrorResourceList,
249 const char *address, OICResourceCoordinatorParamType paramType);
252 * Copy mirror resource
254 * @param sourceMirrorResource - pointer to source mirror resource
257 * pointer to the copied mirror resource
259 MirrorResource *cloneMirrorResource(MirrorResource *sourceMirrorResource);
262 * Eject mirror resource from mirror resource list
264 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be found
265 * @param mirrorResource - pointer to mirror resource to be ejected
268 * OIC_HOSTING_INVALID_PARAM - mirrorResourceList or mirrorResource is null
269 * OIC_HOSTING_OK - ejected successfully
270 * OIC_HOSTING_ERROR - cannot found mirror resource from mirrorResourceList same with mirrorResource
272 OCStackResult ejectMirrorResource(MirrorResourceList *mirrorResourceList,
273 MirrorResource *mirrorResource);
276 * Print mirror resources from mirror resource list
278 * @param mirrorResourceList - pointer to the mirror resource list that mirror resource will be printed
281 * OIC_HOSTING_INVALID_PARAM - mirrorResourceList is null or mirrorResourceList is empty
282 * OIC_HOSTING_OK - print successfully
284 OCStackResult printMirrorResourceList(MirrorResourceList *mirrorResourceList);
286 //-----------------------------------------------------------------------------
287 // Function prototypes for RequestHandle
288 //-----------------------------------------------------------------------------
289 RequestHandleList *createRequestHandleList();
290 RequestHandle *createRequestHandle();
291 OCStackResult insertRequestHandle(RequestHandleList *requestHandleList,
292 RequestHandle *requestHandle);
294 OCStackResult deleteRequestHandleFromList(RequestHandleList *requestHandleList,
295 RequestHandle *requestHandle);
296 OCStackResult destroyRequestHandle(RequestHandle *requestHandle);
298 OCStackResult destroyRequestHandleList(RequestHandleList *requestHandleList);
300 RequestHandle *findRequestHandle(RequestHandleList *requestHandleList,
301 OCDoHandle handle, OICResourceCoordinatorParamType paramType);
303 #endif //_MIRROR_RESOURCE_H_