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.
|
A set of Parameters along with an optional name and description. More...
#include <parameter_set.h>
Public Member Functions | |
Parameter * | EasyCreateAndAddDoubleParameterToParameterSet (const struct ServiceData *service_data_p, ParameterSet *params_p, ParameterGroup *group_p, const ParameterType pt, const char *const name_s, const char *const display_name_s, const char *const description_s, const double64 *default_value_p, uint8 level) |
Allocate a new Parameter and add it to a ParameterSet. More... | |
Parameter * | CreateAndAddDoubleParameterToParameterSet (const struct ServiceData *service_data_p, ParameterSet *params_p, ParameterGroup *group_p, const ParameterType pt, const char *const name_s, const char *const display_name_s, const char *const description_s, const double64 *default_value_p, const double64 *current_value_p, uint8 level) |
Allocate a new Parameter and add it to a ParameterSet. More... | |
ParameterSet * | AllocateParameterSet (const char *name_s, const char *description_s) |
Create a new ParameterSet containing no parameters. More... | |
void | FreeParameterSet (ParameterSet *params_p) |
Free a ParameterSet and all of its Parameters. More... | |
bool | AddParameterToParameterSet (ParameterSet *params_p, Parameter *param_p) |
Add a Parameter to a ParameterSet. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
Parameter * | GetParameterFromParameterSetByName (const ParameterSet *const params_p, const char *const name_s) |
Get the Parameter with a given name from a ParameterSet. More... | |
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. More... | |
Parameter * | DetachParameterByName (ParameterSet *params_p, const char *const name_s) |
Remove the Parameter with a given name from a ParameterSet. More... | |
bool | DetachParameter (ParameterSet *params_p, Parameter *param_p) |
Remove the Parameter with from a ParameterSet. More... | |
struct ParameterGroup * | GetParameterGroupFromParameterSetByGroupName (const ParameterSet *const params_p, const char *const name_s) |
Get all of the Parameters within a given ParameterGroup. More... | |
bool | AddParameterGroupToParameterSet (ParameterSet *param_set_p, ParameterGroup *group_p) |
Add a ParameterGroup to a ParameterSet. More... | |
bool | GetCurrentStringParameterValueFromParameterSet (const ParameterSet *const params_p, const char *const name_s, const char **value_pp) |
Get the value of a StringParameter within a ParameterSet. More... | |
Data Fields | |
const char * | ps_name_s |
An optional name for the ParameterSet. More... | |
const char * | ps_description_s |
An optional description for the ParameterSet. More... | |
LinkedList * | ps_params_p |
A LinkedList of ParameterNodes containing the Parameters. More... | |
LinkedList * | ps_grouped_params_p |
A LinkedList of ParameterGroupNodes for this ParameterSet. More... | |
ParameterLevel | ps_current_level |
This is used when responding to parameters sent by another Grassroots Server or Client if there are two different run routines depending upon the simple or advanced parameters being set. More... | |
A set of Parameters along with an optional name and description.
Parameter * EasyCreateAndAddDoubleParameterToParameterSet | ( | const struct ServiceData * | service_data_p, |
ParameterSet * | params_p, | ||
ParameterGroup * | group_p, | ||
const ParameterType | pt, | ||
const char *const | name_s, | ||
const char *const | display_name_s, | ||
const char *const | description_s, | ||
const double64 * | default_value_p, | ||
uint8 | level | ||
) |
Allocate a new Parameter and add it to a ParameterSet.
service_data_p | The ServiceData for the Service that is allocating this Parameter. |
params_p | The ParameterSet to add the new Parameter to. |
group_p | The ParameterGroup to add this Parameter to. This can be NULL in which case the Parameter will not be placed within any ParameterGroup. |
type | The ParameterType for this Parameter. |
name_s | The name of the Parameter. The Parameter will store a copy of this string so this value does not need to remain in scope. |
display_name_s | An optional name to display for the Parameter for use in Clients. The Parameter will store a copy of this string so this value does not need to remain in scope. This can be NULL . |
description_s | The description of the Parameter. The Parameter will store a copy of this string so this value does not need to remain in scope. |
default_value-p | The default value for this Parameter. |
level | The ParameterLevel for this Parameter. This determines when the Client should display this Parameter to the user. |
NULL
upon error. Parameter * CreateAndAddDoubleParameterToParameterSet | ( | const struct ServiceData * | service_data_p, |
ParameterSet * | params_p, | ||
ParameterGroup * | group_p, | ||
const ParameterType | pt, | ||
const char *const | name_s, | ||
const char *const | display_name_s, | ||
const char *const | description_s, | ||
const double64 * | default_value_p, | ||
const double64 * | current_value_p, | ||
uint8 | level | ||
) |
Allocate a new Parameter and add it to a ParameterSet.
service_data_p | The ServiceData for the Service that is allocating this Parameter. |
params_p | The ParameterSet to add the new Parameter to. |
group_p | The ParameterGroup to add this Parameter to. This can be NULL in which case the Parameter will not be placed within any ParameterGroup. |
type | The ParameterType for this Parameter. |
name_s | The name of the Parameter. The Parameter will store a copy of this string so this value does not need to remain in scope. |
display_name_s | An optional name to display for the Parameter for use in Clients. The Parameter will store a copy of this string so this value does not need to remain in scope. This can be NULL . |
description_s | The description of the Parameter. The Parameter will store a copy of this string so this value does not need to remain in scope. |
options_p | The options specifying the possible values that this Parameter can take. If NULL then it can take any valid values for its given ParameterType. |
default_value | The default value for this Parameter. |
current_value_p | If this is not NULL , then copy this value as the current value of the Parameter. If this is NULL , then current value for this Parameter will be set to be a copy of its default value. |
level | The ParameterLevel for this Parameter. This determines when the Client should display this Parameter to the user. |
NULL
upon error. ParameterSet * AllocateParameterSet | ( | const char * | name_s, |
const char * | description_s | ||
) |
Create a new ParameterSet containing no parameters.
name_s | The name to use for the ParameterSet. |
description_s | The description to use for the ParameterSet. |
NULL
upon error. void FreeParameterSet | ( | ParameterSet * | params_p | ) |
Free a ParameterSet and all of its Parameters.
params_p | The ParameterSet to free. |
bool AddParameterToParameterSet | ( | ParameterSet * | params_p, |
Parameter * | param_p | ||
) |
Add a Parameter to a ParameterSet.
params_p | The ParameterSet to amend. |
param_p | The Parameter to add. |
true
if the Parameter was added successfully, false
otherwise. 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.
params_p | The ParameterSet to amend. |
old_param_p | The Parameter to remove. |
new_param_p | The Parameter to add to the ParameterSet. |
free_old_param_flag | If this is true then old_param_p will be freed if this function is successful. Set this to false to leave old_param_p as valid pointer. |
true
if the Parameter was replaced successfully, false
otherwise. 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.
This uses the Swagger definitions as much as possible.
param_set_p | The ParameterSet to generate the description for. |
sv_p | If you wish to create a JSON fragment for a different version of the Grassroots system, then you can set this value to the version that you require. If this is NULL , then the current version of the running Grassroots system will be used. |
full_definition_flag | If this is true then all of the details for each of the Parameters will get added. If this is false then just the name and current value of each Parameter will get added. This is useful is you just want to send the values to use when running a service. |
NULL
if there was an error. json_t * GetParameterSetSelectionAsJSON | ( | const ParameterSet *const | param_set_p, |
const SchemaVersion *const | sv_p, | ||
const bool | full_definition_flag, | ||
void * | data_p, | ||
bool(*)(const Parameter *param_p, void *data_p) | add_param_fn | ||
) |
Generate a json-based description of a selection of ParameterSet.
param_set_p | The ParameterSet to generate the description for. |
sv_p | If you wish to create a JSON fragment for a different version of the Grassroots system, then you can set this value to the version that you require. If this is NULL , then the current version of the running Grassroots system will be used. |
full_definition_flag | If this is true then all of the details for each of the Parameters will get added. If this is false then just the name and current value of each Parameter will get added. This is useful is you just want to send the values to use when running a service. |
data_p | If some custom data is needed by add_param_fn, then this can be used. It will be passed to each call of add_param_fn. |
add_param_fn | A callback function that determines whether a Parameter should be added to the generated JSON. This will be called for each Parameter in the ParameterSet along with data_p and if returns true then the Parameter's JSON will get added. If it returns false , then the Parameter will be skipped. |
NULL
if there was an error. 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.
This uses the Swagger definitions as much as possible.
json_p | The json-based representation of the ParameterSet. |
concise_flag | If this is true , then any Parameters within this ParameterSet will just have the values that are needed to run the Service are added. If this is false then user-facing attributes such as description, parameter level, group, etc. will be added. |
NULL
if there was an error.Parameter * GetParameterFromParameterSetByName | ( | const ParameterSet *const | params_p, |
const char *const | name_s | ||
) |
Get the Parameter with a given name from a ParameterSet.
params_p | The ParameterSet to search. |
name_s | The Parameter name to try and match. |
NULL
if it could not be found 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.
params_p | The ParameterSet to search. |
name_s | The Parameter name to try and match. |
NULL
if it could not be found Parameter * DetachParameterByName | ( | ParameterSet * | params_p, |
const char *const | name_s | ||
) |
Remove the Parameter with a given name from a ParameterSet.
params_p | The ParameterSet to search. |
name_s | The name of the Parameter to try and match. |
NULL
will be returned. be found. bool DetachParameter | ( | ParameterSet * | params_p, |
Parameter * | param_p | ||
) |
Remove the Parameter with from a ParameterSet.
params_p | The ParameterSet to search. |
param_p | The Parameter to try and deatch. |
true
if the Parameter was found and removed from the ParameterSet, false
otherwise. struct ParameterGroup * GetParameterGroupFromParameterSetByGroupName | ( | const ParameterSet *const | params_p, |
const char *const | name_s | ||
) |
Get all of the Parameters within a given ParameterGroup.
params_p | The ParameterSet to search. |
name_s | The name of the ParameterGroup to get the Parameters for. |
NULL
. Upon failure a NULL
is returned. bool AddParameterGroupToParameterSet | ( | ParameterSet * | param_set_p, |
ParameterGroup * | group_p | ||
) |
Add a ParameterGroup to a ParameterSet.
param_set_p | The ParameterSet to add the ParameterGroup to. |
group_p | The ParameterGroup to add. |
true
if the ParameterGroup was added successfully, false
otherwise. bool GetCurrentStringParameterValueFromParameterSet | ( | const ParameterSet *const | params_p, |
const char *const | name_s, | ||
const char ** | value_pp | ||
) |
Get the value of a StringParameter within a ParameterSet.
params_p | The ParameterSet to get the Parameter from. |
name_s | The Parameter name to try and match. |
value_pp | Where the StringParameter value will be stored upon success. |
true
if the Parameter value was retrieved successfully, false
otherwise. const char* ps_name_s |
An optional name for the ParameterSet.
This can be NULL.
const char* ps_description_s |
An optional description for the ParameterSet.
This can be NULL.
LinkedList* ps_params_p |
A LinkedList of ParameterNodes containing the Parameters.
LinkedList* ps_grouped_params_p |
A LinkedList of ParameterGroupNodes for this ParameterSet.
ParameterLevel ps_current_level |
This is used when responding to parameters sent by another Grassroots Server or Client if there are two different run routines depending upon the simple or advanced parameters being set.