Update comments in Things Manager for doxygen
[platform/upstream/iotivity.git] / service / notification-manager / NotificationManager / include / virtualResource.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics 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 #ifndef _VIRTUAL_RESOURCE_H_
22 #define _VIRTUAL_RESOURCE_H_
23
24 #include <stdio.h>
25 #include <string.h>
26 #include <stdlib.h>
27
28 #include "ocstack.h"
29 #include "ocsocket.h"
30 #include "logger.h"
31
32 #include "cJSON.h"
33 #define TAG  PCF("virtualResource")
34
35 //-----------------------------------------------------------------------------
36 // Typedefs
37 //-----------------------------------------------------------------------------
38
39 /**
40 * Resource Coordinating Parameter Type
41 */
42 typedef enum
43 {
44     OIC_SOURCE_ADDRESS     = 0,
45     OIC_MIRROR_ADDRESS     = 1,
46     OIC_REQUEST_HANDLE     = 0,
47     OIC_MIRROR_HANDLE      = 1,
48     OIC_NONE               = 255
49 } OICResourceCoordinatorParamType;
50
51 /**
52 * Property of Mirror Resource
53 */
54 typedef struct MirrorResourceProperty
55 {
56     int countResourceType;
57     int countInterface;
58     char **resourceType;
59     char **resourceInterfaceName;
60 } MirrorResourceProperty;
61
62 /**
63 * Mirror Resource Object
64 */
65 typedef struct MirrorResource
66 {
67     OCDoHandle resourceHandle[2];   // OIC_REQUEST_HANDLE = 0, OIC_VIRTUAL_HANDLE = 1
68     char *address[2];               // OIC_SOURCE_ADDRESS = 0, OIC_VIRTUAL_ADDRESS = 1
69     cJSON *rep;
70     char *uri;
71     MirrorResourceProperty prop;
72
73     unsigned char isAliveCheck;
74
75     struct MirrorResource *next;
76
77     /*
78      * for multiple resource
79      */
80 //  virtualRepresentation rep2;
81
82 } MirrorResource;
83
84 /**
85 * Mirror Resource List
86 */
87 typedef struct MirrorResourceList
88 {
89     struct MirrorResource *headerNode;
90     struct MirrorResource *tailNode;
91 } MirrorResourceList;
92
93 //-----------------------------------------------------------------------------
94 // Function prototypes
95 //-----------------------------------------------------------------------------
96
97 /**
98 * Create an empty mirror resource list
99 *
100 * @return
101 *     pointer to empty Mirror resource list
102 */
103 MirrorResourceList *createMirrorResourceList();
104
105 /**
106 * Create an empty mirror resource.
107 *
108 * @return
109 *     pointer to empty mirror resource
110 */
111 MirrorResource *createMirrorResource();
112
113 /**
114 * Insert the mirror resource in the mirror resource list
115 *
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
118 * @return
119 *     OIC_HOSTING_INVALID_PARAM - if list or vResource is null
120 *     OIC_HOSTING_OK - successfully inserted
121 */
122 OCStackResult insertMirrorResource(MirrorResourceList *mirrorResourceList,
123                                    MirrorResource *mirrorResource);
124
125 /**
126 * Delete the mirror resource from the mirror resource list
127 *
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
130 * @return
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
134 */
135 OCStackResult deleteMirrorResourceFromList(MirrorResourceList *mirrorResourceList,
136         MirrorResource *mirrorResource);
137
138 /**
139 * Destroy mirror resource
140 *
141 * @param mirrorResource - pointer to mirror resource to be destroyed
142 * @return
143 *     OIC_HOSTING_INVALID_PARAM - if mirrorResource is null
144 *     OIC_HOSTING_OK - successfully destroyed
145 */
146 OCStackResult destroyMirrorResource(MirrorResource *mirrorResource);
147
148 /**
149 * Destroy mirror resource list
150 *
151 * @param mirrorResourceList - pointer to mirror resource list to be destroyed
152 * @return
153 *     OIC_HOSTING_INVALID_PARAM - if mirrorResourceList is null
154 *     OIC_HOSTING_OK - successfully destroyed
155 */
156 OCStackResult destroyMirrorResourceList(MirrorResourceList *mirrorResourceList);
157
158 /**
159 * Find mirror resource using handle
160 *
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
164 *
165 * NOTE: every parameter(handle and type) will be compared
166 *
167 * @return
168 *     pointer to the found mirror resource
169 *     NULL - mirror resource not found
170 */
171 MirrorResource *findMirrorResourceUsingHandle(MirrorResourceList *mirrorResourceList,
172         OCResourceHandle handle, OICResourceCoordinatorParamType paramType);
173
174 /*
175  * find virtual resource using address function 사용하는지 확인 필요.
176  */
177 //virtualResource *findvResourceUsingAddress(virtualResourceList *list,
178 //        const char *Address, OICResourceHostingParamType type, const char *subData);
179
180 /**
181 * Find mirror resource using Address and URI
182 *
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
187 *
188 * NOTE: every parameter(address, type and uri) will be compared
189 *
190 * @return
191 *     pointer to the found mirror resource
192 *     NULL - invalid input parameter or mirror resource not found
193 */
194 MirrorResource *findMirrorResourceUsingAddressAndURI(MirrorResourceList *mirrorResourceList,
195         const char *address, OICResourceCoordinatorParamType paramType, const char *uri);
196
197 /**
198 * Find mirror resource list using Address and Hosting Parameter Type
199 *
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
203 *
204 * NOTE: every parameter(address, type and uri) will be compared
205 *
206 * @return
207 *     pointer to the found mirror resource
208 *     NULL - invalid input parameter or mirror resource list not found
209 */
210 MirrorResourceList *findMirrorResourceListUsingAddress(MirrorResourceList *mirrorResourceList,
211         const char *address, OICResourceCoordinatorParamType paramType);
212
213 /**
214 * Copy mirror resource
215 *
216 * @param sourceMirrorResource - pointer to source mirror resource
217 *
218 * @return
219 *     pointer to the copied mirror resource
220 */
221 MirrorResource *cloneMirrorResource(MirrorResource *sourceMirrorResource);
222
223 /**
224 * Eject mirror resource from mirror resource list
225 *
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
228 *
229 * @return
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
233 */
234 OCStackResult ejectMirrorResource(MirrorResourceList *mirrorResourceList,
235                                   MirrorResource *mirrorResource);
236
237 /**
238 * Print mirror resources from mirror resource list
239 *
240 * @param mirrorResourceList - pointer to the mirror resource list that mirror resource will be printed
241 *
242 * @return
243 *     OIC_HOSTING_INVALID_PARAM - mirrorResourceList is null or mirrorResourceList is empty
244 *     OIC_HOSTING_OK - print successfully
245 */
246 OCStackResult printMirrorResourceList(MirrorResourceList *mirrorResourceList);
247
248 #endif