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("virtualResource")
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
40 * Resource Coordinating Parameter Type
44 OIC_SOURCE_ADDRESS = 0,
45 OIC_MIRROR_ADDRESS = 1,
46 OIC_REQUEST_HANDLE = 0,
47 OIC_MIRROR_HANDLE = 1,
49 } OICResourceCoordinatorParamType;
52 * Property of Mirror Resource
54 typedef struct MirrorResourceProperty
56 int countResourceType;
59 char **resourceInterfaceName;
60 } MirrorResourceProperty;
63 * Mirror Resource Object
65 typedef struct MirrorResource
67 OCDoHandle resourceHandle[2]; // OIC_REQUEST_HANDLE = 0, OIC_VIRTUAL_HANDLE = 1
68 char *address[2]; // OIC_SOURCE_ADDRESS = 0, OIC_VIRTUAL_ADDRESS = 1
71 MirrorResourceProperty prop;
73 unsigned char isAliveCheck;
75 struct MirrorResource *next;
78 * for multiple resource
80 // virtualRepresentation rep2;
85 * Mirror Resource List
87 typedef struct MirrorResourceList
89 struct MirrorResource *headerNode;
90 struct MirrorResource *tailNode;
93 //-----------------------------------------------------------------------------
94 // Function prototypes
95 //-----------------------------------------------------------------------------
98 * Create an empty mirror resource list
101 * pointer to empty Mirror resource list
103 MirrorResourceList *createMirrorResourceList();
106 * Create an empty mirror resource.
109 * pointer to empty mirror resource
111 MirrorResource *createMirrorResource();
114 * Insert the mirror resource in the mirror resource list
116 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be inserted
117 * @param mirrorResource - pointer to mirror resource list to be inserted
119 * OIC_HOSTING_INVALID_PARAM - if list or vResource is null
120 * OIC_HOSTING_OK - successfully inserted
122 OCStackResult insertMirrorResource(MirrorResourceList *mirrorResourceList,
123 MirrorResource *mirrorResource);
126 * Delete the mirror resource from the mirror resource list
128 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be deleted
129 * @param mirrorResource - pointer to mirror resource list to be deleted
131 * OIC_HOSTING_INVALID_PARAM - if mirrorResourceList or mirrorResource is null
132 * OIC_HOSTING_ERROR - mirror resource delete process error
133 * OIC_HOSTING_OK - successfully deleted
135 OCStackResult deleteMirrorResourceFromList(MirrorResourceList *mirrorResourceList,
136 MirrorResource *mirrorResource);
139 * Destroy mirror resource
141 * @param mirrorResource - pointer to mirror resource to be destroyed
143 * OIC_HOSTING_INVALID_PARAM - if mirrorResource is null
144 * OIC_HOSTING_OK - successfully destroyed
146 OCStackResult destroyMirrorResource(MirrorResource *mirrorResource);
149 * Destroy mirror resource list
151 * @param mirrorResourceList - pointer to mirror resource list to be destroyed
153 * OIC_HOSTING_INVALID_PARAM - if mirrorResourceList is null
154 * OIC_HOSTING_OK - successfully destroyed
156 OCStackResult destroyMirrorResourceList(MirrorResourceList *mirrorResourceList);
159 * Find mirror resource using handle
161 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be found
162 * @param handle - handle value to be found
163 * @param paramType - handle type to be found
165 * NOTE: every parameter(handle and type) will be compared
168 * pointer to the found mirror resource
169 * NULL - mirror resource not found
171 MirrorResource *findMirrorResourceUsingHandle(MirrorResourceList *mirrorResourceList,
172 OCResourceHandle handle, OICResourceCoordinatorParamType paramType);
175 * find virtual resource using address function 사용하는지 확인 필요.
177 //virtualResource *findvResourceUsingAddress(virtualResourceList *list,
178 // const char *Address, OICResourceHostingParamType type, const char *subData);
181 * Find mirror resource using Address and URI
183 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be found
184 * @param address - pointer to address to be found
185 * @param paramType - address type to be found
186 * @param uri - pointer to uri to be found
188 * NOTE: every parameter(address, type and uri) will be compared
191 * pointer to the found mirror resource
192 * NULL - invalid input parameter or mirror resource not found
194 MirrorResource *findMirrorResourceUsingAddressAndURI(MirrorResourceList *mirrorResourceList,
195 const char *address, OICResourceCoordinatorParamType paramType, const char *uri);
198 * Find mirror resource list using Address and Hosting Parameter Type
200 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be found
201 * @param address - pointer to address to be found
202 * @param paramType - address type to be found
204 * NOTE: every parameter(address, type and uri) will be compared
207 * pointer to the found mirror resource
208 * NULL - invalid input parameter or mirror resource list not found
210 MirrorResourceList *findMirrorResourceListUsingAddress(MirrorResourceList *mirrorResourceList,
211 const char *address, OICResourceCoordinatorParamType paramType);
214 * Copy mirror resource
216 * @param sourceMirrorResource - pointer to source mirror resource
219 * pointer to the copied mirror resource
221 MirrorResource *cloneMirrorResource(MirrorResource *sourceMirrorResource);
224 * Eject mirror resource from mirror resource list
226 * @param mirrorResourceList - pointer to the target mirror resource list that mirror resource will be found
227 * @param mirrorResource - pointer to mirror resource to be ejected
230 * OIC_HOSTING_INVALID_PARAM - mirrorResourceList or mirrorResource is null
231 * OIC_HOSTING_OK - ejected successfully
232 * OIC_HOSTING_ERROR - cannot found mirror resource from mirrorResourceList same with mirrorResource
234 OCStackResult ejectMirrorResource(MirrorResourceList *mirrorResourceList,
235 MirrorResource *mirrorResource);
238 * Print mirror resources from mirror resource list
240 * @param mirrorResourceList - pointer to the mirror resource list that mirror resource will be printed
243 * OIC_HOSTING_INVALID_PARAM - mirrorResourceList is null or mirrorResourceList is empty
244 * OIC_HOSTING_OK - print successfully
246 OCStackResult printMirrorResourceList(MirrorResourceList *mirrorResourceList);