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 * Typedefs for stack interface
65 * IF here stands for Interface
77 * following structure will be created in occollection.
80 typedef struct occapability {
81 /** Linked list; for multiple capabilities.*/
82 struct occapability* next;
84 /** It is a name about resource capability. */
87 /** It is mean status of capability. */
92 * following structure will be created in occollection.
95 typedef struct ocaction {
96 /** linked list; for multiple actions. */
97 struct ocaction *next;
99 /** Target Uri. It will be used to execute the action. */
102 /** head pointer of a linked list of capability nodes.*/
107 * following structure will be created in occollection.
110 typedef struct ocactionset
112 /** linked list; for list of action set. */
113 struct ocactionset *next;
115 /** Name of the action set.*/
121 /** Type of action.*/
124 /** head pointer of a linked list of Actions.*/
129 * Data structure for holding name and data types for each OIC resource.
131 typedef struct resourcetype_t {
133 /** linked list; for multiple types on resource. */
134 struct resourcetype_t *next;
137 * Name of the type; this string is ‘.’ (dot) separate list of segments where each segment is a
138 * namespace and the final segment is the type; type and sub-types can be separate with
139 * ‘-‘ (dash) usually only two segments would be defined. Either way this string is meant to be
140 * human friendly and is used opaquely and not parsed by code. This name is used in the “rt=”
141 * parameter of a resource description when resources are introspected and is also use in the
142 * " <base URI>/types " list of available types.
144 char *resourcetypename;
148 * Data structure for data type and definition for attributes that the resource exposes.
150 typedef struct attr_t {
152 /** Points to next resource in list.*/
155 /** The name of the attribute; used to look up the attribute in list.
156 * for a given attribute SHOULD not be changed once assigned.
158 const char *attrName;
160 /** value of the attribute as string.*/
165 * Data structure for holding a resource interface
167 typedef struct resourceinterface_t {
169 /** linked list; for multiple interfaces on resource.*/
170 struct resourceinterface_t *next;
172 /** Name of the interface; this is ‘.’ (dot) separate list of segments where each segment is a
173 * namespace and the final segment is the interface; usually only two segments would be
174 * defined. Either way this string is opaque and not parsed by segment.*/
177 /** Supported content types to serialize request and response on this interface
178 * (REMOVE for V1 – only jSON for all but core.ll that uses Link Format)*/
180 char *inputContentType ;
181 char *outputContentType ;
183 /** Future placeholder for access control and policy.*/
184 } OCResourceInterface;
187 * Data structure for holding child resources associated with a collection
189 typedef struct OCChildResource {
190 struct OCResource *rsrcResource;
191 struct OCChildResource *next;
195 * Data structure for holding data type and definition for OIC resource.
197 typedef struct OCResource {
199 /** Points to next resource in list.*/
200 struct OCResource *next;
202 /** Relative path on the device; will be combined with base url to create fully qualified path.*/
205 /** Resource type(s); linked list.*/
206 OCResourceType *rsrcType;
208 /** Resource interface(s); linked list.*/
209 OCResourceInterface *rsrcInterface;
211 /** Resource interface(s); linked list.*/
212 OCAttribute *rsrcAttributes;
214 /** Array of pointers to resources; can be used to represent a container of resources.
215 * (i.e. hierarchies of resources) or for reference resources (i.e. for a resource collection).*/
217 /** Child resource(s); linked list.*/
218 OCChildResource *rsrcChildResourcesHead;
220 /** Pointer to function that handles the entity bound to the resource.
221 * This handler has to be explicitly defined by the programmer.*/
222 OCEntityHandler entityHandler;
224 /** Callback parameter.*/
225 void * entityHandlerCallbackParam;
227 /** Properties on the resource – defines meta information on the resource.
228 * (ACTIVE, DISCOVERABLE etc ). */
230 OCResourceProperty resourceProperties ;
232 /* @note: Methods supported by this resource should be based on the interface targeted
233 * i.e. look into the interface structure based on the query request Can be removed here;
234 * place holder for the note above.*/
235 /* method_t methods; */
238 /** Sequence number for observable resources. Per the CoAP standard it is a 24 bit value.*/
239 uint32_t sequenceNum;
241 /** Pointer of ActionSet which to support group action.*/
242 OCActionSet *actionsetHead;
247 #endif /* OCRESOURCE_H_ */