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.
field_trial.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2018 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  * field_trial.h
18  *
19  * Created on: 11 Sep 2018
20  * Author: billy
21  */
22 
30 #ifndef SERVICES_FIELD_TRIALS_INCLUDE_FIELD_TRIAL_H_
31 #define SERVICES_FIELD_TRIALS_INCLUDE_FIELD_TRIAL_H_
32 
35 #include "jansson.h"
36 
37 #include "typedefs.h"
38 #include "linked_list.h"
39 #include "person.h"
40 
41 /* forward declarations */
42 struct Study;
43 struct Programme;
44 
50 typedef struct FieldTrial
51 {
52  bson_oid_t *ft_id_p;
53 
58 
63 
65 
66 
70  char *ft_name_s;
71 
75  char *ft_team_s;
76 
83 
84 
90 
91 } FieldTrial;
92 
93 
99 typedef struct FieldTrialNode
100 {
105 
110 
112 
113 
114 #ifndef DOXYGEN_SHOULD_SKIP_THIS
115 
116 #ifdef ALLOCATE_FIELD_TRIAL_TAGS
117  #define FIELD_TRIAL_PREFIX DFW_FIELD_TRIAL_SERVICE_LOCAL
118  #define FIELD_TRIAL_VAL(x) = x
119  #define FIELD_TRIAL_CONCAT_VAL(x,y) = x y
120 #else
121  #define FIELD_TRIAL_PREFIX extern
122  #define FIELD_TRIAL_VAL(x)
123  #define FIELD_TRIAL_CONCAT_VAL(x,y)
124 #endif
125 
126 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
127 
128 
129 
130 
131 /* Field Trial */
132 
133 
134 FIELD_TRIAL_PREFIX const char *FT_NAME_S FIELD_TRIAL_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "name");
135 
136 FIELD_TRIAL_PREFIX const char *FT_TEAM_S FIELD_TRIAL_VAL ("team");
137 
138 FIELD_TRIAL_PREFIX const char *FT_ID_S FIELD_TRIAL_VAL ("_id");
139 
140 FIELD_TRIAL_PREFIX const char *FT_STUDIES_S FIELD_TRIAL_VAL ("studies");
141 
142 FIELD_TRIAL_PREFIX const char *FT_PEOPLE_S FIELD_TRIAL_VAL ("people");
143 
144 FIELD_TRIAL_PREFIX const char *FT_PARENT_PROGRAM_S FIELD_TRIAL_VAL ("parent_program");
145 
146 
147 #ifdef __cplusplus
148 extern "C"
149 {
150 #endif
151 
152 
153 DFW_FIELD_TRIAL_SERVICE_LOCAL FieldTrial *AllocateFieldTrial (const char *name_s, const char *team_s, struct Programme *parent_program_p, MEM_FLAG parent_program_mem, bson_oid_t *id_p, const char *time_s);
154 
162 
164 
166 
168 
169 DFW_FIELD_TRIAL_SERVICE_LOCAL FieldTrial *GetFieldTrialFromJSON (const json_t *json_p, const ViewFormat format, const FieldTrialServiceData *data_p);
170 
171 
172 DFW_FIELD_TRIAL_SERVICE_LOCAL FieldTrial *GetVersionedFieldTrial (const char *field_trial_id_s, const char *timestamp_s, const ViewFormat format, const FieldTrialServiceData *data_p);
173 
174 
176 
178 
179 
181 
182 
183 DFW_FIELD_TRIAL_SERVICE_LOCAL bool AddFieldTrialStudy (FieldTrial *trial_p, struct Study *study_p, MEM_FLAG mf);
184 
185 
187 
188 
190 
191 
192 DFW_FIELD_TRIAL_SERVICE_LOCAL FieldTrial *GetFieldTrialByIdString (const char *field_trial_id_s, const ViewFormat format, const FieldTrialServiceData *data_p);
193 
194 
196 
197 
199 
200 
201 DFW_FIELD_TRIAL_SERVICE_LOCAL bool AddStudiesToFieldTrialJSON (FieldTrial *trial_p, json_t *trial_json_p, const ViewFormat format, FieldTrialServiceData *data_p);
202 
203 
204 DFW_FIELD_TRIAL_SERVICE_LOCAL bool AddPeopleToFieldTrialJSON (FieldTrial *trial_p, json_t *trial_json_p, const ViewFormat format, FieldTrialServiceData *data_p);
205 
206 
207 DFW_FIELD_TRIAL_SERVICE_LOCAL LinkedList *GetFieldTrialsByName (const char * const trial_s, const FieldTrialServiceData *data_p);
208 
209 
210 DFW_FIELD_TRIAL_SERVICE_LOCAL FieldTrial *GetFieldTrialById (const bson_oid_t *id_p, const ViewFormat format, const FieldTrialServiceData *data_p);
211 
212 
224 
225 
234 
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 
241 
242 
243 
244 #endif /* SERVICES_FIELD_TRIALS_INCLUDE_FIELD_TRIAL_H_ */
SaveFieldTrial
bool SaveFieldTrial(FieldTrial *trial_p, ServiceJob *job_p, FieldTrialServiceData *data_p)
FreeFieldTrial
void FreeFieldTrial(FieldTrial *trial_p)
Free a given FieldTrial.
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
GetFieldTrialByIdString
FieldTrial * GetFieldTrialByIdString(const char *field_trial_id_s, const ViewFormat format, const FieldTrialServiceData *data_p)
FieldTrial::ft_studies_p
LinkedList * ft_studies_p
A LinkedList of StudyNodes for all of the Studies in this FieldTrial.
Definition: field_trial.h:82
ServiceJob
A datatype to represent a running task.
Definition: service_job.h:72
GetNumberOfFieldTrialStudies
uint32 GetNumberOfFieldTrialStudies(const FieldTrial *trial_p)
Get the number of Studies in a given FieldTrial.
dfw_field_trial_service_library.h
RemoveFieldTrialStudy
bool RemoveFieldTrialStudy(FieldTrial *trial_p, struct Study *study_p)
Remove a Study from a given FieldTrial.
FIELD_TRIAL_CONCAT_VAL
const FIELD_TRIAL_PREFIX char *FT_NAME_S FIELD_TRIAL_CONCAT_VAL(CONTEXT_PREFIX_SCHEMA_ORG_S, "name")
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
FieldTrial::ft_parent_p
struct Programme * ft_parent_p
The Programme that this Field Trial is a part of.
Definition: field_trial.h:62
FieldTrial
A datatype that represents a Field Trial that can contain one or more Studies.
Definition: field_trial.h:50
GetFieldTrialById
FieldTrial * GetFieldTrialById(const bson_oid_t *id_p, const ViewFormat format, const FieldTrialServiceData *data_p)
typedefs.h
AllocateFieldTrial
FieldTrial * AllocateFieldTrial(const char *name_s, const char *team_s, struct Programme *parent_program_p, MEM_FLAG parent_program_mem, bson_oid_t *id_p, const char *time_s)
FT_STUDIES_S
const FIELD_TRIAL_PREFIX char * FT_STUDIES_S
Definition: field_trial.h:140
AllocateFieldTrialNode
FieldTrialNode * AllocateFieldTrialNode(FieldTrial *trial_p)
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
Programme
Definition: programme.h:46
AddStudiesToFieldTrialJSON
bool AddStudiesToFieldTrialJSON(FieldTrial *trial_p, json_t *trial_json_p, const ViewFormat format, FieldTrialServiceData *data_p)
FieldTrialNode::ftn_field_trial_p
FieldTrial * ftn_field_trial_p
The FieldTrial.
Definition: field_trial.h:109
GetFieldTrialIdAsString
char * GetFieldTrialIdAsString(const FieldTrial *trial_p)
GetFieldTrialFromJSON
FieldTrial * GetFieldTrialFromJSON(const json_t *json_p, const ViewFormat format, const FieldTrialServiceData *data_p)
GetUniqueFieldTrialBySearchString
FieldTrial * GetUniqueFieldTrialBySearchString(const char *trial_s, const ViewFormat format, const FieldTrialServiceData *data_p)
AddFieldTrialPerson
bool AddFieldTrialPerson(FieldTrial *trial_p, Person *person_p, MEM_FLAG mf)
Person
Definition: person.h:51
FieldTrial::ft_team_s
char * ft_team_s
The team or organisation running this FieldTrial.
Definition: field_trial.h:75
FieldTrial::ft_people_p
LinkedList * ft_people_p
A LinkedList of PersonNodes for each of the PI and Co-I people on this trial.
Definition: field_trial.h:89
FieldTrial::ft_parent_program_mem
MEM_FLAG ft_parent_program_mem
Definition: field_trial.h:64
dfw_field_trial_service_data.h
FreeFieldTrialNode
void FreeFieldTrialNode(ListItem *node_p)
GetFieldTrialAsString
char * GetFieldTrialAsString(const FieldTrial *trial_p)
linked_list.h
A doubly-linked list.
FT_ID_S
const FIELD_TRIAL_PREFIX char * FT_ID_S
Definition: field_trial.h:138
FieldTrial::ft_id_p
bson_oid_t * ft_id_p
Definition: field_trial.h:52
GetFieldTrialsByName
LinkedList * GetFieldTrialsByName(const char *const trial_s, const FieldTrialServiceData *data_p)
FT_TEAM_S
const FIELD_TRIAL_PREFIX char * FT_TEAM_S
Definition: field_trial.h:136
GetAllFieldTrialStudies
bool GetAllFieldTrialStudies(FieldTrial *trial_p, const ViewFormat format, const FieldTrialServiceData *data_p)
FieldTrialServiceData
The configuration data used by the DFW Field Trial Service.
Definition: dfw_field_trial_service_data.h:118
AddFieldTrialStudy
bool AddFieldTrialStudy(FieldTrial *trial_p, struct Study *study_p, MEM_FLAG mf)
FieldTrial::ft_timestamp_s
char * ft_timestamp_s
The time when this Field Trial was saved.
Definition: field_trial.h:57
GetVersionedFieldTrial
FieldTrial * GetVersionedFieldTrial(const char *field_trial_id_s, const char *timestamp_s, const ViewFormat format, const FieldTrialServiceData *data_p)
FT_PARENT_PROGRAM_S
const FIELD_TRIAL_PREFIX char * FT_PARENT_PROGRAM_S
Definition: field_trial.h:144
ViewFormat
ViewFormat
An indicator of what the output destination is for the JSON data values.
Definition: view_format.h:19
FieldTrial::ft_name_s
char * ft_name_s
Name of the field trial.
Definition: field_trial.h:70
FT_PEOPLE_S
const FIELD_TRIAL_PREFIX char * FT_PEOPLE_S
Definition: field_trial.h:142
GetFieldTrialAsJSON
json_t * GetFieldTrialAsJSON(FieldTrial *trial_p, const ViewFormat format, FieldTrialServiceData *data_p)
Study
Definition: study.h:182
person.h
FieldTrialNode
A datatype for storing a Field Trial on a list.
Definition: field_trial.h:99
FieldTrialNode::ftn_node
ListItem ftn_node
The base node.
Definition: field_trial.h:104
AddPeopleToFieldTrialJSON
bool AddPeopleToFieldTrialJSON(FieldTrial *trial_p, json_t *trial_json_p, const ViewFormat format, FieldTrialServiceData *data_p)
GetFieldTrialStudies
LinkedList * GetFieldTrialStudies(FieldTrial *trial_p)
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43