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.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  * study_treatment.h
18  *
19  * Created on: 5 Mar 2020
20  * Author: billy
21  */
22 
23 #ifndef SERVICES_FIELD_TRIALS_INCLUDE_STUDY_TREATMENT_H_
24 #define SERVICES_FIELD_TRIALS_INCLUDE_STUDY_TREATMENT_H_
25 
26 
29 
30 #include "key_value_pair.h"
31 #include "schema_keys.h"
32 #include "jansson.h"
33 
34 typedef struct Treatment Treatment;
35 
40 struct Treatment
41 {
42  bson_oid_t *tr_id_p;
43 
45 
48 
51 };
52 
53 
54 typedef struct TreatmentNode
55 {
57 
59 
61 
62  /*
63  * Purely a cached pointer of tn_treatment_p -> tr_ontology_term_p -> st_url_s
64  * to speed up access
65  */
66  const char *tn_treatment_url_s;
67 
69 
70 
71 
72 
73 
74 #ifndef DOXYGEN_SHOULD_SKIP_THIS
75 
76 #ifdef ALLOCATE_TREATMENT_TAGS
77  #define TREATMENT_PREFIX DFW_FIELD_TRIAL_SERVICE_LOCAL
78  #define TREATMENT_VAL(x) = x
79  #define TREATMENT_CONCAT_VAL(x,y) = x y
80 #else
81  #define TREATMENT_PREFIX extern
82  #define TREATMENT_VAL(x)
83  #define TREATMENT_CONCAT_VAL(x,y)
84 #endif
85 
86 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
87 
88 
89 TREATMENT_PREFIX const char *TR_NAME_S TREATMENT_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "name");
90 TREATMENT_PREFIX const char *TR_TERM_S TREATMENT_VAL ("term");
91 TREATMENT_PREFIX const char *TR_PARENTS_S TREATMENT_VAL ("parent_name");
92 TREATMENT_PREFIX const char *TR_SYNONYMS_S TREATMENT_VAL ("synonyms");
93 
94 
95 
96 #ifdef __cplusplus
97 extern "C"
98 {
99 #endif
100 
101 
102 DFW_FIELD_TRIAL_SERVICE_LOCAL Treatment *AllocateTreatment (SchemaTerm *term_p, char **parent_names_ss, const size_t num_parents, const bool copy_parents_flag, char **synonyms_ss, const size_t num_synonyms, const bool copy_synonyms_flag, bson_oid_t *id_p);
103 
104 
106 
107 DFW_FIELD_TRIAL_SERVICE_LOCAL bool AddTreatmentValueByParts (Treatment *treatment_p, const char *name_s, const char *value_s);
108 
110 
111 //DFW_FIELD_TRIAL_SERVICE_LOCAL TreatmentNode *AllocateTreatmentNode (Treatment *treatment_p);
112 
114 
115 DFW_FIELD_TRIAL_SERVICE_LOCAL json_t *GetTreatmentAsJSON (const Treatment *treatmnent_p);
116 
117 DFW_FIELD_TRIAL_SERVICE_LOCAL bool AddTreatmentToJSON (const Treatment *treatment_p, json_t *root_p);
118 
119 DFW_FIELD_TRIAL_SERVICE_LOCAL Treatment *GetTreatmentFromJSON (const json_t *treatmnent_json_p);
120 
122 
124 
125 #ifdef _cplusplus
126 }
127 #endif
128 
129 
130 #endif /* SERVICES_FIELD_TRIALS_INCLUDE_STUDY_TREATMENT_H_ */
GetTreatmentAsJSON
json_t * GetTreatmentAsJSON(const Treatment *treatmnent_p)
MEM_FLAG
MEM_FLAG
An enum specifying the particular status of a piece of dynamically allocated memory for a particular ...
Definition: memory_allocations.h:38
AllocateTreatmentNode
TreatmentNode * AllocateTreatmentNode(Treatment *treatment_p, MEM_FLAG treatment_mem)
GetTreatmentFromJSON
Treatment * GetTreatmentFromJSON(const json_t *treatmnent_json_p)
Treatment
A treatment defines an experimental process that can be applied.
Definition: treatment.h:40
TreatmentNode::tn_node
ListItem tn_node
Definition: treatment.h:56
AddTreatmentValue
bool AddTreatmentValue(Treatment *treatment_p, KeyValuePair *pair_p)
Treatment::tr_num_parents
size_t tr_num_parents
Definition: treatment.h:47
Treatment::tr_parent_names_ss
char ** tr_parent_names_ss
Definition: treatment.h:46
FreeTreatmentNode
void FreeTreatmentNode(ListItem *treatment_node_p)
dfw_field_trial_service_library.h
schema_keys.h
The keys for the Grassroots Schema.
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
KeyValuePair
A pair of strings.
Definition: key_value_pair.h:42
AllocateTreatment
Treatment * AllocateTreatment(SchemaTerm *term_p, char **parent_names_ss, const size_t num_parents, const bool copy_parents_flag, char **synonyms_ss, const size_t num_synonyms, const bool copy_synonyms_flag, bson_oid_t *id_p)
TREATMENT_VAL
const TREATMENT_PREFIX char *TR_TERM_S TREATMENT_VAL("term")
AddTreatmentToJSON
bool AddTreatmentToJSON(const Treatment *treatment_p, json_t *root_p)
key_value_pair.h
TreatmentNode::tn_treatment_mem
MEM_FLAG tn_treatment_mem
Definition: treatment.h:60
Treatment::tr_id_p
bson_oid_t * tr_id_p
Definition: treatment.h:42
Treatment::tr_synonyms_ss
char ** tr_synonyms_ss
Definition: treatment.h:49
dfw_field_trial_service_data.h
TreatmentNode
Definition: treatment.h:54
AddTreatmentValueByParts
bool AddTreatmentValueByParts(Treatment *treatment_p, const char *name_s, const char *value_s)
Treatment::tr_ontology_term_p
SchemaTerm * tr_ontology_term_p
Definition: treatment.h:44
TREATMENT_CONCAT_VAL
const TREATMENT_PREFIX char *TR_NAME_S TREATMENT_CONCAT_VAL(CONTEXT_PREFIX_SCHEMA_ORG_S, "name")
TreatmentNode::tn_treatment_url_s
const char * tn_treatment_url_s
Definition: treatment.h:66
FreeTreatment
void FreeTreatment(Treatment *treatment_p)
Treatment::tr_num_synonyms
size_t tr_num_synonyms
Definition: treatment.h:50
SchemaTerm
A datatype for specifying ontological terms as a way to describe the data that each of the Services c...
Definition: schema_term.h:38
TreatmentNode::tn_treatment_p
Treatment * tn_treatment_p
Definition: treatment.h:58
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43