linked_service.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 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 
21 /*
22  * linked_service.h
23  *
24  * Created on: 6 Sep 2016
25  * Author: tyrrells
26  */
27 
28 #ifndef SERVER_SRC_SERVICES_LIB_INCLUDE_LINKED_SERVICE_H_
29 #define SERVER_SRC_SERVICES_LIB_INCLUDE_LINKED_SERVICE_H_
30 
32 
33 #include "jansson.h"
34 
35 #include "linked_list.h"
36 #include "mapped_parameter.h"
37 #include "grassroots_server.h"
38 
39 /* forward declarations */
40 struct ServiceJob;
41 
42 
50 typedef struct LinkedService
51 {
58 
66 
67 
75  const char *ls_generate_fn_s;
76 
77 
78  char *ls_input_key_s;
79 
80  const json_t *ls_config_p;
81 
82  GrassrootsServer *ls_grassroots_p;
83 
85 
86 
94 typedef struct LinkedServiceNode
95 {
98 
102 
103 
104 #ifdef __cplusplus
105 extern "C"
106 {
107 #endif
108 
109 
121 GRASSROOTS_SERVICE_API LinkedService *AllocateLinkedService (const char *linked_service_s, const char *input_key_s, const json_t *mapped_params_json_p, const char * const function_s, const json_t *config_p, GrassrootsServer *grassroots_p);
122 
123 
131 GRASSROOTS_SERVICE_API LinkedService *CreateLinkedServiceFromJSON (struct Service *service_p, const json_t *linked_service_json_p, GrassrootsServer *grassroots_p);
132 
133 
134 
141 GRASSROOTS_SERVICE_API void FreeLinkedService (LinkedService *linked_service_p);
142 
143 
151 GRASSROOTS_SERVICE_API LinkedServiceNode *AllocateLinkedServiceNode (LinkedService *linked_service_p);
152 
153 
160 GRASSROOTS_SERVICE_API void FreeLinkedServiceNode (ListItem *node_p);
161 
162 
178 GRASSROOTS_SERVICE_API bool CreateAndAddMappedParameterToLinkedService (LinkedService *linked_service_p, const char *input_s, const char *output_s, bool required_flag, bool multi_flag);
179 
180 
189 GRASSROOTS_SERVICE_API bool AddMappedParameterToLinkedService (LinkedService *linked_service_p, struct MappedParameter *mapped_param_p);
190 
191 
192 
200 GRASSROOTS_SERVICE_API struct MappedParameter *GetMappedParameterByInputParamName (const LinkedService *linked_service_p, const char * const name_s);
201 
202 
210 GRASSROOTS_SERVICE_API json_t *GetLinkedServiceAsJSON (LinkedService *linked_service_p);
211 
212 
222 GRASSROOTS_SERVICE_API bool ProcessLinkedService (LinkedService *linked_service_p, struct ServiceJob *job_p);
223 
224 
235 GRASSROOTS_SERVICE_API bool AddLinkedServiceToRequestJSON (json_t *request_p, LinkedService *linked_service_p, ParameterSet *output_params_p);
236 
237 
238 
239 
240 GRASSROOTS_SERVICE_API bool RunCustomLinkedServiceGenerator (struct LinkedService *linked_service_p, json_t *data_p, struct ServiceJob *job_p);
241 
242 
243 #ifdef __cplusplus
244 }
245 #endif
246 
247 
248 #endif /* SERVER_SRC_SERVICES_LIB_INCLUDE_LINKED_SERVICE_H_ */
bool ProcessLinkedService(LinkedService *linked_service_p, struct ServiceJob *job_p)
Run a LinkedService.
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43
bool AddMappedParameterToLinkedService(LinkedService *linked_service_p, struct MappedParameter *mapped_param_p)
Add a MappedParameter to a LinkedService.
const char * ls_generate_fn_s
The name of the function that will get dynamically loaded from the Service's Plugin.
Definition: linked_service.h:75
json_t * GetLinkedServiceAsJSON(LinkedService *linked_service_p)
Get the JSON representation of a LinkedService.
struct MappedParameter * GetMappedParameterByInputParamName(const LinkedService *linked_service_p, const char *const name_s)
Get the MappedParameter with a given name from a LinkedService.
bool CreateAndAddMappedParameterToLinkedService(LinkedService *linked_service_p, const char *input_s, const char *output_s, bool required_flag, bool multi_flag)
Create and add a MappedParameter to a LinkedService.
void FreeLinkedServiceNode(ListItem *node_p)
Free a LinkedServiceNode and its associated LinkedService.
bool AddLinkedServiceToRequestJSON(json_t *request_p, LinkedService *linked_service_p, ParameterSet *output_params_p)
Add the details for how to run a LinkedService with a partially-filled in set of Parameters to a JSON...
LinkedList * ls_mapped_params_p
The list of MappedParameterNodes storing the information required to map values from the input Servic...
Definition: linked_service.h:65
A doubly-linked list.
A datatype which defines an available service, its capabilities and its parameters.
Definition: service.h:153
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
The datatype to allow the storage of LinkedServices on LinkedLists.
Definition: linked_service.h:94
LinkedServiceNode * AllocateLinkedServiceNode(LinkedService *linked_service_p)
Allocate a LinkedServiceNode to store a LinkedService on a LinkedList.
ListItem lsn_node
The base ListItem.
Definition: linked_service.h:97
void FreeLinkedService(LinkedService *linked_service_p)
Free a LinkedService.
A datatype to represent a running task.
Definition: service_job.h:72
LinkedService * AllocateLinkedService(const char *linked_service_s, const char *input_key_s, const json_t *mapped_params_json_p, const char *const function_s, const json_t *config_p, GrassrootsServer *grassroots_p)
Allocate a LinkedService.
LinkedService * lsn_linked_service_p
A pointer to the LinkedService.
Definition: linked_service.h:100
char * ls_output_service_s
The name of the Service whose input will be generated from the output of the Service that owns this L...
Definition: linked_service.h:57
Definition: grassroots_server.h:44
This structure is used to store a relationship between a value from the output of running one service...
Definition: mapped_parameter.h:52
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46
This datatype stores the data needed to get the required information from the output of one Service t...
Definition: linked_service.h:50
LinkedService * CreateLinkedServiceFromJSON(struct Service *service_p, const json_t *linked_service_json_p, GrassrootsServer *grassroots_p)
Create a new LinkedService from a JSON fragment.