A datatype representing a URI. More...

#include <data_resource.h>

Public Member Functions

ResourceAllocateResource (const char *protocol_s, const char *value_s, const char *title_s)
 Allocate a Resource. More...
 
void InitResource (Resource *resource_p)
 Initialise a Resource ready for use. More...
 
void FreeResource (Resource *resource_p)
 Free a Resource and its associated data. More...
 
void ClearResource (Resource *resource_p)
 Clear a Resource. More...
 
bool SetResourceValue (Resource *resource_p, const char *protocol_s, const char *value_s, const char *title_s)
 Set the fields of a Resource. More...
 
bool SetResourceData (Resource *resource_p, json_t *data_p, const bool owns_data_flag)
 Set the json_t object of a Resource. More...
 
bool CopyResource (const Resource *const src_p, Resource *const dest_p)
 Copy the data from one Resource to another. More...
 
ResourceCloneResource (const Resource *const src_p)
 Clone the data from one Resource to another. More...
 
ResourceParseStringToResource (const char *const resource_s)
 Create a Resource from a given string. More...
 
bool GetResourceProtocolAndPath (const char *const resource_s, char **const path_ss, char **const protocol_ss)
 Get the protocol and path parts of a Resource. More...
 
json_t * GetResourceAsJSONByParts (const char *const protocol_s, const char *const path_s, const char *const title_s, json_t *data_p)
 Get the json representation of a Resource's fields. More...
 

Data Fields

char * re_protocol_s
 The protocol of this Resource. More...
 
char * re_value_s
 The protocol-specific path to the data object. More...
 
char * re_title_s
 An optional user-friendly name for this Resource. More...
 
json_t * re_data_p
 An optional set of json-based data for any application-specific configuration details. More...
 
bool re_owns_data_flag
 Does this Resource own any data pointed to by re_data_p? If so, it will delete re_data_p when this Resource is freed. More...
 
const char * RESOURCE_DELIMITER_S
 The string used to separate the protocol and values of a Resource. More...
 
const char * PROTOCOL_IRODS_S
 The protocol for a data object on an iRODS system. More...
 
const char * PROTOCOL_FILE_S
 The protocol for a data object for a mounted file. More...
 
const char * PROTOCOL_HTTP_S
 The protocol for a data object for a web address. More...
 
const char * PROTOCOL_HTTPS_S
 The protocol for a data object for a secure web address. More...
 
const char * PROTOCOL_INLINE_S
 The protocol for a data object stored within the Grassroots system inline. More...
 
const char * PROTOCOL_TEXT_S
 The protocol for a data object stored within the Grassroots system inline. More...
 
const char * PROTOCOL_SERVICE_S
 The protocol for a data object for a Grassroots Service. More...
 

Detailed Description

A datatype representing a URI.

This represents a URI to a particular data object. For example "http://grassroots.tgac.ac.uk" would have a protocol of "http" and a value of "grassroots.tgac.ac.uk". It can have a user-friendly title and an associated json object if needed.

Examples
long_running_service.c.

Member Function Documentation

◆ AllocateResource()

Resource * AllocateResource ( const char *  protocol_s,
const char *  value_s,
const char *  title_s 
)

Allocate a Resource.

Parameters
protocol_sThe protocol for the Resource. A deep copy will be made of this so the value passed in dose not need to remain in scope.
value_sThe value for the Resource. A deep copy will be made of this so the value passed in dose not need to remain in scope.
title_sThe title for the Resource. A deep copy will be made of this so the value passed in dose not need to remain in scope.
Returns
A newly-allocated Resource or NULL upon error.

◆ InitResource()

void InitResource ( Resource resource_p)

Initialise a Resource ready for use.

Parameters
resource_pThe Resource to initialise.

◆ FreeResource()

void FreeResource ( Resource resource_p)

Free a Resource and its associated data.

Parameters
resource_pThe Resource to free.

◆ ClearResource()

void ClearResource ( Resource resource_p)

Clear a Resource.

Clear and free any memory used for the Resource's fields and set them to NULL

Parameters
resource_pThe Resource to clear.

◆ SetResourceValue()

bool SetResourceValue ( Resource resource_p,
const char *  protocol_s,
const char *  value_s,
const char *  title_s 
)

Set the fields of a Resource.

Parameters
resource_pThe Resource to be updated.
protocol_sThe new value for the protocol for the Resource. A deep copy will be made of this so the value passed in dose not need to remain in scope. Any previous value will be freed.
value_sThe new value for the value for the Resource. A deep copy will be made of this so the value passed in dose not need to remain in scope. Any previous value will be freed.
title_sThe new value for the title for the Resource. A deep copy will be made of this so the value passed in dose not need to remain in scope. Any previous value will be freed.
Returns
true if the Resource was updated successfully, false otherwise.

