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.
ParameterSet Struct Reference

A set of Parameters along with an optional name and description. More...

#include <parameter_set.h>

Collaboration diagram for ParameterSet:
[legend]

Public Member Functions

ParameterEasyCreateAndAddDoubleParameterToParameterSet (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...
 
ParameterCreateAndAddDoubleParameterToParameterSet (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...
 
ParameterSetAllocateParameterSet (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...
 
ParameterSetCreateParameterSetFromJSON (const json_t *const json_p, struct Service *service_p, const bool concise_flag)
 Create a new ParameterSet from a json-based description. More...
 
ParameterGetParameterFromParameterSetByName (const ParameterSet *const params_p, const char *const name_s)
 Get the Parameter with a given name from a ParameterSet. More...
 
ParameterNodeGetParameterNodeFromParameterSetByName (const ParameterSet *const params_p, const char *const name_s)
 Get the ParameterNode for a Parameter with a given name from a ParameterSet. More...
 
ParameterDetachParameterByName (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 ParameterGroupGetParameterGroupFromParameterSetByGroupName (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...
 
LinkedListps_params_p
 A LinkedList of ParameterNodes containing the Parameters. More...
 
LinkedListps_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...
 

Detailed Description

A set of Parameters along with an optional name and description.

Member Function Documentation

◆ EasyCreateAndAddDoubleParameterToParameterSet()

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.

Parameters
service_data_pThe ServiceData for the Service that is allocating this Parameter.
params_pThe ParameterSet to add the new Parameter to.
group_pThe ParameterGroup to add this Parameter to. This can be NULL in which case the Parameter will not be placed within any ParameterGroup.
typeThe ParameterType for this Parameter.
name_sThe 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_sAn 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_sThe 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-pThe default value for this Parameter.
levelThe ParameterLevel for this Parameter. This determines when the Client should display this Parameter to the user.
Returns
A newly-allocated Parameter or NULL upon error.

◆ CreateAndAddDoubleParameterToParameterSet()

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.

Parameters
service_data_pThe ServiceData for the Service that is allocating this Parameter.
params_pThe ParameterSet to add the new Parameter to.
group_pThe ParameterGroup to add this Parameter to. This can be NULL in which case the Parameter will not be placed within any ParameterGroup.
typeThe ParameterType for this Parameter.
name_sThe 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_sAn 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_sThe description of the Parameter. The Parameter will store a copy of this string so this value does not need to remain in scope.
options_pThe options specifying the possible values that this Parameter can take. If NULL then it can take any valid values for its given ParameterType.
default_valueThe default value for this Parameter.
current_value_pIf 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.
levelThe ParameterLevel for this Parameter. This determines when the Client should display this Parameter to the user.
Returns
A newly-allocated Parameter or NULL upon error.

◆ AllocateParameterSet()

ParameterSet * AllocateParameterSet ( const char *  name_s,
const char *  description_s 
)

Create a new ParameterSet containing no parameters.

Parameters
name_sThe name to use for the ParameterSet.
description_sThe description to use for the ParameterSet.
Returns
The newly created ParameterSet or NULL upon error.

◆ FreeParameterSet()

void FreeParameterSet ( ParameterSet params_p)

Free a ParameterSet and all of its Parameters.

Parameters
params_pThe ParameterSet to free.

◆ AddParameterToParameterSet()

bool AddParameterToParameterSet ( ParameterSet params_p,
Parameter param_p 
)

Add a Parameter to a ParameterSet.

Parameters
params_pThe ParameterSet to amend.
param_pThe Parameter to add.
Returns
true if the Parameter was added successfully, false otherwise.

◆ 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.

Parameters
params_pThe ParameterSet to amend.
old_param_pThe Parameter to remove.
new_param_pThe Parameter to add to the ParameterSet.
free_old_param_flagIf 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.
Returns
true if the Parameter was replaced successfully, false otherwise.

◆ 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.

This uses the Swagger definitions as much as possible.

Parameters
param_set_pThe ParameterSet to generate the description for.
sv_pIf 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_flagIf 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.
Returns
The json-based representation of the ParameterSet or NULL if there was an error.

◆ GetParameterSetSelectionAsJSON()

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.

Parameters
param_set_pThe ParameterSet to generate the description for.
sv_pIf 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_flagIf 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_pIf 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_fnA 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.
Returns
The json-based representation of the ParameterSet or NULL if there was an error.

◆ 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.

This uses the Swagger definitions as much as possible.

Parameters
json_pThe json-based representation of the ParameterSet.
concise_flagIf 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.
Returns
The newly-generated ParameterSet or NULL if there was an error.
See also
CreateParameterFromJSON

◆ GetParameterFromParameterSetByName()

Parameter * GetParameterFromParameterSetByName ( const ParameterSet *const  params_p,
const char *const  name_s 
)

Get the Parameter with a given name from a ParameterSet.

Parameters
params_pThe ParameterSet to search.
name_sThe Parameter name to try and match.
Returns
The Parameter with the matching name or NULL if it could not be found

◆ 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.

Parameters
params_pThe ParameterSet to search.
name_sThe Parameter name to try and match.
Returns
The ParameterNode with the matching Parameter name or NULL if it could not be found

◆ DetachParameterByName()

Parameter * DetachParameterByName ( ParameterSet params_p,
const char *const  name_s 
)

Remove the Parameter with a given name from a ParameterSet.

Parameters
params_pThe ParameterSet to search.
name_sThe name of the Parameter to try and match.
Returns
If found, the Parameter with the matching name will be removed from the ParameterSet and returned. If it could not be found NULL will be returned. be found.

◆ DetachParameter()

bool DetachParameter ( ParameterSet params_p,
Parameter param_p 
)

Remove the Parameter with from a ParameterSet.

Parameters
params_pThe ParameterSet to search.
param_pThe Parameter to try and deatch.
Returns
true if the Parameter was found and removed from the ParameterSet, false otherwise.

◆ GetParameterGroupFromParameterSetByGroupName()

struct ParameterGroup * GetParameterGroupFromParameterSetByGroupName ( const ParameterSet *const  params_p,
const char *const  name_s 
)

Get all of the Parameters within a given ParameterGroup.

Parameters
params_pThe ParameterSet to search.
name_sThe name of the ParameterGroup to get the Parameters for.
Returns
Upon success, an array of matching Parameter pointers terminated by a NULL. Upon failure a NULL is returned.

◆ AddParameterGroupToParameterSet()

bool AddParameterGroupToParameterSet ( ParameterSet param_set_p,
ParameterGroup group_p 
)

Add a ParameterGroup to a ParameterSet.

Parameters
param_set_pThe ParameterSet to add the ParameterGroup to.
group_pThe ParameterGroup to add.
Returns
true if the ParameterGroup was added successfully, false otherwise.

◆ GetCurrentStringParameterValueFromParameterSet()

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.

Parameters
params_pThe ParameterSet to get the Parameter from.
name_sThe Parameter name to try and match.
value_ppWhere the StringParameter value will be stored upon success.
Returns
true if the Parameter value was retrieved successfully, false otherwise.

Field Documentation

◆ ps_name_s

const char* ps_name_s

An optional name for the ParameterSet.

This can be NULL.

◆ ps_description_s

const char* ps_description_s

An optional description for the ParameterSet.

This can be NULL.

◆ ps_params_p

LinkedList* ps_params_p

A LinkedList of ParameterNodes containing the Parameters.

◆ ps_grouped_params_p

LinkedList* ps_grouped_params_p

A LinkedList of ParameterGroupNodes for this 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 two different run routines depending upon the simple or advanced parameters being set.


The documentation for this struct was generated from the following files: