parameter_set.h
Go to the documentation of this file.
1 /*
2 L** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
24 #ifndef PARAMETER_SET_H
25 #define PARAMETER_SET_H
26 
27 #include "jansson.h"
28 
29 #include "linked_list.h"
30 #include "parameter.h"
31 #include "json_util.h"
32 
33 
34 struct ServiceData;
35 struct Service;
36 
37 #include "parameter_group.h"
38 
39 
46 typedef struct ParameterSet
47 {
52  const char *ps_name_s;
53 
58  const char *ps_description_s;
59 
65 
71 
78 } ParameterSet;
79 
80 
87 typedef struct ParameterSetNode
88 {
91 
95 
96 
97 #ifdef __cplusplus
98 extern "C"
99 {
100 #endif
101 
110 GRASSROOTS_PARAMS_API ParameterSet *AllocateParameterSet (const char *name_s, const char *description_s);
111 
112 
119 GRASSROOTS_PARAMS_API void FreeParameterSet (ParameterSet *params_p);
120 
121 
130 GRASSROOTS_PARAMS_API bool AddParameterToParameterSet (ParameterSet *params_p, Parameter *param_p);
131 
132 
133 
134 
151 GRASSROOTS_PARAMS_API json_t *GetParameterSetAsJSON (const ParameterSet * const param_set_p, const SchemaVersion * const sv_p, const bool full_definition_flag);
152 
153 
154 
155 
177 GRASSROOTS_PARAMS_API json_t *GetParameterSetSelectionAsJSON (const ParameterSet * const param_set_p, const SchemaVersion * const sv_p, const bool full_definition_flag, void *data_p, bool (*add_param_fn) (const Parameter *param_p, void *data_p));
178 
179 
194 GRASSROOTS_PARAMS_API ParameterSet *CreateParameterSetFromJSON (const json_t * const json_p, struct Service *service_p, const bool concise_flag);
195 
196 
206 GRASSROOTS_PARAMS_API Parameter *GetParameterFromParameterSetByName (const ParameterSet * const params_p, const char * const name_s);
207 
208 
218 GRASSROOTS_PARAMS_API ParameterNode *GetParameterNodeFromParameterSetByName (const ParameterSet * const params_p, const char * const name_s);
219 
220 
221 
231 GRASSROOTS_PARAMS_API ParameterSetNode *AllocateParameterSetNode (ParameterSet *params_p);
232 
233 
241 GRASSROOTS_PARAMS_API void FreeParameterSetNode (ListItem *node_p);
242 
243 
244 
255 GRASSROOTS_PARAMS_API Parameter *DetachParameterByName (ParameterSet *params_p, const char * const name_s);
256 
257 
258 
268 GRASSROOTS_PARAMS_API bool DetachParameter (ParameterSet *params_p, Parameter *param_p);
269 
270 
280 GRASSROOTS_PARAMS_API struct ParameterGroup *GetParameterGroupFromParameterSetByGroupName (const ParameterSet * const params_p, const char * const name_s);
281 
282 
292 GRASSROOTS_PARAMS_API bool AddParameterGroupToParameterSet (ParameterSet *param_set_p, ParameterGroup *group_p);
293 
294 
295 GRASSROOTS_PARAMS_API uint32 GetParameterSetSize (const ParameterSet * const param_set_p);
296 
297 
298 #ifdef __cplusplus
299 }
300 #endif
301 
302 
303 
304 #endif /* #ifndef PARAMETER_SET_H */
305 
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43
ParameterSet * CreateParameterSetFromJSON(const json_t *const json_p, struct Service *service_p, const bool concise_flag)
Create a new ParameterSet from a json-based description.
void FreeParameterSetNode(ListItem *node_p)
Free a ParameterSetNode and its associated ParameterSet.
ParameterNode * GetParameterNodeFromParameterSetByName(const ParameterSet *const params_p, const char *const name_s)
Get the ParameterNode for a Parameter with a given name from a ParameterSet.
bool AddParameterGroupToParameterSet(ParameterSet *param_set_p, ParameterGroup *group_p)
Add a ParameterGroup to a ParameterSet.
ListItem psn_node
The base list node.
Definition: parameter_set.h:90
json_t * GetParameterSetSelectionAsJSON(const ParameterSet *const param_set_p, const SchemaVersion *const sv_p, const bool full_definition_flag, void *data_p, bool(*add_param_fn)(const Parameter *param_p, void *data_p))
Generate a json-based description of a selection of ParameterSet.
json_t * GetParameterSetAsJSON(const ParameterSet *const param_set_p, const SchemaVersion *const sv_p, const bool full_definition_flag)
Generate a json-based description of a ParameterSet.
void FreeParameterSet(ParameterSet *params_p)
Free a ParameterSet and all of its Parameters.
This is a datatype to store the versioning details for the Grassroots JSON schema that is being used.
Definition: schema_version.h:44
ParameterSet * AllocateParameterSet(const char *name_s, const char *description_s)
Create a new ParameterSet containing no parameters.
const char * ps_name_s
An optional name for the ParameterSet.
Definition: parameter_set.h:52
A doubly-linked list.
A datatype for holding the configuration data for a Service.
Definition: service.h:126
A datatype to tell the system that certain parameters should be grouped together in the client's user...
Definition: parameter_group.h:85
A datatype which defines an available service, its capabilities and its parameters.
Definition: service.h:153
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
LinkedList * ps_params_p
A LinkedList of ParameterNodes containing the Parameters.
Definition: parameter_set.h:64
Parameter * DetachParameterByName(ParameterSet *params_p, const char *const name_s)
Remove the Parameter with a given name from a ParameterSet.
struct ParameterGroup * GetParameterGroupFromParameterSetByGroupName(const ParameterSet *const params_p, const char *const name_s)
Get all of the Parameters within a given ParameterGroup.
ParameterLevel
The ParameterLevel defines the level that a user should be to adjust the Parameter.
Definition: parameter.h:52
ParameterLevel ps_current_level
This is used when responding to parameters sent by another Grassroots Server or Client if there are t...
Definition: parameter_set.h:77
The datatype that stores all of the information about a Parameter.
Definition: parameter.h:121
Parameter * GetParameterFromParameterSetByName(const ParameterSet *const params_p, const char *const name_s)
Get the Parameter with a given name from a ParameterSet.
bool AddParameterToParameterSet(ParameterSet *params_p, Parameter *param_p)
Add a Parameter to a ParameterSet.
A datatype for storing Parameters in a LinkedList.
Definition: parameter.h:219
const char * ps_description_s
An optional description for the ParameterSet.
Definition: parameter_set.h:58
bool DetachParameter(ParameterSet *params_p, Parameter *param_p)
Remove the Parameter with from a ParameterSet.
ParameterSet * psn_param_set_p
Pointer to the associated ParameterSet.
Definition: parameter_set.h:93
ParameterSetNode * AllocateParameterSetNode(ParameterSet *params_p)
Allocate a new ParameterSetNode to point to the given ParameterSet.
LinkedList * ps_grouped_params_p
A LinkedList of ParameterGroupNodes for this ParameterSet.
Definition: parameter_set.h:70
A datatype for storing a ParameterSet on a LinkedList.
Definition: parameter_set.h:87
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46