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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This file contains the definition, types and interfaces for resource and attributes
32 #include "ocstackconfig.h"
33 #include "occlientcb.h"
35 /** Macro Definitions for observers */
37 /** Observer not interested. */
38 #define OC_OBSERVER_NOT_INTERESTED (0)
40 /** Observer still interested. */
41 #define OC_OBSERVER_STILL_INTERESTED (1)
43 /** Failed communication. */
44 #define OC_OBSERVER_FAILED_COMM (2)
47 *Virtual Resource Presence Attributes
51 typedef struct PRESENCERESOURCE{
52 OCResourceHandle handle;
58 * Forward declarations
64 * following structure will be created in occollection.
67 typedef struct occapability {
68 /** Linked list; for multiple capabilities.*/
69 struct occapability* next;
71 /** It is a name about resource capability. */
74 /** It is mean status of capability. */
79 * following structure will be created in occollection.
82 typedef struct ocaction {
83 /** linked list; for multiple actions. */
84 struct ocaction *next;
86 /** Target Uri. It will be used to execute the action. */
89 /** head pointer of a linked list of capability nodes.*/
94 * following structure will be created in occollection.
97 typedef struct ocactionset
99 /** linked list; for list of action set. */
100 struct ocactionset *next;
102 /** Name of the action set.*/
108 /** Type of action.*/
111 /** head pointer of a linked list of Actions.*/
116 * Data structure for holding name and data types for each OIC resource.
118 typedef struct resourcetype_t {
120 /** linked list; for multiple types on resource. */
121 struct resourcetype_t *next;
124 * Name of the type; this string is ‘.’ (dot) separate list of segments where each segment is a
125 * namespace and the final segment is the type; type and sub-types can be separate with
126 * ‘-‘ (dash) usually only two segments would be defined. Either way this string is meant to be
127 * human friendly and is used opaquely and not parsed by code. This name is used in the “rt=”
128 * parameter of a resource description when resources are introspected and is also use in the
129 * " <base URI>/types " list of available types.
131 char *resourcetypename;
135 * Data structure for data type and definition for attributes that the resource exposes.
137 typedef struct attr_t {
139 /** Points to next resource in list.*/
142 /** The name of the attribute; used to look up the attribute in list.
143 * for a given attribute SHOULD not be changed once assigned.
147 /** value of the attribute as void. To support both string and @OCStringLL value*/
152 * Data structure for holding a resource interface
154 typedef struct resourceinterface_t {
156 /** linked list; for multiple interfaces on resource.*/
157 struct resourceinterface_t *next;
159 /** Name of the interface; this is ‘.’ (dot) separate list of segments where each segment is a
160 * namespace and the final segment is the interface; usually only two segments would be
161 * defined. Either way this string is opaque and not parsed by segment.*/
164 /** Supported content types to serialize request and response on this interface
165 * (REMOVE for V1 – only jSON for all but core.ll that uses Link Format)*/
167 char *inputContentType ;
168 char *outputContentType ;
170 /** Future placeholder for access control and policy.*/
171 } OCResourceInterface;
174 * Data structure for holding child resources associated with a collection
176 typedef struct OCChildResource {
177 struct OCResource *rsrcResource;
178 struct OCChildResource *next;
182 * Data structure for holding data type and definition for OIC resource.
184 typedef struct OCResource {
186 /** Points to next resource in list.*/
187 struct OCResource *next;
189 /** Relative path on the device; will be combined with base url to create fully qualified path.*/
192 /** Resource type(s); linked list.*/
193 OCResourceType *rsrcType;
195 /** Resource interface(s); linked list.*/
196 OCResourceInterface *rsrcInterface;
198 /** Resource interface(s); linked list.*/
199 OCAttribute *rsrcAttributes;
201 /** Array of pointers to resources; can be used to represent a container of resources.
202 * (i.e. hierarchies of resources) or for reference resources (i.e. for a resource collection).*/
204 /** Child resource(s); linked list.*/
205 OCChildResource *rsrcChildResourcesHead;
207 /** Pointer to function that handles the entity bound to the resource.
208 * This handler has to be explicitly defined by the programmer.*/
209 OCEntityHandler entityHandler;
211 /** Callback parameter.*/
212 void * entityHandlerCallbackParam;
214 /** Properties on the resource – defines meta information on the resource.
215 * (ACTIVE, DISCOVERABLE etc ). */
217 OCResourceProperty resourceProperties ;
219 /* @note: Methods supported by this resource should be based on the interface targeted
220 * i.e. look into the interface structure based on the query request Can be removed here;
221 * place holder for the note above.*/
222 /* method_t methods; */
225 /** Sequence number for observable resources. Per the CoAP standard it is a 24 bit value.*/
226 uint32_t sequenceNum;
228 /** Pointer of ActionSet which to support group action.*/
229 OCActionSet *actionsetHead;
231 /** The instance identifier for this web link in an array of web links - used in links. */
234 /** An ordinal number that is not repeated - must be unique in the collection context. */
236 /** Any unique string including a URI. */
238 /** Use UUID for universal uniqueness - used in /oic/res to identify the device. */
239 OCIdentity uniqueUUID;
245 #endif /* OCRESOURCE_H_ */