Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
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_SERVICE_API ParameterSet *AllocateParameterSet (const char *name_s, const char *description_s);
111 
112 
120 
121 
131 
132 
144 GRASSROOTS_SERVICE_API bool ReplaceParameterInParameterSet (ParameterSet *params_p, Parameter *old_param_p, Parameter *new_param_p, const bool free_old_param_flag);
145 
146 
163 GRASSROOTS_SERVICE_API json_t *GetParameterSetAsJSON (const ParameterSet * const param_set_p, const SchemaVersion * const sv_p, const bool full_definition_flag);
164 
165 
166 
167 
189 GRASSROOTS_SERVICE_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));
190 
191 
206 GRASSROOTS_SERVICE_API ParameterSet *CreateParameterSetFromJSON (const json_t * const json_p, struct Service *service_p, const bool concise_flag);
207 
208 
218 GRASSROOTS_SERVICE_API Parameter *GetParameterFromParameterSetByName (const ParameterSet * const params_p, const char * const name_s);
219 
220 
230 GRASSROOTS_SERVICE_API ParameterNode *GetParameterNodeFromParameterSetByName (const ParameterSet * const params_p, const char * const name_s);
231 
232 
233 
244 
245 
254 
255 
256 
267 GRASSROOTS_SERVICE_API Parameter *DetachParameterByName (ParameterSet *params_p, const char * const name_s);
268 
269 
270 
281 
282 
292 GRASSROOTS_SERVICE_API struct ParameterGroup *GetParameterGroupFromParameterSetByGroupName (const ParameterSet * const params_p, const char * const name_s);
293 
294 
305 
306 
307 GRASSROOTS_SERVICE_API uint32 GetParameterSetSize (const ParameterSet * const param_set_p);
308 
309 
310 #ifdef __cplusplus
311 }
312 #endif
313 
314 
315 
316 #endif /* #ifndef PARAMETER_SET_H */
317 
Parameter
The datatype that stores all of the information about a Parameter.
Definition: parameter.h:121
ParameterGroup
A datatype to tell the system that certain parameters should be grouped together in the client's user...
Definition: parameter_group.h:85
SchemaVersion
This is a datatype to store the versioning details for the Grassroots JSON schema that is being used.
Definition: schema_version.h:44
ParameterSet::GetParameterSetAsJSON
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.
ParameterSetNode::psn_param_set_p
ParameterSet * psn_param_set_p
Pointer to the associated ParameterSet.
Definition: parameter_set.h:93
GetParameterSetSize
uint32 GetParameterSetSize(const ParameterSet *const param_set_p)
GRASSROOTS_SERVICE_API
#define GRASSROOTS_SERVICE_API
Definition: grassroots_service_library.h:49
ParameterSet::GetParameterSetSelectionAsJSON
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.
parameter.h
ParameterSet::ps_params_p
LinkedList * ps_params_p
A LinkedList of ParameterNodes containing the Parameters.
Definition: parameter_set.h:64
ParameterSet::AllocateParameterSet
ParameterSet * AllocateParameterSet(const char *name_s, const char *description_s)
Create a new ParameterSet containing no parameters.
ParameterSet::ps_grouped_params_p
LinkedList * ps_grouped_params_p
A LinkedList of ParameterGroupNodes for this ParameterSet.
Definition: parameter_set.h:70
ParameterSet::AddParameterGroupToParameterSet
bool AddParameterGroupToParameterSet(ParameterSet *param_set_p, ParameterGroup *group_p)
Add a ParameterGroup to a ParameterSet.
ParameterSetNode::AllocateParameterSetNode
ParameterSetNode * AllocateParameterSetNode(ParameterSet *params_p)
Allocate a new ParameterSetNode to point to the given ParameterSet.
ParameterSet::AddParameterToParameterSet
bool AddParameterToParameterSet(ParameterSet *params_p, Parameter *param_p)
Add a Parameter to a ParameterSet.
Service
A datatype which defines an available service, its capabilities and its parameters.
Definition: service.h:153
ParameterSet::DetachParameterByName
Parameter * DetachParameterByName(ParameterSet *params_p, const char *const name_s)
Remove the Parameter with a given name from a ParameterSet.
ParameterLevel
ParameterLevel
The ParameterLevel defines the level that a user should be to adjust the Parameter.
Definition: parameter.h:52
ParameterSet::GetParameterGroupFromParameterSetByGroupName
struct ParameterGroup * GetParameterGroupFromParameterSetByGroupName(const ParameterSet *const params_p, const char *const name_s)
Get all of the Parameters within a given ParameterGroup.
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
ParameterSet::ps_current_level
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
ParameterSetNode::FreeParameterSetNode
void FreeParameterSetNode(ListItem *node_p)
Free a ParameterSetNode and its associated ParameterSet.
ParameterSet::GetParameterFromParameterSetByName
Parameter * GetParameterFromParameterSetByName(const ParameterSet *const params_p, const char *const name_s)
Get the Parameter with a given name from a ParameterSet.
ParameterSetNode::psn_node
ListItem psn_node
The base list node.
Definition: parameter_set.h:90
ParameterSet::DetachParameter
bool DetachParameter(ParameterSet *params_p, Parameter *param_p)
Remove the Parameter with from a ParameterSet.
ParameterSet::ps_description_s
const char * ps_description_s
An optional description for the ParameterSet.
Definition: parameter_set.h:58
linked_list.h
A doubly-linked list.
ParameterSetNode
A datatype for storing a ParameterSet on a LinkedList.
Definition: parameter_set.h:87
ParameterSet::FreeParameterSet
void FreeParameterSet(ParameterSet *params_p)
Free a ParameterSet and all of its Parameters.
ParameterNode
A datatype for storing Parameters in a LinkedList.
Definition: parameter.h:219
ParameterSet::ps_name_s
const char * ps_name_s
An optional name for the ParameterSet.
Definition: parameter_set.h:52
ServiceData
A datatype for holding the configuration data for a Service.
Definition: service.h:126
ParameterSet::GetParameterNodeFromParameterSetByName
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.
ParameterSet
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46
parameter_group.h
ParameterSet::CreateParameterSetFromJSON
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.
json_util.h
ParameterSet::ReplaceParameterInParameterSet
bool ReplaceParameterInParameterSet(ParameterSet *params_p, Parameter *old_param_p, Parameter *new_param_p, const bool free_old_param_flag)
Replace a Parameter in a ParameterSet.
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43