◆ SetResourceData()

bool SetResourceData ( Resource resource_p,
json_t *  data_p,
const bool  owns_data_flag 
)

Set the json_t object of a Resource.

Parameters
resource_pThe Resource to set the data for.
data_pThe json_t object to add.
owns_data_flagIf this is true, then when this Resource is freed it will clear and free the given json_t object.
Returns
true if the Resource was updated successfully, false otherwise.

◆ CopyResource()

bool CopyResource ( const Resource *const  src_p,
Resource *const  dest_p 
)

Copy the data from one Resource to another.

This will make a deep copy of each field in the source Resource into the equivalent field in the destination Resource.

Parameters
src_pThe Resource to copy from.
dest_pThe Resource to copy to.
Returns
true if all of the fields were copied correctly, false otherwise. Upon failure, the destination Resource will remain unaltered.

◆ CloneResource()

Resource * CloneResource ( const Resource *const  src_p)

Clone the data from one Resource to another.

This will make new Resource and make a deep copy of each field in the source Resource into the equivalent field in the destination Resource.

Parameters
src_pThe Resource to copy from.
Returns
true if all of the fields were copied correctly, false otherwise. Upon failure, the destination Resource will remain unaltered.

◆ ParseStringToResource()

Resource * ParseStringToResource ( const char *const  resource_s)

Create a Resource from a given string.

This will take a string of the form <PROTOCOL>://<PATH> to generate a Resource.

Parameters
resource_sThe string representation of the Resource.
Returns
A newly-allocated Resource or NULL upon failure.
See also
PROTOCOL_IRODS_S
PROTOCOL_FILE_S
PROTOCOL_HTTP_S
PROTOCOL_HTTPS_S
PROTOCOL_INLINE_S
RESOURCE_DELIMITER_S

◆ GetResourceProtocolAndPath()

bool GetResourceProtocolAndPath ( const char *const  resource_s,
char **const  path_ss,
char **const  protocol_ss 
)

Get the protocol and path parts of a Resource.

Parameters
resource_sThe Resource to get the values from.
path_ssA pointer to where the path part of the Resource will be copied to. This will need to be freed with FreeCopiedString when it is finished with.
protocol_ssA pointer to where the protocol part of the Resource will be copied to. This will need to be freed with FreeCopiedString when it is finished with.
Returns
true if all of the fields were copied correctly, false otherwise. Upon failure, the destination path_ss and protocol_ss variables will remain unaltered.
See also
FreeCopiedString

◆ GetResourceAsJSONByParts()

json_t * GetResourceAsJSONByParts ( const char *const  protocol_s,
const char *const  path_s,
const char *const  title_s,
json_t *  data_p 
)

Get the json representation of a Resource's fields.

Parameters
protocol_sThe protocol of the Resource.
path_sThe path of the Resource.
title_sThe title of the Resource.
data_pThe associated json data of the Resource.
Returns
The json_t object representing the Resource or NULL upon failure.
Examples
long_running_service.c.

Field Documentation

◆ re_protocol_s

◆ re_value_s

char* re_value_s

The protocol-specific path to the data object.

◆ re_title_s

char* re_title_s

An optional user-friendly name for this Resource.

◆ re_data_p

json_t* re_data_p

An optional set of json-based data for any application-specific configuration details.

◆ re_owns_data_flag

bool re_owns_data_flag

Does this Resource own any data pointed to by re_data_p? If so, it will delete re_data_p when this Resource is freed.

◆ RESOURCE_DELIMITER_S

const char* RESOURCE_DELIMITER_S

The string used to separate the protocol and values of a Resource.

This is used to build string representations of the form <PROTOCOL><RESOURCE_DELIMITER_S><VALUE>

◆ PROTOCOL_IRODS_S

const char* PROTOCOL_IRODS_S

The protocol for a data object on an iRODS system.

◆ PROTOCOL_FILE_S

const char* PROTOCOL_FILE_S

The protocol for a data object for a mounted file.

◆ PROTOCOL_HTTP_S

const char* PROTOCOL_HTTP_S

The protocol for a data object for a web address.

◆ PROTOCOL_HTTPS_S

const char* PROTOCOL_HTTPS_S

The protocol for a data object for a secure web address.

◆ PROTOCOL_INLINE_S

const char* PROTOCOL_INLINE_S

The protocol for a data object stored within the Grassroots system inline.

Examples
long_running_service.c.

◆ PROTOCOL_TEXT_S

const char* PROTOCOL_TEXT_S

The protocol for a data object stored within the Grassroots system inline.

◆ PROTOCOL_SERVICE_S

const char* PROTOCOL_SERVICE_S

The protocol for a data object for a Grassroots Service.


The documentation for this struct was generated from the following file: