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.
string_array_parameter.h
Go to the documentation of this file.
1 /*
2  * string_array_parameter.h
3  *
4  * Created on: 17 Jan 2021
5  * Author: billy
6  */
7 
8 #ifndef CORE_SHARED_PARAMETERS_INCLUDE_STRING_ARRAY_PARAMETER_H_
9 #define CORE_SHARED_PARAMETERS_INCLUDE_STRING_ARRAY_PARAMETER_H_
10 
11 
12 
13 #include "parameter.h"
14 #include "parameter_set.h"
16 
17 #include "service.h"
18 
19 
20 typedef struct StringArrayParameter
21 {
23 
25 
26 
28 
30 
32 
33 
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39 
40 /*
41  * Allocate a StringArrayParameter
42  *
43  * @param service_data_p The ServiceData for the Service that is allocating this Parameter.
44  * @param 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.
45  * @param 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.
46  * This can be <code>NULL</code>.
47  * @param 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.
48  * @param options_p This can be used to constrain the Parameter to a fixed set of values. If this is <code>NULL</code> then the Parameter can be set to any value.
49  * @param default_value_p The default value for this Parameter.
50  * @param current_value_p If this is not <code>NULL</code>, then copy this value as the current value of the Parameter. If this is <code>NULL</code>, then current value for this Parameter
51  * will be set to be a copy of its default value.
52  * @param bounds_p If this is not <code>NULL</code>, then this will be used to specify the minimum and maximum values that this Parameter can take. If this is <code>NULL</code>,
53  * then the Parameter can take any value.
54  * @param level The ParameterLevel for this Parameter. This determines when the Client should display this Parameter to the user.
55  * @param check_value_fn If this is not <code>NULL</code>, then this will be used to check whether the Parameter has been set to a valid value.
56  * @return A newly-allocated Parameter or <code>NULL</code> upon error.
57  * @memberof BooleanParameter
58  */
59 GRASSROOTS_SERVICE_API StringArrayParameter *AllocateStringArrayParameter (const struct ServiceData *service_data_p, const char * const name_s, const char * const display_name_s, const char * const description_s, char **default_value_ss, char **current_value_ss, const size_t num_values, ParameterLevel level);
60 
61 
62 GRASSROOTS_SERVICE_API StringArrayParameter *AllocateStringArrayParameterFromJSON (const json_t *param_json_p, const struct Service *service_p, const bool concise_flag, const ParameterType *pt_p);
63 
64 
65 
67  const char * const name_s, const char * const display_name_s, const char * const description_s,
68  char **default_values_ss, uint32 num_entries, uint8 level);
69 
71  const char * const name_s, const char * const display_name_s, const char * const description_s,
72  char **default_value_ss, char **current_value_ss, uint32 num_entries, uint8 level);
73 
74 
76 
77 GRASSROOTS_SERVICE_API const char **GetStringArrayValuesForParameter (ParameterSet *param_set_p, const char *param_s, size_t *num_entries_p);
78 
79 
81 
83 
84 
86 
88 
89 
90 GRASSROOTS_SERVICE_API bool GetCurrentStringArrayParameterValuesFromParameterSet (const ParameterSet * const params_p, const char * const name_s, const char ***values_ppp, size_t *num_entries_p);
91 
92 
93 GRASSROOTS_SERVICE_API const char *GetStringArrayParameterCurrentValueAtIndex (const StringArrayParameter *param_p, const size_t index);
94 
95 
96 
97 GRASSROOTS_SERVICE_API bool SetStringArrayParameterCurrentValues (StringArrayParameter *param_p, char **values_ss, const size_t num_values);
98 
99 GRASSROOTS_SERVICE_API bool SetStringArrayParameterDefaultValues (StringArrayParameter *param_p, char **values_ss, const size_t num_values);
100 
101 
103 
104 
105 GRASSROOTS_SERVICE_API char **CopyStringArray (char **src_ss, const size_t num_values);
106 
107 
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* CORE_SHARED_PARAMETERS_INCLUDE_STRING_ARRAY_PARAMETER_H_ */
Parameter
The datatype that stores all of the information about a Parameter.
Definition: parameter.h:121
EasyCreateAndAddStringArrayParameterToParameterSet
Parameter * EasyCreateAndAddStringArrayParameterToParameterSet(const ServiceData *service_data_p, ParameterSet *params_p, ParameterGroup *group_p, const char *const name_s, const char *const display_name_s, const char *const description_s, char **default_values_ss, uint32 num_entries, uint8 level)
ParameterGroup
A datatype to tell the system that certain parameters should be grouped together in the client's user...
Definition: parameter_group.h:85
IsStringArrayParameter
bool IsStringArrayParameter(const Parameter *param_p)
StringArrayParameter::sap_default_values_ss
char ** sap_default_values_ss
Definition: string_array_parameter.h:27
ParameterType
ParameterType
The different types that a Parameter can take.
Definition: parameter_type.h:35
service.h
grassroots_service_library.h
StringArrayParameter::sap_num_values
size_t sap_num_values
Definition: string_array_parameter.h:29
parameter_set.h
GRASSROOTS_SERVICE_API
#define GRASSROOTS_SERVICE_API
Definition: grassroots_service_library.h:49
GetStringArrayParameterCurrentValuesAsFlattenedString
char * GetStringArrayParameterCurrentValuesAsFlattenedString(const StringArrayParameter *param_p)
parameter.h
FreeStringArrayParameter
void FreeStringArrayParameter(StringArrayParameter *param_p)
GetStringArrayParameterCurrentValues
const char ** GetStringArrayParameterCurrentValues(const StringArrayParameter *param_p)
StringArrayParameter::sap_current_values_ss
char ** sap_current_values_ss
Definition: string_array_parameter.h:24
GetStringArrayValuesForParameter
const char ** GetStringArrayValuesForParameter(ParameterSet *param_set_p, const char *param_s, size_t *num_entries_p)
StringArrayParameter::sap_base_param
Parameter sap_base_param
Definition: string_array_parameter.h:22
GetStringArrayParameterCurrentValueAtIndex
const char * GetStringArrayParameterCurrentValueAtIndex(const StringArrayParameter *param_p, const size_t index)
SetStringArrayParameterDefaultValues
bool SetStringArrayParameterDefaultValues(StringArrayParameter *param_p, char **values_ss, const size_t num_values)
Service
A datatype which defines an available service, its capabilities and its parameters.
Definition: service.h:153
CopyStringArray
char ** CopyStringArray(char **src_ss, const size_t num_values)
StringArrayParameter
Definition: string_array_parameter.h:20
CreateAndAddStringArrayParameterToParameterSet
Parameter * CreateAndAddStringArrayParameterToParameterSet(const ServiceData *service_data_p, ParameterSet *params_p, ParameterGroup *group_p, const char *const name_s, const char *const display_name_s, const char *const description_s, char **default_value_ss, char **current_value_ss, uint32 num_entries, uint8 level)
GetNumberOfStringArrayCurrentParameterValues
size_t GetNumberOfStringArrayCurrentParameterValues(const StringArrayParameter *param_p)
SetStringArrayParameterCurrentValues
bool SetStringArrayParameterCurrentValues(StringArrayParameter *param_p, char **values_ss, const size_t num_values)
AllocateStringArrayParameter
StringArrayParameter * AllocateStringArrayParameter(const struct ServiceData *service_data_p, const char *const name_s, const char *const display_name_s, const char *const description_s, char **default_value_ss, char **current_value_ss, const size_t num_values, ParameterLevel level)
ParameterLevel
ParameterLevel
The ParameterLevel defines the level that a user should be to adjust the Parameter.
Definition: parameter.h:52
AllocateStringArrayParameterFromJSON
StringArrayParameter * AllocateStringArrayParameterFromJSON(const json_t *param_json_p, const struct Service *service_p, const bool concise_flag, const ParameterType *pt_p)
ServiceData
A datatype for holding the configuration data for a Service.
Definition: service.h:126
GetStringArrayParameterDefaultValues
const char ** GetStringArrayParameterDefaultValues(const StringArrayParameter *param_p)
GetCurrentStringArrayParameterValuesFromParameterSet
bool GetCurrentStringArrayParameterValuesFromParameterSet(const ParameterSet *const params_p, const char *const name_s, const char ***values_ppp, size_t *num_entries_p)
ParameterSet
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46