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.
treatment_factor.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  * treatment_factor..h
18  *
19  * Created on: 4 Dec 2020
20  * Author: billy
21  */
22 
23 #ifndef SERVICES_FIELD_TRIALS_INCLUDE_TREATMENT_FACTOR_H_
24 #define SERVICES_FIELD_TRIALS_INCLUDE_TREATMENT_FACTOR_H_
25 
26 
29 
30 #include "treatment.h"
31 #include "linked_list.h"
32 
33 
34 /* forward declarations */
35 struct Study;
36 
37 
38 
39 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40 
41 #ifdef ALLOCATE_TREATMENT_FACTOR_TAGS
42  #define TREATMENT_FACTOR_PREFIX DFW_FIELD_TRIAL_SERVICE_LOCAL
43  #define TREATMENT_FACTOR_VAL(x) = x
44  #define TREATMENT_FACTOR_CONCAT_VAL(x,y) = x y
45 #else
46  #define TREATMENT_FACTOR_PREFIX extern
47  #define TREATMENT_FACTOR_VAL(x)
48  #define TREATMENT_FACTOR_CONCAT_VAL(x,y)
49 #endif
50 
51 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
52 
53 
54 
55 
56 
57 
58 TREATMENT_FACTOR_PREFIX const char *TF_STUDY_ID_S TREATMENT_FACTOR_VAL("study_id");
59 TREATMENT_FACTOR_PREFIX const char *TF_STUDY_NAME_S TREATMENT_FACTOR_VAL ("study_name");
60 TREATMENT_FACTOR_PREFIX const char *TF_TREATMENT_S TREATMENT_FACTOR_VAL ( "treatment");
61 TREATMENT_FACTOR_PREFIX const char *TF_TREATMENT_ID_S TREATMENT_FACTOR_VAL ("treatment_id");
62 TREATMENT_FACTOR_PREFIX const char *TF_VALUES_S TREATMENT_FACTOR_VAL ("values");
63 TREATMENT_FACTOR_PREFIX const char *TF_VALUES_KEY_S TREATMENT_FACTOR_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "name");
64 TREATMENT_FACTOR_PREFIX const char *TF_VALUES_VALUE_S TREATMENT_FACTOR_VAL ("value");
65 
66 
67 
68 
69 
76 typedef struct TreatmentFactor
77 {
80 
82  struct Study *tf_study_p;
83 
91 
93 
94 
95 typedef struct TreatmentFactorNode
96 {
98 
101 
102 
103 
104 #ifdef __cplusplus
105 extern "C"
106 {
107 #endif
108 
109 
111 
113 
114 DFW_FIELD_TRIAL_SERVICE_LOCAL bool AddTreatmentFactorValue (TreatmentFactor *treatment_p, const char *name_s, const char *value_s);
115 
117 
119 
121 
122 DFW_FIELD_TRIAL_SERVICE_LOCAL json_t *GetTreatmentFactorAsJSON (const TreatmentFactor *treatment_factor_p, const ViewFormat format);
123 
124 DFW_FIELD_TRIAL_SERVICE_LOCAL TreatmentFactor *GetTreatmentFactorFromJSON (const json_t *treatment_factor_json_p, struct Study *parent_study_p, const FieldTrialServiceData *data_p);
125 
126 DFW_FIELD_TRIAL_SERVICE_LOCAL const char *GetTreatmentFactorValue (TreatmentFactor *treatment_p, const char *name_s);
127 
128 DFW_FIELD_TRIAL_SERVICE_LOCAL const char *GetTreatmentFactorName (const TreatmentFactor *treatment_factor_p);
129 
130 
131 DFW_FIELD_TRIAL_SERVICE_LOCAL const char *GetTreatmentFactorUrl (const TreatmentFactor *treatment_factor_p);
132 
133 DFW_FIELD_TRIAL_SERVICE_LOCAL const char *GetTreatmentFactorDescription (const TreatmentFactor *treatment_factor_p);
134 
135 
136 
137 DFW_FIELD_TRIAL_SERVICE_LOCAL json_t *GetTreatmentFactorValuesAsJSON (const TreatmentFactor *treatment_factor_p, const ViewFormat format);
138 
139 
140 
141 
142 
143 #ifdef _cplusplus
144 }
145 #endif
146 
147 
148 #endif /* SERVICES_FIELD_TRIALS_INCLUDE_TREATMENT_FACTOR_H_ */
TreatmentFactorNode::tfn_node
ListItem tfn_node
Definition: treatment_factor.h:97
FreeTreatmentFactor
void FreeTreatmentFactor(TreatmentFactor *treatment_factor_p)
AllocateTreatmentFactor
TreatmentFactor * AllocateTreatmentFactor(Treatment *treatment_factor_p, struct Study *study_p)
Treatment
A treatment defines an experimental process that can be applied.
Definition: treatment.h:40
TREATMENT_FACTOR_VAL
const TREATMENT_FACTOR_PREFIX char *TF_STUDY_ID_S TREATMENT_FACTOR_VAL("study_id")
GetNumberOfTreatmentFactorValues
size_t * GetNumberOfTreatmentFactorValues(const TreatmentFactor *treatment_factor_p)
TreatmentFactorNode
Definition: treatment_factor.h:95
AddTreatmentFactorValue
bool AddTreatmentFactorValue(TreatmentFactor *treatment_p, const char *name_s, const char *value_s)
TreatmentFactor
A TreatmentFactor is a set of values for a Treatment applied to plots within a Study.
Definition: treatment_factor.h:76
TreatmentFactorNode::tfn_p
TreatmentFactor * tfn_p
Definition: treatment_factor.h:99
GetTreatmentFactorName
const char * GetTreatmentFactorName(const TreatmentFactor *treatment_factor_p)
dfw_field_trial_service_library.h
DFW_FIELD_TRIAL_SERVICE_LOCAL
#define DFW_FIELD_TRIAL_SERVICE_LOCAL
Definition: dfw_field_trial_service_library.h:43
CONTEXT_PREFIX_SCHEMA_ORG_S
#define CONTEXT_PREFIX_SCHEMA_ORG_S
Definition: schema_keys.h:103
treatment.h
AllocateTreatmentFactorNode
TreatmentFactorNode * AllocateTreatmentFactorNode(TreatmentFactor *treatment_factor_p)
FreeTreatmentFactorNode
void FreeTreatmentFactorNode(ListItem *treatment_node_p)
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
GetTreatmentFactorValue
const char * GetTreatmentFactorValue(TreatmentFactor *treatment_p, const char *name_s)
GetTreatmentFactorDescription
const char * GetTreatmentFactorDescription(const TreatmentFactor *treatment_factor_p)
TREATMENT_FACTOR_CONCAT_VAL
const TREATMENT_FACTOR_PREFIX char *TF_VALUES_KEY_S TREATMENT_FACTOR_CONCAT_VAL(CONTEXT_PREFIX_SCHEMA_ORG_S, "name")
TreatmentFactor::tf_values_p
LinkedList * tf_values_p
A list of KeyValuePairNodes where the keys are the labels for the different levels of the applied Tre...
Definition: treatment_factor.h:90
dfw_field_trial_service_data.h
linked_list.h
A doubly-linked list.
GetTreatmentFactorValuesAsJSON
json_t * GetTreatmentFactorValuesAsJSON(const TreatmentFactor *treatment_factor_p, const ViewFormat format)
GetTreatmentFactorUrl
const char * GetTreatmentFactorUrl(const TreatmentFactor *treatment_factor_p)
GetTreatmentFactorAsJSON
json_t * GetTreatmentFactorAsJSON(const TreatmentFactor *treatment_factor_p, const ViewFormat format)
FieldTrialServiceData
The configuration data used by the DFW Field Trial Service.
Definition: dfw_field_trial_service_data.h:118
TreatmentFactor::tf_treatment_p
Treatment * tf_treatment_p
The Treatment that is applied.
Definition: treatment_factor.h:79
ViewFormat
ViewFormat
An indicator of what the output destination is for the JSON data values.
Definition: view_format.h:19
TreatmentFactor::tf_study_p
struct Study * tf_study_p
The Study that this TreatmentFactor is applied in.
Definition: treatment_factor.h:82
Study
Definition: study.h:182
GetTreatmentFactorFromJSON
TreatmentFactor * GetTreatmentFactorFromJSON(const json_t *treatment_factor_json_p, struct Study *parent_study_p, const FieldTrialServiceData *data_p)
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43