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.
|
A Handler is a datatype for accessing data. More...
#include <handler.h>
Public Member Functions | |
void | InitialiseHandler (Handler *const handler_p, bool(*init_fn)(struct Handler *handler_p, const User *user_p), bool(*match_fn)(struct Handler *handler_p, const DataResource *resource_p), const char *(*get_protocol_fn)(struct Handler *handler_p), const char *(*get_name_fn)(struct Handler *handler_p), const char *(*get_description_fn)(struct Handler *handler_p), bool(*open_fn)(struct Handler *handler_p, DataResource *resource_p, MEM_FLAG resource_mem, const char *const mode_s), size_t(*read_fn)(struct Handler *handler_p, void *buffer_p, const size_t length), size_t(*write_fn)(struct Handler *handler_p, const void *buffer_p, const size_t length), bool(*seek_fn)(struct Handler *handler_p, long offset, int whence), bool(*close_fn)(struct Handler *handler_p), HandlerStatus(*status_fn)(struct Handler *handler_p), bool(*file_info_fn)(struct Handler *handler_p, FileInformation *info_p), void(*free_handler_fn)(struct Handler *handler_p)) |
Initialise a Handler from a loaded Plugin. More... | |
bool | InitHandler (struct Handler *handler_p, const User *user_p) |
Initialise a Handler ready for use. More... | |
bool | OpenHandler (struct Handler *handler_p, DataResource *resource_p, MEM_FLAG resource_mem, const char *const mode_s) |
Open a Resource with the Handler. More... | |
size_t | ReadFromHandler (struct Handler *handler_p, void *buffer_p, const size_t length) |
Read data from a Handler into a buffer. More... | |
size_t | WriteToHandler (struct Handler *handler_p, const void *buffer_p, const size_t length) |
Write data from a buffer into a Handler. More... | |
bool | SeekHandler (struct Handler *handler_p, size_t offset, int whence) |
Move a Handler to a new position in its stream. More... | |
bool | CloseHandler (struct Handler *handler_p) |
Close a Handler. More... | |
bool | IsHandlerForResource (struct Handler *handler_p, const DataResource *resource_p) |
Determine if the Handler is designed for a given Resource. More... | |
const char * | GetHandlerName (struct Handler *handler_p) |
Get the name of a Handler. More... | |
const char * | GetHandlerDescription (struct Handler *handler_p) |
Get the description of a Handler. More... | |
const char * | GetHandlerProtocol (struct Handler *handler_p) |
Get the protocol of a Handler. More... | |
HandlerStatus | GetHandlerStatus (struct Handler *handler_p) |
Get the HandlerStatus of a Handler. More... | |
bool | CalculateFileInformationFromHandler (struct Handler *handler_p, FileInformation *info_p) |
Calculate the FileInformation for the current Resource in use by a Handler. More... | |
void | FreeHandler (struct Handler *handler_p) |
Free a Handler. More... | |
Data Fields | |
struct Plugin * | ha_plugin_p |
The platform-specific plugin that the code for the Client is stored in. More... | |
bool(* | ha_init_fn )(struct Handler *handler_p, const User *user_p) |
Initialise a Handler ready for use. More... | |
bool(* | ha_match_fn )(struct Handler *handler_p, const DataResource *resource_p) |
Determine if the Handler is designed for a given Resource. More... | |
const char *(* | ha_get_protocol_fn )(struct Handler *handler_p) |
Get the protocol of a Handler. More... | |
const char *(* | ha_get_name_fn )(struct Handler *handler_p) |
Get the name of a Handler. More... | |
const char *(* | ha_get_description_fn )(struct Handler *handler_p) |
Get the description of a Handler. More... | |
bool(* | ha_open_fn )(struct Handler *handler_p, DataResource *resource_p, MEM_FLAG resource_mem, const char *const mode_s) |
Open a Resource with the Handler. More... | |
size_t(* | ha_read_fn )(struct Handler *handler_p, void *buffer_p, const size_t length) |
Read data from a Handler into a buffer. More... | |
size_t(* | ha_write_fn )(struct Handler *handler_p, const void *buffer_p, const size_t length) |
Write data from a buffer into a Handler. More... | |
bool(* | ha_seek_fn )(struct Handler *handler_p, long offset, int whence) |
Move a Handler to a new position in its stream. More... | |
bool(* | ha_close_fn )(struct Handler *handler_p) |
Close a Handler. More... | |
HandlerStatus(* | ha_status_fn )(struct Handler *handler_p) |
Get the HandlerStatus of a Handler. More... | |
bool(* | ha_file_info_fn )(struct Handler *handler_p, FileInformation *info_p) |
Calculate the FileInformation for the current Resource in use by a Handler. More... | |
void(* | ha_free_handler_fn )(struct Handler *handler_p) |
Free a Handler. More... | |
DataResource * | ha_resource_p |
The current Resource for this Handler. More... | |
MEM_FLAG | ha_resource_mem |
The MEM_FLAG for the Handler's Resource. More... | |
A Handler is a datatype for accessing data.
It is an abstraction of the common data input/output operations, e.g., opening and closing files, reading and writing data, etc. Any Grassroots component can use any Handler to access data without having to worry about the internals. So just by loading the appropriate Handler, a task can read data from a file, and iRODS data object, a webpage, etc. simply by using the Handler API.
void InitialiseHandler | ( | Handler *const | handler_p, |
bool(*)(struct Handler *handler_p, const User *user_p) | init_fn, | ||
bool(*)(struct Handler *handler_p, const DataResource *resource_p) | match_fn, | ||
const char *(*)(struct Handler *handler_p) | get_protocol_fn, | ||
const char *(*)(struct Handler *handler_p) | get_name_fn, | ||
const char *(*)(struct Handler *handler_p) | get_description_fn, | ||
bool(*)(struct Handler *handler_p, DataResource *resource_p, MEM_FLAG resource_mem, const char *const mode_s) | open_fn, | ||
size_t(*)(struct Handler *handler_p, void *buffer_p, const size_t length) | read_fn, | ||
size_t(*)(struct Handler *handler_p, const void *buffer_p, const size_t length) | write_fn, | ||
bool(*)(struct Handler *handler_p, long offset, int whence) | seek_fn, | ||
bool(*)(struct Handler *handler_p) | close_fn, | ||
HandlerStatus(*)(struct Handler *handler_p) | status_fn, | ||
bool(*)(struct Handler *handler_p, FileInformation *info_p) | file_info_fn, | ||
void(*)(struct Handler *handler_p) | free_handler_fn | ||
) |
Initialise a Handler from a loaded Plugin.
handler_p | The Handler to initialise. |
init_fn | The callback function to use for the Handler's ha_init_fn function. |
match_fn | The callback function to use for the Handler's ha_match_fn function. |
get_protocol_fn | The callback function to use for the Handler's ha_get_protocol_fn function. |
get_name_fn | The callback function to use for the Handler's ha_get_name_fn function. |
get_description_fn | The callback function to use for the Handler's ha_get_description_fn function. |
open_fn | The callback function to use for the Handler's ha_open_fn function. |
read_fn | The callback function to use for the Handler's ha_read_fn function. |
write_fn | The callback function to use for the Handler's ha_write_fn function. |
seek_fn | The callback function to use for the Handler's ha_seek_fn function. |
close_fn | The callback function to use for the Handler's ha_close_fn function. |
status_fn | The callback function to use for the Handler's ha_status_fn function. |
file_info_fn | The callback function to use for the Handler's ha_file_info_fn function. |
free_handler_fn | The callback function to use for the Handler's ha_free_handler_fn function. |
Initialise a Handler ready for use.
This is for when the Handler may need some custom initialisation e.g. permissions to be used.
handler_p | The Handler to initialise. |
user_p | The current user's details. This can be NULL . |
true
upon success, false
upon failure. bool OpenHandler | ( | struct Handler * | handler_p, |
DataResource * | resource_p, | ||
MEM_FLAG | resource_mem, | ||
const char *const | mode_s | ||
) |
Open a Resource with the Handler.
handler_p | The Handler to use |
resource_p | The Resource to use |
resource_mem | How the Handler will treat the Resource when the Handler is freed. |
mode_s | The mode to open with. This is the same as the mode used with the standard c library fopen. |
true
upon success, false
upon failure. size_t ReadFromHandler | ( | struct Handler * | handler_p, |
void * | buffer_p, | ||
const size_t | length | ||
) |
size_t WriteToHandler | ( | struct Handler * | handler_p, |
const void * | buffer_p, | ||
const size_t | length | ||
) |
bool SeekHandler | ( | struct Handler * | handler_p, |
size_t | offset, | ||
int | whence | ||
) |
Move a Handler to a new position in its stream.
This is equivalent to fseek in the standard c library.
handler_p | The Handler to alter. |
offset | The new position. |
whence | The reference position to use. These are the constants defined in <stdio.h>
|
true
upon success, false
upon failure. bool CloseHandler | ( | struct Handler * | handler_p | ) |
bool IsHandlerForResource | ( | struct Handler * | handler_p, |
const DataResource * | resource_p | ||
) |
const char * GetHandlerName | ( | struct Handler * | handler_p | ) |
const char * GetHandlerDescription | ( | struct Handler * | handler_p | ) |
const char * GetHandlerProtocol | ( | struct Handler * | handler_p | ) |
HandlerStatus GetHandlerStatus | ( | struct Handler * | handler_p | ) |
bool CalculateFileInformationFromHandler | ( | struct Handler * | handler_p, |
FileInformation * | info_p | ||
) |
Calculate the FileInformation for the current Resource in use by a Handler.
handler_p | The Handler to query. |
info_p | Pointer to where the FileInformation will be stored upon success. |
true
upon success, false
upon failure. void FreeHandler | ( | struct Handler * | handler_p | ) |
struct Plugin* ha_plugin_p |
The platform-specific plugin that the code for the Client is stored in.
bool(* ha_match_fn) (struct Handler *handler_p, const DataResource *resource_p) |
const char*(* ha_get_protocol_fn) (struct Handler *handler_p) |
const char*(* ha_get_name_fn) (struct Handler *handler_p) |
const char*(* ha_get_description_fn) (struct Handler *handler_p) |
bool(* ha_open_fn) (struct Handler *handler_p, DataResource *resource_p, MEM_FLAG resource_mem, const char *const mode_s) |
Open a Resource with the Handler.
handler_p | This Handler. |
resource_p | The Resource to use. |
resource_mem | How the Handler will treat the Resource when the Handler is freed. |
mode_s | The mode to open with. This is the same as the mode used with the standard c library fopen. |
true
upon success, false
upon failure. size_t(* ha_read_fn) (struct Handler *handler_p, void *buffer_p, const size_t length) |
size_t(* ha_write_fn) (struct Handler *handler_p, const void *buffer_p, const size_t length) |
bool(* ha_seek_fn) (struct Handler *handler_p, long offset, int whence) |
Move a Handler to a new position in its stream.
This is equivalent to fseek in the standard c library.
handler_p | This Handler. |
offset | The new position. |
whence | The reference position to use. These are the constants defined in <stdio.h>
|
true
upon success, false
upon failure. bool(* ha_close_fn) (struct Handler *handler_p) |
HandlerStatus(* ha_status_fn) (struct Handler *handler_p) |
bool(* ha_file_info_fn) (struct Handler *handler_p, FileInformation *info_p) |
Calculate the FileInformation for the current Resource in use by a Handler.
handler_p | This Handler. |
info_p | Pointer to where the FileInformation will be stored upon success. |
true
upon success, false
upon failure. void(* ha_free_handler_fn) (struct Handler *handler_p) |
DataResource* ha_resource_p |
The current Resource for this Handler.