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.
json_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  * json_parameter.h
18  *
19  * Created on: 31 Jan 2020
20  * Author: billy
21  */
22 
23 #ifndef CORE_SHARED_PARAMETERS_INCLUDE_JSON_PARAMETER_H_
24 #define CORE_SHARED_PARAMETERS_INCLUDE_JSON_PARAMETER_H_
25 
26 #include "parameter.h"
28 #include "parameter_set.h"
29 
30 
31 
32 typedef struct JSONParameter
33 {
35 
37 
40 
41 
42 #ifndef DOXYGEN_SHOULD_SKIP_THIS
43 
44 #ifdef ALLOCATE_JSON_PARAMETER_TAGS
45  #define JSON_PARAM_PREFIX GRASSROOTS_SERVICE_API
46  #define JSON_PARAM_VAL(x) = x
47 #else
48  #define JSON_PARAM_PREFIX extern GRASSROOTS_SERVICE_API
49  #define JSON_PARAM_VAL(x)
50 #endif
51 
52 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
53 
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 
60 
61 JSON_PARAM_PREFIX const char *TABLE_PARAM_ROW_S JSON_PARAM_VAL("row");
62 JSON_PARAM_PREFIX const char *TABLE_PARAM_COLUMN_S JSON_PARAM_VAL("column");
63 
64 
65 
85 GRASSROOTS_SERVICE_API JSONParameter *AllocateJSONParameter (const struct ServiceData *service_data_p, const ParameterType pt, const char * const name_s, const char * const display_name_s, const char * const description_s, const json_t *default_value_p, const json_t *current_value_p, ParameterLevel level);
86 
87 
88 
89 GRASSROOTS_SERVICE_API JSONParameter *AllocateJSONParameterFromJSON (const json_t *param_json_p, const struct Service *service_p, const bool concise_flag, const ParameterType *pt_p);
90 
91 
93  const char * const name_s, const char * const display_name_s, const char * const description_s,
94  const json_t *default_value_p, uint8 level);
95 
96 
98  const char * const name_s, const char * const display_name_s, const char * const description_s,
99  const json_t *default_value_p, const json_t *current_value_p, uint8 level);
100 
101 
103 
104 
106 
107 
108 GRASSROOTS_SERVICE_API bool SetJSONParameterCurrentValue (JSONParameter *param_p, const json_t *value_p);
109 
110 
112 
113 
114 GRASSROOTS_SERVICE_API bool SetJSONParameterDefaultValue (JSONParameter *param_p, const json_t *value_p);
115 
116 
118 
119 
120 GRASSROOTS_SERVICE_API bool GetCurrentJSONParameterValueFromParameterSet (const ParameterSet * const params_p, const char * const name_s, const json_t **value_pp);
121 
122 
123 GRASSROOTS_SERVICE_API bool SetJSONParameterCurrentValueFromJSON (JSONParameter *param_p, const json_t *value_p);
124 
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* CORE_SHARED_PARAMETERS_INCLUDE_JSON_PARAMETER_H_ */
Parameter
The datatype that stores all of the information about a Parameter.
Definition: parameter.h:121
ParameterGroup
A datatype to tell the system that certain parameters should be grouped together in the client's user...
Definition: parameter_group.h:85
JSON_PARAM_VAL
const JSON_PARAM_PREFIX char *TABLE_PARAM_ROW_S JSON_PARAM_VAL("row")
JSONParameter
Definition: json_parameter.h:32
ParameterType
ParameterType
The different types that a Parameter can take.
Definition: parameter_type.h:35
JSONParameter::jp_current_value_p
json_t * jp_current_value_p
Definition: json_parameter.h:36
JSONParameter::jp_base_param
Parameter jp_base_param
Definition: json_parameter.h:34
grassroots_service_library.h
parameter_set.h
CreateAndAddJSONParameterToParameterSet
Parameter * CreateAndAddJSONParameterToParameterSet(const struct ServiceData *service_data_p, ParameterSet *params_p, ParameterGroup *group_p, ParameterType type, const char *const name_s, const char *const display_name_s, const char *const description_s, const json_t *default_value_p, const json_t *current_value_p, uint8 level)
GRASSROOTS_SERVICE_API
#define GRASSROOTS_SERVICE_API
Definition: grassroots_service_library.h:49
GetJSONParameterCurrentValue
const json_t * GetJSONParameterCurrentValue(const JSONParameter *param_p)
parameter.h
GetJSONParameterDefaultValue
const json_t * GetJSONParameterDefaultValue(const JSONParameter *param_p)
JSONParameter::jp_default_value_p
json_t * jp_default_value_p
Definition: json_parameter.h:38
JSONParameter::AllocateJSONParameter
JSONParameter * AllocateJSONParameter(const struct ServiceData *service_data_p, const ParameterType pt, const char *const name_s, const char *const display_name_s, const char *const description_s, const json_t *default_value_p, const json_t *current_value_p, ParameterLevel level)
Allocate a JSONParameter.
SetJSONParameterCurrentValueFromJSON
bool SetJSONParameterCurrentValueFromJSON(JSONParameter *param_p, const json_t *value_p)
FreeJSONParameter
void FreeJSONParameter(JSONParameter *param_p)
Service
A datatype which defines an available service, its capabilities and its parameters.
Definition: service.h:153
IsJSONParameter
bool IsJSONParameter(Parameter *param_p)
EasyCreateAndAddJSONParameterToParameterSet
Parameter * EasyCreateAndAddJSONParameterToParameterSet(const struct ServiceData *service_data_p, ParameterSet *params_p, ParameterGroup *group_p, ParameterType type, const char *const name_s, const char *const display_name_s, const char *const description_s, const json_t *default_value_p, uint8 level)
ParameterLevel
ParameterLevel
The ParameterLevel defines the level that a user should be to adjust the Parameter.
Definition: parameter.h:52
SetJSONParameterCurrentValue
bool SetJSONParameterCurrentValue(JSONParameter *param_p, const json_t *value_p)
GetCurrentJSONParameterValueFromParameterSet
bool GetCurrentJSONParameterValueFromParameterSet(const ParameterSet *const params_p, const char *const name_s, const json_t **value_pp)
AllocateJSONParameterFromJSON
JSONParameter * AllocateJSONParameterFromJSON(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
ParameterSet
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46
SetJSONParameterDefaultValue
bool SetJSONParameterDefaultValue(JSONParameter *param_p, const json_t *value_p)