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.
service_matcher.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 #ifndef SERVICE_MATCHER_H
22 #define SERVICE_MATCHER_H
23 
25 #include "data_resource.h"
26 #include "handler.h"
27 #include "service.h"
28 
29 struct ServiceMatcher;
30 
31 
33 typedef bool (*RunServiceMatcherCallback) (struct ServiceMatcher *matcher_p, Service *service_p);
34 
36 typedef void (*DestroyServiceMatcherCallback) (struct ServiceMatcher *matcher_p);
37 
38 
44 typedef struct ServiceMatcher
45 {
52 
60 
61 
69 typedef struct ResourceServiceMatcher
70 {
73 
76 
80 
81 
89 typedef struct NameServiceMatcher
90 {
93 
95  const char *nsm_service_name_s;
96 
98  const char *nsm_service_alias_s;
100 
101 
113 {
116 
118  const char *pnsm_plugin_name_s;
120 
121 
133 {
136 
140 
141 
149 typedef struct KeywordServiceMatcher
150 {
154 
155 
156 #ifdef __cplusplus
157 extern "C"
158 {
159 #endif
160 
161 
169 
179 AllocateResourceServiceMatcher(DataResource *resource_p, Handler *handler_p);
180 
181 
190 AllocateOperationNameServiceMatcher(const char *name_s, const char *alias_s);
191 
192 
201 AllocatePluginNameServiceMatcher(const char *plugin_name_s);
202 
203 
212 GRASSROOTS_SERVICE_MANAGER_API ServiceMatcher *AllocatePluginOperationNameServiceMatcher(const char *plugin_name_s, const char *service_name_s);
213 
214 
222 
223 
232 
233 
235 
236 GRASSROOTS_SERVICE_MANAGER_LOCAL void InitOperationNameServiceMatcher (NameServiceMatcher *matcher_p, const char *name_s, const char *alias_s);
237 
239 
240 
241 GRASSROOTS_SERVICE_MANAGER_LOCAL void InitPluginOperationNameServiceMatcher (PluginOperationNameServiceMatcher *matcher_p, const char *plugin_name_s, const char *operation_name_s);
242 
243 
245 
246 
255 
256 
265 
267 
269 
271 
273 
275 
277 
278 
285 
287 
289 
291 
293 
295 
296 
297 #ifdef __cplusplus
298 }
299 #endif
300 
301 #endif /* #ifndef SERVICE_MATCHER_H */
InitPluginOperationNameServiceMatcher
GRASSROOTS_SERVICE_MANAGER_LOCAL void InitPluginOperationNameServiceMatcher(PluginOperationNameServiceMatcher *matcher_p, const char *plugin_name_s, const char *operation_name_s)
ServiceMatcher::AllocateServiceMatcher
ServiceMatcher * AllocateServiceMatcher(void)
Allocate an empty ServiceMatcher.
KeywordServiceMatcher
A ServiceMatcher that will find any Service with a keyword parameter.
Definition: service_matcher.h:149
ResourceServiceMatcher
A ServiceMatcher that matches a Service if it can run on a given Resource.
Definition: service_matcher.h:69
ServiceMatcher::AllocateKeywordServiceMatcher
ServiceMatcher * AllocateKeywordServiceMatcher(void)
Allocate a KeywordServiceMatcher.
PluginNameServiceMatcher::SetPluginNameForServiceMatcher
void SetPluginNameForServiceMatcher(PluginNameServiceMatcher *matcher_p, const char *plugin_name_s)
Set the Plugin name to match for a PluginNameServiceMatcher.
FreePluginNameServiceMatcher
GRASSROOTS_SERVICE_MANAGER_LOCAL void FreePluginNameServiceMatcher(ServiceMatcher *matcher_p)
NameServiceMatcher
A ServiceMatcher that matches a Service by its name.
Definition: service_matcher.h:89
InitResourceServiceMatcher
GRASSROOTS_SERVICE_MANAGER_LOCAL void InitResourceServiceMatcher(ResourceServiceMatcher *matcher_p, DataResource *resource_p, Handler *handler_p)
service.h
NameServiceMatcher::nsm_service_name_s
const char * nsm_service_name_s
The name of the Service to match.
Definition: service_matcher.h:95
DataResource
A datatype representing a URI.
Definition: data_resource.h:40
grassroots_service_manager_library.h
handler.h
ServiceMatcher::AllocatePluginOperationNameServiceMatcher
ServiceMatcher * AllocatePluginOperationNameServiceMatcher(const char *plugin_name_s, const char *service_name_s)
Allocate a PluginOperationNameServiceMatcher.
ServiceMatcher
A datatype used to find any Services that match given criteria.
Definition: service_matcher.h:44
MatchServiceByPluginAndOperationsName
GRASSROOTS_SERVICE_MANAGER_LOCAL bool MatchServiceByPluginAndOperationsName(ServiceMatcher *matcher_p, Service *service_p)
PluginOperationNameServiceMatcher::ponsm_base_matcher
PluginNameServiceMatcher ponsm_base_matcher
The base matcher for matching by Plugin name.
Definition: service_matcher.h:135
ServiceMatcher::sm_destroy_fn
DestroyServiceMatcherCallback sm_destroy_fn
Callback to call when destroying a custom ServiceMatcher.
Definition: service_matcher.h:58
DestroyServiceMatcherCallback
void(* DestroyServiceMatcherCallback)(struct ServiceMatcher *matcher_p)
A callback function used to free a ServiceMatcher.
Definition: service_matcher.h:36
FreeKeywordServiceMatcher
GRASSROOTS_SERVICE_MANAGER_LOCAL void FreeKeywordServiceMatcher(ServiceMatcher *matcher_p)
FreePluginOperationNameServiceMatcher
GRASSROOTS_SERVICE_MANAGER_LOCAL void FreePluginOperationNameServiceMatcher(ServiceMatcher *matcher_p)
KeywordServiceMatcher::ksm_base_matcher
ServiceMatcher ksm_base_matcher
The base ServiceMatcher.
Definition: service_matcher.h:152
ServiceMatcher::AllocatePluginNameServiceMatcher
ServiceMatcher * AllocatePluginNameServiceMatcher(const char *plugin_name_s)
Allocate a PluginNameServiceMatcher.
NameServiceMatcher::nsm_base_matcher
ServiceMatcher nsm_base_matcher
The base matcher.
Definition: service_matcher.h:92
MatchServiceByResource
GRASSROOTS_SERVICE_MANAGER_LOCAL bool MatchServiceByResource(ServiceMatcher *matcher_p, Service *service_p)
NameServiceMatcher::nsm_service_alias_s
const char * nsm_service_alias_s
The alias of the Service to match.
Definition: service_matcher.h:98
ResourceServiceMatcher::rsm_base_matcher
ServiceMatcher rsm_base_matcher
The base matcher.
Definition: service_matcher.h:72
MatchServiceByPluginName
GRASSROOTS_SERVICE_MANAGER_LOCAL bool MatchServiceByPluginName(ServiceMatcher *matcher_p, Service *service_p)
Service
A datatype which defines an available service, its capabilities and its parameters.
Definition: service.h:153
ServiceMatcher::AllocateResourceServiceMatcher
ServiceMatcher * AllocateResourceServiceMatcher(DataResource *resource_p, Handler *handler_p)
Allocate a ResourceServiceMatcher.
PluginOperationNameServiceMatcher
A ServiceMatcher that matches a Service by its Plugin name and an Service name.
Definition: service_matcher.h:132
ResourceServiceMatcher::rsm_handler_p
Handler * rsm_handler_p
The Handler to access the Resource.
Definition: service_matcher.h:78
ServiceMatcher::RunServiceMatcher
bool RunServiceMatcher(ServiceMatcher *matcher_p, Service *service_p)
Run a ServiceMatcher on a given Service.
PluginNameServiceMatcher::pnsm_plugin_name_s
const char * pnsm_plugin_name_s
The name of the Service's Plugin to match.
Definition: service_matcher.h:118
GRASSROOTS_SERVICE_MANAGER_LOCAL
#define GRASSROOTS_SERVICE_MANAGER_LOCAL
Definition: grassroots_service_manager_library.h:47
InitOperationNameServiceMatcher
GRASSROOTS_SERVICE_MANAGER_LOCAL void InitOperationNameServiceMatcher(NameServiceMatcher *matcher_p, const char *name_s, const char *alias_s)
ServiceMatcher::InitServiceMatcher
GRASSROOTS_SERVICE_MANAGER_LOCAL void InitServiceMatcher(ServiceMatcher *matcher_p, RunServiceMatcherCallback match_fn)
Initialise a ServiceMatcher.
InitPluginNameServiceMatcher
GRASSROOTS_SERVICE_MANAGER_LOCAL void InitPluginNameServiceMatcher(PluginNameServiceMatcher *matcher_p, const char *plugin_name_s)
MatchServiceByKeyword
GRASSROOTS_SERVICE_MANAGER_LOCAL bool MatchServiceByKeyword(ServiceMatcher *matcher_p, Service *service_p)
ResourceServiceMatcher::rsm_resource_p
DataResource * rsm_resource_p
The Resource to test if a Service can operate upon.
Definition: service_matcher.h:75
FreeNameServiceMatcher
GRASSROOTS_SERVICE_MANAGER_LOCAL void FreeNameServiceMatcher(ServiceMatcher *matcher_p)
ServiceMatcher::sm_match_fn
RunServiceMatcherCallback sm_match_fn
Callback function to run against a given Service to see if is a match.
Definition: service_matcher.h:51
MatchServiceByNameOrAlias
GRASSROOTS_SERVICE_MANAGER_LOCAL bool MatchServiceByNameOrAlias(ServiceMatcher *matcher_p, Service *service_p)
FreeResourceServiceMatcher
GRASSROOTS_SERVICE_MANAGER_LOCAL void FreeResourceServiceMatcher(ServiceMatcher *matcher_p)
PluginNameServiceMatcher
A ServiceMatcher that matches a Service by its Plugin name.
Definition: service_matcher.h:112
ServiceMatcher::FreeServiceMatcher
void FreeServiceMatcher(ServiceMatcher *matcher_p)
Free a ServiceMatcher.
Handler
A Handler is a datatype for accessing data.
Definition: handler.h:72
RunServiceMatcherCallback
bool(* RunServiceMatcherCallback)(struct ServiceMatcher *matcher_p, Service *service_p)
A callback function used to run a ServiceMatcher.
Definition: service_matcher.h:33
InitKeywordServiceMatcher
GRASSROOTS_SERVICE_MANAGER_LOCAL void InitKeywordServiceMatcher(KeywordServiceMatcher *matcher_p)
GRASSROOTS_SERVICE_MANAGER_API
#define GRASSROOTS_SERVICE_MANAGER_API
Definition: grassroots_service_manager_library.h:46
PluginNameServiceMatcher::pnsm_base_matcher
ServiceMatcher pnsm_base_matcher
The base matcher.
Definition: service_matcher.h:115
PluginOperationNameServiceMatcher::ponsm_operation_name_s
const char * ponsm_operation_name_s
The Service name to match.
Definition: service_matcher.h:138
ServiceMatcher::AllocateOperationNameServiceMatcher
ServiceMatcher * AllocateOperationNameServiceMatcher(const char *name_s, const char *alias_s)
Allocate a NameServiceMatcher.
data_resource.h
MatchServiceByName
GRASSROOTS_SERVICE_MANAGER_LOCAL bool MatchServiceByName(ServiceMatcher *matcher_p, Service *service_p)