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.
location.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  * location.h
18  *
19  * Created on: 11 Sep 2018
20  * Author: billy
21  */
22 
23 #ifndef SERVICES_FIELD_TRIALS_INCLUDE_LOCATION_H_
24 #define SERVICES_FIELD_TRIALS_INCLUDE_LOCATION_H_
25 
26 #include "study.h"
27 #include "jansson.h"
28 
29 #include "address.h"
30 
31 struct Study;
32 
33 typedef enum
34 {
39 } LocationType;
40 
41 
42 
43 
44 
45 typedef struct Location
46 {
47  bson_oid_t *lo_id_p;
48 
49  uint32 lo_order;
50 
51  char *lo_soil_s;
52 
53  double64 *lo_min_ph_p;
54 
55  double64 *lo_max_ph_p;
56 
58 
60 } Location;
61 
62 
63 typedef struct LocationNode
64 {
66 
68 } LocationNode;
69 
70 
71 #ifndef DOXYGEN_SHOULD_SKIP_THIS
72 
73 #ifdef ALLOCATE_LOCATION_TAGS
74  #define LOCATION_PREFIX DFW_FIELD_TRIAL_SERVICE_LOCAL
75  #define LOCATION_VAL(x) = x
76  #define LOCATION_CONCAT_VAL(x,y) = x y
77 #else
78  #define LOCATION_PREFIX extern
79  #define LOCATION_VAL(x)
80  #define LOCATION_CONCAT_VAL(x,y)
81 #endif
82 
83 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
84 
85 
86 
87 
88 /* Location */
89 
90 
91 
92 LOCATION_PREFIX const char *LO_ADDRESS_S LOCATION_VAL ("address");
93 
94 LOCATION_PREFIX const char *LO_ORDER_S LOCATION_VAL ("order");
95 
96 LOCATION_PREFIX const char *LO_NAME_S LOCATION_VAL ("name");
97 
98 
99 LOCATION_PREFIX const char *LO_SOIL_S LOCATION_VAL ("soil");
100 
101 
102 LOCATION_PREFIX const char *LO_MIN_PH_S LOCATION_VAL ("min_ph");
103 
104 LOCATION_PREFIX const char *LO_MAX_PH_S LOCATION_VAL ("max_ph");
105 
106 LOCATION_PREFIX const char *LO_TYPE_S LOCATION_VAL ("type");
107 
108 LOCATION_PREFIX const char *LT_FARM_S LOCATION_VAL ("farm");
109 
110 LOCATION_PREFIX const char *LT_SITE_S LOCATION_VAL ("site");
111 
112 LOCATION_PREFIX const char *LT_UNKNOWN_S LOCATION_VAL ("unknown");
113 
114 
115 
116 
117 #ifdef __cplusplus
118 extern "C"
119 {
120 #endif
121 
122 
123 
124 DFW_FIELD_TRIAL_SERVICE_LOCAL Location *AllocateLocation (Address *address_p, const uint32 order, const char *soil_s, const double64 *min_ph_p, const double64 *max_ph_p, const LocationType loc_type, bson_oid_t *id_p);
125 
126 
128 
129 
130 
132 
133 
135 
136 
138 
139 
140 DFW_FIELD_TRIAL_SERVICE_LOCAL Location *GetLocationFromJSON (const json_t *location_json_p, const FieldTrialServiceData *data_p);
141 
142 
144 
145 
146 DFW_FIELD_TRIAL_SERVICE_LOCAL Location *GetLocationById (bson_oid_t *id_p, const ViewFormat format, const FieldTrialServiceData *data_p);
147 
148 
149 DFW_FIELD_TRIAL_SERVICE_LOCAL Location *GetLocationByIdString (const char *location_id_s, const ViewFormat format, const FieldTrialServiceData *data_p);
150 
151 
152 DFW_FIELD_TRIAL_SERVICE_LOCAL Location *GetUniqueLocationBySearchString (const char *location_s, const ViewFormat format, const FieldTrialServiceData *data_p);
153 
154 
156 
157 
159 
160 
162 
163 
164 DFW_FIELD_TRIAL_SERVICE_LOCAL bool GetLocationTypeFromString (const char *loc_type_s, LocationType *loc_type_p);
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 
171 #endif /* SERVICES_FIELD_TRIALS_INCLUDE_LOCATION_H_ */
GetLocationById
Location * GetLocationById(bson_oid_t *id_p, const ViewFormat format, const FieldTrialServiceData *data_p)
GetLocationFromJSON
Location * GetLocationFromJSON(const json_t *location_json_p, const FieldTrialServiceData *data_p)
study.h
ServiceJob
A datatype to represent a running task.
Definition: service_job.h:72
FreeLocationNode
void FreeLocationNode(ListItem *node_p)
GetLocationTypeFromString
bool GetLocationTypeFromString(const char *loc_type_s, LocationType *loc_type_p)
Location::lo_order
uint32 lo_order
Definition: location.h:49
Location::lo_id_p
bson_oid_t * lo_id_p
Definition: location.h:47
SaveLocation
OperationStatus SaveLocation(Location *location_p, ServiceJob *job_p, FieldTrialServiceData *data_p)
Location::lo_soil_s
char * lo_soil_s
Definition: location.h:51
LocationNode
Definition: location.h:63
address.h
LocationType
LocationType
Definition: location.h:33
DFW_FIELD_TRIAL_SERVICE_LOCAL
#define DFW_FIELD_TRIAL_SERVICE_LOCAL
Definition: dfw_field_trial_service_library.h:43
GetLocationAsJSON
json_t * GetLocationAsJSON(Location *location_p)
LT_NUM_TYPES
Definition: location.h:38
Location::lo_min_ph_p
double64 * lo_min_ph_p
Definition: location.h:53
GetLocationsByName
LinkedList * GetLocationsByName(FieldTrialServiceData *data_p, const char *location_s)
Location::lo_type
LocationType lo_type
Definition: location.h:57
Address
A datatype for storing a postal address as well as its geographic coordinates if possible.
Definition: address.h:21
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
LocationNode::ln_node
ListItem ln_node
Definition: location.h:65
Location::lo_address_p
Address * lo_address_p
Definition: location.h:59
LT_FARM
Definition: location.h:36
LOCATION_VAL
const LOCATION_PREFIX char *LO_ADDRESS_S LOCATION_VAL("address")
OperationStatus
OperationStatus
The current status of an Operation.
Definition: operation.h:96
LT_SITE
Definition: location.h:37
GetUniqueLocationBySearchString
Location * GetUniqueLocationBySearchString(const char *location_s, const ViewFormat format, const FieldTrialServiceData *data_p)
LT_UNKNOWN
Definition: location.h:35
FreeLocation
void FreeLocation(Location *location_p)
AllocateLocation
Location * AllocateLocation(Address *address_p, const uint32 order, const char *soil_s, const double64 *min_ph_p, const double64 *max_ph_p, const LocationType loc_type, bson_oid_t *id_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
LocationNode::ln_location_p
Location * ln_location_p
Definition: location.h:67
GetLocationAsString
char * GetLocationAsString(const Location *location_p)
GetLocationTypeAsString
const char * GetLocationTypeAsString(const LocationType loc_type)
Location
Definition: location.h:45
GetLocationByIdString
Location * GetLocationByIdString(const char *location_id_s, const ViewFormat format, const FieldTrialServiceData *data_p)
Study
Definition: study.h:182
AllocateLocationNode
LocationNode * AllocateLocationNode(Location *location_p)
Location::lo_max_ph_p
double64 * lo_max_ph_p
Definition: location.h:55
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43