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.
char_parameter.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2020 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 /*
17  * char_parameter.h
18  *
19  * Created on: 30 Jan 2020
20  * Author: billy
21  */
22 
23 #ifndef CORE_SHARED_PARAMETERS_INCLUDE_CHAR_PARAMETER_H_
24 #define CORE_SHARED_PARAMETERS_INCLUDE_CHAR_PARAMETER_H_
25 
26 
27 #include "parameter.h"
29 #include "parameter_set.h"
30 
31 
32 /* forward declaration */
33 struct ServiceData;
34 
35 
36 typedef struct CharParameter
37 {
39 
41 
43 
45 
47 
49 
50 
51 #ifdef __cplusplus
52 extern "C"
53 {
54 #endif
55 
56 
57 /*
58  * Allocate a CharParameter
59  *
60  * @param service_data_p The ServiceData for the Service that is allocating this Parameter.
61  * @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.
62  * @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.
63  * This can be <code>NULL</code>.
64  * @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.
65  * @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.
66  * @param default_value_p The default value for this Parameter.
67  * @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
68  * will be set to be a copy of its default value.
69  * @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>,
70  * then the Parameter can take any value.
71  * @param level The ParameterLevel for this Parameter. This determines when the Client should display this Parameter to the user.
72  * @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.
73  * @return A newly-allocated Parameter or <code>NULL</code> upon error.
74  * @memberof BooleanParameter
75  */
76 GRASSROOTS_SERVICE_API CharParameter *AllocateCharParameter (const struct ServiceData *service_data_p, const char * const name_s, const char * const display_name_s, const char * const description_s, const char *default_value_p, const char *current_value_p, ParameterLevel level);
77 
78 
79 GRASSROOTS_SERVICE_API CharParameter *AllocateCharParameterFromJSON (const json_t *param_json_p, const struct Service *service_p, const bool concise_flag);
80 
81 
83 
84 
86 
87 
88 GRASSROOTS_SERVICE_API bool SetCharParameterCurrentValue (CharParameter *param_p, const char *value_p);
89 
90 
92 
93 
94 GRASSROOTS_SERVICE_API bool SetCharParameterDefaultValue (CharParameter *param_p, const char *value_p);
95 
96 
97 GRASSROOTS_SERVICE_API bool SetCharParameterBounds (CharParameter *param_p, const char min_value, const char max_value);
98 
99 
101 
102 
103 GRASSROOTS_SERVICE_API bool GetCharParameterBounds (const CharParameter *param_p, char *min_p, char *max_p);
104 
105 
107 
108 
109 GRASSROOTS_SERVICE_API bool GetCurrentCharParameterValueFromParameterSet (const ParameterSet * const params_p, const char * const name_s, const char **value_pp);
110 
111 
112 
114  const char * const name_s, const char * const display_name_s, const char * const description_s,
115  const char *default_value_p, uint8 level);
116 
117 
119  const char * const name_s, const char * const display_name_s, const char * const description_s,
120  const char *default_value_p, const char *current_value_p, uint8 level);
121 
122 
123 GRASSROOTS_SERVICE_API bool SetCharParameterCurrentValueFromJSON (CharParameter *param_p, const json_t *value_p);
124 
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* CORE_SHARED_PARAMETERS_INCLUDE_CHAR_PARAMETER_H_ */
Parameter
The datatype that stores all of the information about a Parameter.
Definition: parameter.h:121
AllocateCharParameter
CharParameter * AllocateCharParameter(const struct ServiceData *service_data_p, const char *const name_s, const char *const display_name_s, const char *const description_s, const char *default_value_p, const char *current_value_p, ParameterLevel 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
SetCharParameterCurrentValueFromJSON
bool SetCharParameterCurrentValueFromJSON(CharParameter *param_p, const json_t *value_p)
SetCharParameterCurrentValue
bool SetCharParameterCurrentValue(CharParameter *param_p, const char *value_p)
AllocateCharParameterFromJSON
CharParameter * AllocateCharParameterFromJSON(const json_t *param_json_p, const struct Service *service_p, const bool concise_flag)
grassroots_service_library.h
parameter_set.h
EasyCreateAndAddCharParameterToParameterSet
Parameter * EasyCreateAndAddCharParameterToParameterSet(const struct 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, const char *default_value_p, uint8 level)
GRASSROOTS_SERVICE_API
#define GRASSROOTS_SERVICE_API
Definition: grassroots_service_library.h:49
GetCharParameterDefaultValue
const char * GetCharParameterDefaultValue(const CharParameter *param_p)
parameter.h
SetCharParameterBounds
bool SetCharParameterBounds(CharParameter *param_p, const char min_value, const char max_value)
CharParameter::cp_min_value_p
char * cp_min_value_p
Definition: char_parameter.h:44
GetCharParameterCurrentValue
const char * GetCharParameterCurrentValue(const CharParameter *param_p)
CharParameter
Definition: char_parameter.h:36
Service
A datatype which defines an available service, its capabilities and its parameters.
Definition: service.h:153
IsCharParameterBounded
bool IsCharParameterBounded(const CharParameter *param_p)
CreateAndAddCharParameterToParameterSet
Parameter * CreateAndAddCharParameterToParameterSet(const struct 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, const char *default_value_p, const char *current_value_p, uint8 level)
SetCharParameterDefaultValue
bool SetCharParameterDefaultValue(CharParameter *param_p, const char *value_p)
IsCharParameter
bool IsCharParameter(Parameter *param_p)
ParameterLevel
ParameterLevel
The ParameterLevel defines the level that a user should be to adjust the Parameter.
Definition: parameter.h:52
GetCharParameterBounds
bool GetCharParameterBounds(const CharParameter *param_p, char *min_p, char *max_p)
CharParameter::cp_base_param
Parameter cp_base_param
Definition: char_parameter.h:38
FreeCharParameter
void FreeCharParameter(CharParameter *param_p)
CharParameter::cp_current_value_p
char * cp_current_value_p
Definition: char_parameter.h:40
ServiceData
A datatype for holding the configuration data for a Service.
Definition: service.h:126
CharParameter::cp_default_value_p
char * cp_default_value_p
Definition: char_parameter.h:42
ParameterSet
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46
GetCurrentCharParameterValueFromParameterSet
bool GetCurrentCharParameterValueFromParameterSet(const ParameterSet *const params_p, const char *const name_s, const char **value_pp)
CharParameter::cp_max_value_p
char * cp_max_value_p
Definition: char_parameter.h:46