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.
row.h
Go to the documentation of this file.
1 /*
2  * base_row.h
3  *
4  * Created on: 29 Jun 2022
5  * Author: billy
6  */
7 
8 #ifndef SERVICES_FIELD_TRIALS_INCLUDE_BASE_ROW_H_
9 #define SERVICES_FIELD_TRIALS_INCLUDE_BASE_ROW_H_
10 
11 
12 #include "bson/bson.h"
13 
15 #include "plot.h"
16 
17 
18 /*
19  * Forward declarations
20  */
21 struct Study;
22 
23 
24 typedef enum
25 {
30 
36 
43 
48 } RowType;
49 
50 
51 typedef struct Row Row;
52 
53 
54 struct Row
55 {
57 
58  bson_oid_t *ro_id_p;
59 
60  const struct Study *ro_study_p;
61 
62  struct Plot *ro_plot_p;
63 
69 
70  void (*ro_clear_fn) (Row *row_p);
71 
72  bool (*ro_add_to_json_fn) (const Row *row_p, json_t *row_json_p, const ViewFormat format, const FieldTrialServiceData *data_p);
73 
74  bool (*ro_add_from_json_fn) (Row *row_p, const json_t *row_json_p, const FieldTrialServiceData *data_p);
75 
76  bool (*ro_add_to_fd_fn) (const Row *row_p, json_t *row_fd_p, const FieldTrialServiceData *service_data_p, const char * const null_sequence_s);
77 
78 };
79 
80 
81 
82 typedef struct RowNode
83 {
85 
87 } RowNode;
88 
89 
90 
91 
92 #ifndef DOXYGEN_SHOULD_SKIP_THIS
93 
94 #ifdef ALLOCATE_BASE_ROW_TAGS
95  #define BASE_ROW_PREFIX DFW_FIELD_TRIAL_SERVICE_API
96  #define BASE_ROW_VAL(x) = x
97  #define BASE_ROW_CONCAT_VAL(x,y) = x y
98 #else
99  #define BASE_ROW_PREFIX extern
100  #define BASE_ROW_VAL(x)
101  #define BASE_ROW_CONCAT_VAL(x,y)
102 #endif
103 
104 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
105 
106 
107 
108 
109 BASE_ROW_PREFIX const char *RO_ID_S BASE_ROW_VAL ("id");
110 
111 BASE_ROW_PREFIX const char *RO_STUDY_INDEX_S BASE_ROW_VAL ("study_index");
112 
113 BASE_ROW_PREFIX const char *RO_PLOT_ID_S BASE_ROW_VAL ("plot_id");
114 
115 BASE_ROW_PREFIX const char *RO_STUDY_ID_S BASE_ROW_VAL ("study_id");
116 
117 BASE_ROW_PREFIX const char *RO_DISCARD_S BASE_ROW_VAL ("discard");
118 
119 
120 BASE_ROW_PREFIX const char *RO_BLANK_S BASE_ROW_VAL ("blank");
121 
122 
123 BASE_ROW_PREFIX const char *RO_ROW_TYPE_S BASE_ROW_VAL ("row_type");
124 
125 
126 
127 
128 #ifdef __cplusplus
129 extern "C"
130 {
131 #endif
132 
133 
134 
135 
136 
137 DFW_FIELD_TRIAL_SERVICE_LOCAL Row *AllocateDiscardRow (bson_oid_t *id_p, const uint32 study_index, Plot *parent_plot_p);
138 
139 
140 DFW_FIELD_TRIAL_SERVICE_LOCAL Row *AllocateBaseRow (bson_oid_t *id_p, const uint32 study_index, Plot *parent_plot_p, RowType rt,
141  void (*clear_fn) (Row *row_p),
142  bool (*add_to_json_fn) (const Row *row_p, json_t *row_json_p, const ViewFormat format, const FieldTrialServiceData *data_p),
143  bool (*add_from_json_fn) (Row *row_p, const json_t *row_json_p, const FieldTrialServiceData *data_p),
144  bool (*add_to_fd_fn) (const Row *row_p, json_t *row_fd_p, const FieldTrialServiceData *service_data_p, const char * const null_sequence_s));
145 
146 
147 DFW_FIELD_TRIAL_SERVICE_LOCAL bool InitRow (Row *row_p, bson_oid_t *id_p, const uint32 study_index, Plot *parent_plot_p, RowType rt,
148  void (*clear_fn) (Row *row_p),
149  bool (*add_to_json_fn) (const Row *row_p, json_t *row_json_p, const ViewFormat format, const FieldTrialServiceData *data_p),
150  bool (*add_from_json_fn) (Row *row_p, const json_t *row_json_p, const FieldTrialServiceData *data_p),
151  bool (*add_to_fd_fn) (const Row *row_p, json_t *row_fd_p, const FieldTrialServiceData *service_data_p, const char * const null_sequence_s));
152 
153 
155 
156 
158 
159 
161 
162 
164 
165 
166 
168 
169 
171 
172 
173 DFW_FIELD_TRIAL_SERVICE_LOCAL bool AddRowToJSON (const Row *row_p, json_t *row_json_p, const ViewFormat format, const FieldTrialServiceData *data_p);
174 
175 
176 DFW_FIELD_TRIAL_SERVICE_LOCAL Row *GetRowFromJSON (const json_t *json_p, Plot *plot_p, const Study *study_p, const ViewFormat format, FieldTrialServiceData *data_p);
177 
178 
179 DFW_FIELD_TRIAL_SERVICE_LOCAL bool PopulateRowFromJSON (Row *row_p, Plot *plot_p, const json_t *row_json_p, const ViewFormat format, FieldTrialServiceData *data_p);
180 
181 
182 DFW_FIELD_TRIAL_SERVICE_LOCAL json_t *GetRowAsJSON (const Row *row_p, const ViewFormat format, JSONProcessor *processor_p, const FieldTrialServiceData *data_p);
183 
184 
185 DFW_FIELD_TRIAL_SERVICE_LOCAL bool SetRowTypeFromJSON (RowType *rt_p, const json_t *row_json_p);
186 
187 
189 
190 
191 DFW_FIELD_TRIAL_SERVICE_LOCAL bool SetRowTypeFromString (RowType *rt_p, const char *value_s);
192 
193 
195  void (*clear_fn) (Row *row_p),
196  bool (*add_to_json_fn) (const Row *row_p, json_t *row_json_p, const ViewFormat format, const FieldTrialServiceData *data_p),
197  bool (*add_from_json_fn) (Row *row_p, const json_t *row_json_p, const FieldTrialServiceData *data_p),
198  bool (*add_to_fd_fn) (const Row *row_p, json_t *row_fd_p, const FieldTrialServiceData *service_data_p, const char * const null_sequence_s));
199 
200 
201 
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #endif /* SERVICES_FIELD_TRIALS_INCLUDE_BASE_ROW_H_ */
Plot
Definition: plot.h:84
RT_NUM_VALUES
The number of different values that a RowType can take.
Definition: row.h:47
SetRowType
void SetRowType(Row *row_p, RowType rt)
FreeRowNode
void FreeRowNode(ListItem *node_p)
BASE_ROW_VAL
const BASE_ROW_PREFIX char *RO_ID_S BASE_ROW_VAL("id")
Row::ro_add_to_json_fn
bool(* ro_add_to_json_fn)(const Row *row_p, json_t *row_json_p, const ViewFormat format, const FieldTrialServiceData *data_p)
Definition: row.h:72
JSONProcessor
Definition: json_processor.h:21
Row::ro_add_to_fd_fn
bool(* ro_add_to_fd_fn)(const Row *row_p, json_t *row_fd_p, const FieldTrialServiceData *service_data_p, const char *const null_sequence_s)
Definition: row.h:76
AddRowToJSON
bool AddRowToJSON(const Row *row_p, json_t *row_json_p, const ViewFormat format, const FieldTrialServiceData *data_p)
GetRowTypeAsString
const char * GetRowTypeAsString(const RowType rt)
dfw_field_trial_service_library.h
RT_DISCARD
A physical plot where no measurements are taken, just there as a physical spacer which will appear in...
Definition: row.h:35
FreeRow
void FreeRow(Row *row_p)
DFW_FIELD_TRIAL_SERVICE_LOCAL
#define DFW_FIELD_TRIAL_SERVICE_LOCAL
Definition: dfw_field_trial_service_library.h:43
AllocateRowNode
RowNode * AllocateRowNode(Row *row_p)
AllocateBaseRow
Row * AllocateBaseRow(bson_oid_t *id_p, const uint32 study_index, Plot *parent_plot_p, RowType rt, void(*clear_fn)(Row *row_p), bool(*add_to_json_fn)(const Row *row_p, json_t *row_json_p, const ViewFormat format, const FieldTrialServiceData *data_p), bool(*add_from_json_fn)(Row *row_p, const json_t *row_json_p, const FieldTrialServiceData *data_p), bool(*add_to_fd_fn)(const Row *row_p, json_t *row_fd_p, const FieldTrialServiceData *service_data_p, const char *const null_sequence_s))
RowType
RowType
Definition: row.h:24
Row::ro_plot_p
struct Plot * ro_plot_p
Definition: row.h:62
SetRowTypeFromJSON
bool SetRowTypeFromJSON(RowType *rt_p, const json_t *row_json_p)
SetRowTypeFromString
bool SetRowTypeFromString(RowType *rt_p, const char *value_s)
SetRowCallbackFunctions
void SetRowCallbackFunctions(Row *row_p, void(*clear_fn)(Row *row_p), bool(*add_to_json_fn)(const Row *row_p, json_t *row_json_p, const ViewFormat format, const FieldTrialServiceData *data_p), bool(*add_from_json_fn)(Row *row_p, const json_t *row_json_p, const FieldTrialServiceData *data_p), bool(*add_to_fd_fn)(const Row *row_p, json_t *row_fd_p, const FieldTrialServiceData *service_data_p, const char *const null_sequence_s))
Row::ro_by_study_index
uint32 ro_by_study_index
The unique index for this row within its parent study.
Definition: row.h:68
Row::ro_study_p
const struct Study * ro_study_p
Definition: row.h:60
RT_STANDARD
A normal plot which is part of an experiment.
Definition: row.h:29
PopulateRowFromJSON
bool PopulateRowFromJSON(Row *row_p, Plot *plot_p, const json_t *row_json_p, const ViewFormat format, FieldTrialServiceData *data_p)
InitRow
bool InitRow(Row *row_p, bson_oid_t *id_p, const uint32 study_index, Plot *parent_plot_p, RowType rt, void(*clear_fn)(Row *row_p), bool(*add_to_json_fn)(const Row *row_p, json_t *row_json_p, const ViewFormat format, const FieldTrialServiceData *data_p), bool(*add_from_json_fn)(Row *row_p, const json_t *row_json_p, const FieldTrialServiceData *data_p), bool(*add_to_fd_fn)(const Row *row_p, json_t *row_fd_p, const FieldTrialServiceData *service_data_p, const char *const null_sequence_s))
Row::ro_type
RowType ro_type
Definition: row.h:56
Row::ro_add_from_json_fn
bool(* ro_add_from_json_fn)(Row *row_p, const json_t *row_json_p, const FieldTrialServiceData *data_p)
Definition: row.h:74
Row::ro_clear_fn
void(* ro_clear_fn)(Row *row_p)
Definition: row.h:70
GetRowFromJSON
Row * GetRowFromJSON(const json_t *json_p, Plot *plot_p, const Study *study_p, const ViewFormat format, FieldTrialServiceData *data_p)
GetRowType
RowType GetRowType(const Row *row_p)
FieldTrialServiceData
The configuration data used by the DFW Field Trial Service.
Definition: dfw_field_trial_service_data.h:118
ViewFormat
ViewFormat
An indicator of what the output destination is for the JSON data values.
Definition: view_format.h:19
AllocateDiscardRow
Row * AllocateDiscardRow(bson_oid_t *id_p, const uint32 study_index, Plot *parent_plot_p)
RowNode::rn_node
ListItem rn_node
Definition: row.h:84
Row::ro_id_p
bson_oid_t * ro_id_p
Definition: row.h:58
GetRowAsJSON
json_t * GetRowAsJSON(const Row *row_p, const ViewFormat format, JSONProcessor *processor_p, const FieldTrialServiceData *data_p)
plot.h
RowNode
Definition: row.h:82
ClearRow
void ClearRow(Row *row_p)
Study
Definition: study.h:182
Row
Definition: row.h:54
RowNode::rn_row_p
Row * rn_row_p
Definition: row.h:86
RT_BLANK
Used to keep the stylised view when laying out the plots and you have non-regular gaps.
Definition: row.h:42
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43