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.
plugin.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 
24 #ifndef PLUGIN_H
25 #define PLUGIN_H
26 
27 #include "typedefs.h"
29 #include "linked_list.h"
30 #include "memory_allocations.h"
31 
32 
33 #ifdef __cplusplus
34  extern "C" {
35 #endif
36 
37 
38 /*********** FORWARD DECLARATION ****************/
39 struct ServicesArray;
40 struct Client;
41 struct Handler;
42 struct JobsManager;
43 struct GrassrootsServer;
44 
50 typedef enum PluginStatus
51 {
54 
57 
60 
63 
64 } PluginStatus;
65 
66 
72 typedef enum PluginNature
73 {
75  PN_UNKNOWN = -1,
76 
79 
82 
85 
88 
91 
94 } PluginNature;
95 
96 
101 typedef union PluginValue
102 {
108 
113  struct Client *pv_client_p;
114 
120 
121 
127 
128 
134 
135 } PluginValue;
136 
137 
138 
139 
150 typedef struct Plugin
151 {
155  char *pl_path_s;
156 
162 
166  char *pl_name_s;
167 
172 
177 
182 
187 
188 
190 } Plugin;
191 
192 
193 
202 typedef struct PluginListNode
203 {
206 
209 
213 
214 
215 /***********************************/
216 /********** API METHODS **********/
217 /***********************************/
218 
219 
220 
231 GRASSROOTS_PLUGIN_API const char *GetPluginConfigName (const Plugin * const plugin_p);
232 
245 GRASSROOTS_PLUGIN_API Plugin *AllocatePlugin (const char * const path_s, struct GrassrootsServer *server_p);
246 
247 
255 GRASSROOTS_PLUGIN_API void FreePlugin (Plugin * const plugin_p);
256 
257 
271 GRASSROOTS_PLUGIN_API bool OpenPlugin (Plugin * const plugin_p);
272 
273 
283 GRASSROOTS_PLUGIN_API void ClosePlugin (Plugin * const plugin_p);
284 
285 
296 GRASSROOTS_PLUGIN_API void *GetSymbolFromPlugin (Plugin *plugin_p, const char * const symbol_s);
297 
298 
307 
308 
316 
317 
331 GRASSROOTS_PLUGIN_API char *DeterminePluginName (const char * const full_plugin_path_s);
332 
333 
344 GRASSROOTS_PLUGIN_API char *MakePluginName (const char * const name_s);
345 
346 
347 
355 
356 
365 
366 
373 GRASSROOTS_PLUGIN_API void ClearPluginValue (Plugin * const plugin_p);
374 
375 
376 /***********************************/
377 /********* LOCAL METHODS *********/
378 /***********************************/
379 
380 
381 GRASSROOTS_PLUGIN_LOCAL bool InitBasePlugin (Plugin * const plugin_p, const char * const path_p, struct GrassrootsServer *server_p);
382 
383 GRASSROOTS_PLUGIN_LOCAL void ClearBasePlugin (Plugin * const plugin_p);
384 
385 
386 GRASSROOTS_PLUGIN_LOCAL void ClearPluginPath (Plugin * const plugin_p);
387 
388 
389 #ifdef __cplusplus
390 }
391 #endif
392 
393 #endif /* #ifndef PLUGIN_H */
Plugin::pl_name_s
char * pl_name_s
A multi-platform name for the Plugin.
Definition: plugin.h:166
PluginValue::pv_client_p
struct Client * pv_client_p
If pl_type is PN_CLIENT then this will point to a valid Client.
Definition: plugin.h:113
Plugin::ClearPluginValue
GRASSROOTS_PLUGIN_API void ClearPluginValue(Plugin *const plugin_p)
Clear all values in a given Plugin ready for it to be reused.
ServersManager
A datatype for monitoring ExternalServers.
Definition: servers_manager.h:141
Plugin::FreePlugin
GRASSROOTS_PLUGIN_API void FreePlugin(Plugin *const plugin_p)
Free a Plugin.
PluginStatus
PluginStatus
The current status of a Plugin.
Definition: plugin.h:50
PN_UNKNOWN
Unknown type of Plugin.
Definition: plugin.h:75
ClearPluginPath
GRASSROOTS_PLUGIN_LOCAL void ClearPluginPath(Plugin *const plugin_p)
PN_CLIENT
The Plugin creates a Client.
Definition: plugin.h:81
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
Plugin::pl_server_p
struct GrassrootsServer * pl_server_p
Definition: plugin.h:189
PS_CLOSING
Plugin is in the process of closing.
Definition: plugin.h:62
PluginValue
A union datatype that abstracts the different types of plugins that are avaialble.
Definition: plugin.h:101
Plugin::IncrementPluginOpenCount
GRASSROOTS_PLUGIN_API void IncrementPluginOpenCount(Plugin *plugin_p)
Increment the number of objects that this Plugin has open.
Plugin::ClosePlugin
GRASSROOTS_PLUGIN_API void ClosePlugin(Plugin *const plugin_p)
Close a Plugin.
JobsManager
A datatype for monitoring ServiceJobs.
Definition: jobs_manager.h:98
GRASSROOTS_PLUGIN_API
#define GRASSROOTS_PLUGIN_API
Definition: grassroots_plugin_library.h:46
PluginListNode::pln_plugin_flag
MEM_FLAG pln_plugin_flag
How the memory for the Plugin is stored and freed.
Definition: plugin.h:211
PN_HANDLER
The Plugin creates a Handler.
Definition: plugin.h:84
Plugin::OpenPlugin
GRASSROOTS_PLUGIN_API bool OpenPlugin(Plugin *const plugin_p)
Open a Plugin in preparation for getting the actual component.
PluginValue::pv_services_p
struct ServicesArray * pv_services_p
If pl_type is PN_SERVICE then this will point to a ServicesArray of Services available.
Definition: plugin.h:107
PN_JOBS_MANAGER
The Plugin creates a JobsManager.
Definition: plugin.h:87
PS_UNAVAILABLE
Plugin of this type failed to previously load.
Definition: plugin.h:59
PluginValue::pv_servers_manager_p
struct ServersManager * pv_servers_manager_p
If pl_type is PN_SERVERS_MANAGER then this will point to a valid JobsManager.
Definition: plugin.h:133
Plugin::AllocatePlugin
GRASSROOTS_PLUGIN_API Plugin * AllocatePlugin(const char *const path_s, struct GrassrootsServer *server_p)
The following functions are platform-specific.
Plugin::MakePluginName
GRASSROOTS_PLUGIN_API char * MakePluginName(const char *const name_s)
Make the platform-specific filename for a given Plugin name.
ServicesArray
A datatype for having a set of Services.
Definition: service.h:422
typedefs.h
PluginListNode::pln_plugin_p
Plugin * pln_plugin_p
The plugin.
Definition: plugin.h:208
Plugin::pl_path_mem
MEM_FLAG pl_path_mem
Memory ownership of the path variable.
Definition: plugin.h:161
PN_SERVERS_MANAGER
The Plugin creates a ServersManager.
Definition: plugin.h:90
grassroots_plugin_library.h
PS_UNSET
No attempt to load a plugin of this type yet.
Definition: plugin.h:53
Plugin
A Plugin is a dynamically-loaded component to provide a piece of functionality.
Definition: plugin.h:150
Plugin::GetPluginConfigName
const GRASSROOTS_PLUGIN_API char * GetPluginConfigName(const Plugin *const plugin_p)
Get the string with the platform-specific plugin parts e.g.
Plugin::DeterminePluginName
GRASSROOTS_PLUGIN_API char * DeterminePluginName(const char *const full_plugin_path_s)
Get the platform-independent Plugin name from a platform-specific filename possibly spanning multiple...
Plugin::pl_value
PluginValue pl_value
The data specific for the PluginNature of this Plugin.
Definition: plugin.h:181
PN_NUM_TYPES
The number of different PluginTypes.
Definition: plugin.h:93
GrassrootsServer
Definition: grassroots_server.h:45
InitBasePlugin
GRASSROOTS_PLUGIN_LOCAL bool InitBasePlugin(Plugin *const plugin_p, const char *const path_p, struct GrassrootsServer *server_p)
GRASSROOTS_PLUGIN_LOCAL
#define GRASSROOTS_PLUGIN_LOCAL
Definition: grassroots_plugin_library.h:47
PluginListNode::FreePluginListNode
GRASSROOTS_PLUGIN_API void FreePluginListNode(ListItem *const node_p)
Free a PluginListNode.
Plugin::pl_path_s
char * pl_path_s
The path of the plugin.
Definition: plugin.h:155
Plugin::GetSymbolFromPlugin
GRASSROOTS_PLUGIN_API void * GetSymbolFromPlugin(Plugin *plugin_p, const char *const symbol_s)
Get a symbol from a Plugin.
memory_allocations.h
linked_list.h
A doubly-linked list.
Plugin::pl_type
PluginNature pl_type
The type of this Plugin e.g.
Definition: plugin.h:176
Plugin::DecrementPluginOpenCount
GRASSROOTS_PLUGIN_API void DecrementPluginOpenCount(Plugin *plugin_p)
Decrement the number of objects that this Plugin has open.
PluginListNode::AllocatePluginListNode
GRASSROOTS_PLUGIN_API PluginListNode * AllocatePluginListNode(Plugin *const plugin_p)
Create a new PluginListNode.
Handler
A Handler is a datatype for accessing data.
Definition: handler.h:72
PN_SERVICE
The Plugin creates a Service.
Definition: plugin.h:78
PluginNature
PluginNature
The type of module that the Plugin contains.
Definition: plugin.h:72
PluginValue::pv_jobs_manager_p
struct JobsManager * pv_jobs_manager_p
If pl_type is PN_JOBS_MANAGER then this will point to a valid JobsManager.
Definition: plugin.h:126
PS_LOADED
Plugin of this type has been loaded successfully.
Definition: plugin.h:56
ClearBasePlugin
GRASSROOTS_PLUGIN_LOCAL void ClearBasePlugin(Plugin *const plugin_p)
PluginValue::pv_handler_p
struct Handler * pv_handler_p
If pl_type is PN_HANDLER then this will point to a valid Handler.
Definition: plugin.h:119
PluginListNode
A ListNode for LinkedLists that also stores a plugin value.
Definition: plugin.h:202
Plugin::pl_open_count
int32 pl_open_count
The count of how many current tasks have this Plugin open.
Definition: plugin.h:186
Plugin::pl_status
PluginStatus pl_status
The current status of the Plugin.
Definition: plugin.h:171
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43
PluginListNode::pln_node
ListItem pln_node
The ListNode.
Definition: plugin.h:205