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_group.h
Go to the documentation of this file.
1 /*
2 ** 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 
22 /*
23  * parameter_group.h
24  *
25  * Created on: 9 Feb 2016
26  * Author: billy
27  */
28 
29 #ifndef PARAMETERS_INCLUDE_PARAMETER_GROUP_H_
30 #define PARAMETERS_INCLUDE_PARAMETER_GROUP_H_
31 
32 #include "jansson.h"
33 #include "linked_list.h"
34 
35 #include "parameter.h"
36 
37 
38 
39 /*
40  * The following preprocessor macros allow us to declare
41  * and define the variables in the same place. By default,
42  * they will expand to
43  *
44  * extern const char *SERVICE_NAME_S;
45  *
46  * however if ALLOCATE_JSON_TAGS is defined then it will
47  * become
48  *
49  * const char *SERVICE_NAME_S = "path";
50  *
51  * ALLOCATE_JSON_TAGS must be defined only once prior to
52  * including this header file. Currently this happens in
53  * json_util.c.
54  */
55 
56 #ifndef DOXYGEN_SHOULD_SKIP_THIS
57 
58 #ifdef ALLOCATE_PARAMETER_GROUP_TAGS_H
59  #define PARAMETER_GROUP_PREFIX GRASSROOTS_SERVICE_API
60  #define PARAMETER_GROUP_VAL(x) = x
61 #else
62  #define PARAMETER_GROUP_PREFIX GRASSROOTS_SERVICE_API
63  #define PARAMETER_GROUP_VAL(x)
64 #endif
65 
66 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
67 
68 
69 /*
70 PARAMETER_GROUP_PREFIX const char *PARAM_GROUP_DELIMITER_S PARAMETER_GROUP_VAL("/");
71 */
72 
73 /* forward declaration */
74 struct ServiceData;
75 struct ParameterGroup;
76 struct ParameterSet;
77 
85 typedef struct ParameterGroup
86 {
88  char *pg_name_s;
89 
92 
93 
99 
100 
106 
107 
113 
114 
121 
127 
128 
133 
134 
140 
141 
146 
148 
149 
150 
157 typedef struct ParameterGroupNode
158 {
161 
165 
166 
167 
168 
169 #ifdef __cplusplus
170 extern "C"
171 {
172 #endif
173 
174 
184 
185 
186 
187 
197 
198 
210 GRASSROOTS_SERVICE_API ParameterGroup *AllocateParameterGroup (const char *name_s, const bool repeatable_flag, const struct ServiceData *service_data_p);
211 
212 
220 
221 
230 GRASSROOTS_SERVICE_API bool AddParameterGroupAsJSON (ParameterGroup *param_group_p, json_t *groups_array_p, const SchemaVersion * const sv_p);
231 
232 
240 GRASSROOTS_SERVICE_API json_t *GetParameterGroupAsJSON (const ParameterGroup *param_group_p, const bool include_params_flag, const bool full_definition_flag, const SchemaVersion * const sv_p);
241 
242 
251 GRASSROOTS_SERVICE_API bool AddParameterGroupChild (ParameterGroup *parent_group_p, ParameterGroup *child_group_p);
252 
253 
267 GRASSROOTS_SERVICE_API ParameterGroup *CreateAndAddParameterGroupChild (ParameterGroup *parent_group_p, const char *name_s, const bool repeatable_flag, const bool add_params_flag);
268 
269 
279 
280 
289 GRASSROOTS_SERVICE_API bool CloneParameters (const ParameterGroup * const src_group_p, ParameterGroup *dest_group_p);
290 
291 
301 
302 
314 GRASSROOTS_SERVICE_API ParameterGroup *CreateAndAddParameterGroupToParameterSet (const char *name_s, const bool repeatable_flag, const struct ServiceData *service_data_p, struct ParameterSet *param_set_p);
315 
316 
326 GRASSROOTS_SERVICE_API ParameterNode *GetParameterNodeFromParameterGroupByName (const ParameterGroup * const group_p, const char * const name_s);
327 
328 
338 GRASSROOTS_SERVICE_API Parameter *GetParameterFromParameterGroupByName (const ParameterGroup * const group_p, const char * const name_s);
339 
340 
349 
350 
361 
362 
363 
373 
374 
375 
386 
387 
388 #ifdef __cplusplus
389 }
390 #endif
391 
392 
393 #endif /* PARAMETERS_INCLUDE_PARAMETER_GROUP_H_ */
Parameter
The datatype that stores all of the information about a Parameter.
Definition: parameter.h:121
ParameterGroup::pg_child_groups_p
LinkedList * pg_child_groups_p
A list of ParmameterGroupNodes for any child parameter groups.
Definition: parameter_group.h:139
ParameterGroup
A datatype to tell the system that certain parameters should be grouped together in the client's user...
Definition: parameter_group.h:85
ParameterGroup::GetParameterGroupAsJSON
json_t * GetParameterGroupAsJSON(const ParameterGroup *param_group_p, const bool include_params_flag, const bool full_definition_flag, const SchemaVersion *const sv_p)
Get the JSON fragment detailing a given ParameterGroup.
SchemaVersion
This is a datatype to store the versioning details for the Grassroots JSON schema that is being used.
Definition: schema_version.h:44
ParameterGroup::AddParameterToParameterGroup
bool AddParameterToParameterGroup(ParameterGroup *parent_group_p, Parameter *param_p)
Add a Parameter to a ParameterGroup.
ParameterGroupNode::FreeParameterGroupNode
void FreeParameterGroupNode(ListItem *node_p)
Free a given ParameterGroupNode.
ParameterGroup::CreateAndAddParameterGroupChild
ParameterGroup * CreateAndAddParameterGroupChild(ParameterGroup *parent_group_p, const char *name_s, const bool repeatable_flag, const bool add_params_flag)
Create and add a ParameterGroup as a child to another ParameterGroup.
ParameterGroup::FreeParameterGroup
void FreeParameterGroup(ParameterGroup *param_group_p)
Free a given ParameterGroup.
ParameterGroup::pg_full_display_flag
bool pg_full_display_flag
Should this ParameterGroup have a full display e.g.
Definition: parameter_group.h:98
ParameterGroup::ReplaceParameterInParameterGroup
bool ReplaceParameterInParameterGroup(ParameterGroup *params_p, Parameter *old_param_p, Parameter *new_param_p)
Replace a Parameter in a ParameterGroup.
GRASSROOTS_SERVICE_API
#define GRASSROOTS_SERVICE_API
Definition: grassroots_service_library.h:49
parameter.h
ParameterGroup::AddRepeatableParameterGroupLabelParam
bool AddRepeatableParameterGroupLabelParam(ParameterGroup *group_p, Parameter *param_p)
Add a Parameter to those used for labelling entries in a repeated ParameterGroup.
ParameterGroup::GetParameterNodeFromParameterGroupByName
ParameterNode * GetParameterNodeFromParameterGroupByName(const ParameterGroup *const group_p, const char *const name_s)
Get the ParameterNode for a Parameter with a given name from a ParameterGroup.
ParameterGroup::pg_repeatable_label_params_p
LinkedList * pg_repeatable_label_params_p
If the ParameterGroup is repeatable, use these named parameters as the label in the list of the param...
Definition: parameter_group.h:120
ParameterGroup::pg_service_data_p
const struct ServiceData * pg_service_data_p
The ServiceData for the Service that has created this ParametetrGroup.
Definition: parameter_group.h:145
ParameterGroup::AllocateParameterGroup
ParameterGroup * AllocateParameterGroup(const char *name_s, const bool repeatable_flag, const struct ServiceData *service_data_p)
Allocate a ParameterGroup.
ParameterGroupNode::AllocateParameterGroupNode
ParameterGroupNode * AllocateParameterGroupNode(ParameterGroup *group_p)
Allocate a ParameterGroupNode that will take ownership of a given ParameterGroup.
ParameterGroup::pg_repeatable_flag
bool pg_repeatable_flag
Can the parameters in this group be repeated, analogous to a row in a table, false if not.
Definition: parameter_group.h:112
ParameterGroup::pg_params_p
LinkedList * pg_params_p
A list of ParameterNodes for the parameters in this group.
Definition: parameter_group.h:132
ParameterGroupNode::pgn_param_group_p
ParameterGroup * pgn_param_group_p
Pointer to the associated ParameterGroup.
Definition: parameter_group.h:163
ParameterGroup::pg_visible_flag
bool pg_visible_flag
Should this ParameterGroup initially be visible?
Definition: parameter_group.h:91
ParameterGroup::CloneParameters
bool CloneParameters(const ParameterGroup *const src_group_p, ParameterGroup *dest_group_p)
Clone all of the Parameters from one ParameterGroup to another.
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
ParameterGroup::pg_name_s
char * pg_name_s
The name of the ParameterGroup.
Definition: parameter_group.h:88
ParameterGroupNode
A datatype for storing a ParameterGroup on a LinkedList.
Definition: parameter_group.h:157
linked_list.h
A doubly-linked list.
ParameterGroup::pg_current_repeatable_group_index
uint32 pg_current_repeatable_group_index
If the parameters can be repeated, this is the current index e.g.
Definition: parameter_group.h:126
ParameterNode
A datatype for storing Parameters in a LinkedList.
Definition: parameter.h:219
ParameterGroup::CreateAndAddParameterGroupToParameterSet
ParameterGroup * CreateAndAddParameterGroupToParameterSet(const char *name_s, const bool repeatable_flag, const struct ServiceData *service_data_p, struct ParameterSet *param_set_p)
Create a ParameterGroup and add it to a given ParameterSet.
ServiceData
A datatype for holding the configuration data for a Service.
Definition: service.h:126
ParameterGroup::GetParameterFromParameterGroupByName
Parameter * GetParameterFromParameterGroupByName(const ParameterGroup *const group_p, const char *const name_s)
Get the Parameter with a given name from a ParameterGroup.
ParameterGroup::AddParameterGroupAsJSON
bool AddParameterGroupAsJSON(ParameterGroup *param_group_p, json_t *groups_array_p, const SchemaVersion *const sv_p)
Add the JSON fragment detailing a given ParameterGroup to a given JSON array.
ParameterSet
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46
ParameterGroup::GetRepeatableParameterGroupName
char * GetRepeatableParameterGroupName(ParameterGroup *const group_p)
Get the name to use for a child of a repeatable ParameterGroup.
ParameterGroup::RemoveParameterGroupChild
bool RemoveParameterGroupChild(ParameterGroup *parent_group_p, ParameterGroup *child_group_p)
Remove a ParameterGroup child from another ParameterGroup.
ParameterGroup::pg_vertical_layout_flag
bool pg_vertical_layout_flag
Should the ParameterGroup layout its child parameters horizontally or vertically?
Definition: parameter_group.h:105
ParameterGroup::AddParameterGroupChild
bool AddParameterGroupChild(ParameterGroup *parent_group_p, ParameterGroup *child_group_p)
Add a ParameterGroup as a child to another ParameterGroup.
ParameterGroupNode::pgn_node
ListItem pgn_node
The base list node.
Definition: parameter_group.h:160
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43
ParameterGroup::GetRepeatableParameterGroupRegularExpression
char * GetRepeatableParameterGroupRegularExpression(const ParameterGroup *const group_p)
Get the string to use for matching ParameterGroups as children of a repeatable ParameterGroup.