ServersManager Struct Reference

A datatype for monitoring ExternalServers. More...

#include <servers_manager.h>

Inheritance diagram for ServersManager:
[legend]
Collaboration diagram for ServersManager:
[legend]

Public Member Functions

void InitServersManager (ServersManager *manager_p, int(*add_server_fn)(ServersManager *manager_p, ExternalServer *server_p, ExternalServerSerialiser serialise_fn), ExternalServer *(*get_server_fn)(ServersManager *manager_p, const char *const server_uri_s, ExternalServerDeserialiser deserialise_fn), ExternalServer *(*remove_server_fn)(ServersManager *manager_p, const char *const server_uri_s, ExternalServerDeserialiser deserialise_fn), LinkedList *(*get_all_servers_fn)(struct ServersManager *manager_p, ExternalServerDeserialiser deserialise_fn), void(*free_servers_manager_fn)(struct ServersManager *manager_p))
 Initialise a ServersManager. More...
 
int AddExternalServerToServersManager (ServersManager *manager_p, ExternalServer *server_p, ExternalServerSerialiser serialise_fn)
 Add an ExternalServer to the ServersManager. More...
 
ExternalServerGetExternalServerFromServersManager (ServersManager *manager_p, const char *const server_uri_s, ExternalServerDeserialiser deserialise_fn)
 Find a ExternalServer. More...
 
ExternalServerRemoveExternalServerFromServersManager (ServersManager *manager_p, const char *const server_uri_s, ExternalServerDeserialiser deserialise_fn)
 Remove a ExternalServer. More...
 
LinkedListGetAllExternalServersFromServersManager (ServersManager *manager_p, ExternalServerDeserialiser deserialise_fn)
 Get all ExternalServers. More...
 
void FreeServersManager (ServersManager *manager_p)
 Free a ServersManager. More...
 
json_t * AddExternalServerOperationsToJSON (ServersManager *manager_p, Operation op)
 Get the JSON fragment which will form part of a response to other servers and clients. More...
 

Data Fields

struct Pluginsm_plugin_p
 The plugin that thjs JobsManager was loaded from. More...
 
uuid_t sm_server_id
 The UUID for this Server. More...
 
char sm_server_id_s [UUID_STRING_BUFFER_SIZE]
 The UUID of this ExternalServer as a string. More...
 
int(* sm_add_server_fn )(struct ServersManager *manager_p, ExternalServer *server_p, ExternalServerSerialiser serialise_fn)
 Add an ExternalServer to the ServersManager. More...
 
ExternalServer *(* sm_get_server_fn )(struct ServersManager *manager_p, const char *const server_uri_s, ExternalServerDeserialiser deserialise_fn)
 Find an ExternalServer. More...
 
ExternalServer *(* sm_remove_server_fn )(struct ServersManager *manager_p, const char *const server_uri_s, ExternalServerDeserialiser deserialise_fn)
 Remove an ExternalServer. More...
 
LinkedList *(* sm_get_all_servers_fn )(struct ServersManager *manager_p, ExternalServerDeserialiser deserialise_fn)
 Get all ExternalServers. More...
 
void(* sm_free_servers_manager_fn )(struct ServersManager *manager_p)
 Free a given ServersManager. More...
 
LinkedList *(* sm_get_all_matching_servers_fn )(struct ServersManager *manager_p, const char *const local_service_name_s)
 Get a LinkedList of ExternalServerNodes that have a given Service. More...
 

Detailed Description

A datatype for monitoring ExternalServers.

A ServersManager is used to store details of the ExternalServers that are currently running on a Server. ExternalServers can be added, removed and searched for.

Member Function Documentation

◆ InitServersManager()

void InitServersManager ( ServersManager manager_p,
int(*)(ServersManager *manager_p, ExternalServer *server_p, ExternalServerSerialiser serialise_fn)  add_server_fn,
ExternalServer *(*)(ServersManager *manager_p, const char *const server_uri_s, ExternalServerDeserialiser deserialise_fn)  get_server_fn,
ExternalServer *(*)(ServersManager *manager_p, const char *const server_uri_s, ExternalServerDeserialiser deserialise_fn)  remove_server_fn,
LinkedList *(*)(struct ServersManager *manager_p, ExternalServerDeserialiser deserialise_fn)  get_all_servers_fn,
void(*)(struct ServersManager *manager_p)  free_servers_manager_fn 
)

Initialise a ServersManager.

Set up the callback functions for a given ServersManager.

Parameters
manager_pThe ServersManager to set up.
add_server_fnThe callback function to set for sm_add_server_fn for the given ServersManager.
get_server_fnThe callback function to set for sm_get_server_fn for the given ServersManager.
remove_server_fnThe callback function to set for sm_remove_server_fn for the given ServersManager.
get_all_servers_fnThe callback function to set for sm_get_all_servers_fn for the given ServersManager.
free_servers_manager_fnThe callback function to set for sm_free_servers_manager_fn for the given ServersManager.

◆ AddExternalServerToServersManager()

int AddExternalServerToServersManager ( ServersManager manager_p,
ExternalServer server_p,
ExternalServerSerialiser  serialise_fn 
)

Add an ExternalServer to the ServersManager.

Parameters
manager_pThe ServersManager to add the ExternalServer to.
server_pThe ExternalServer to add.
serialise_fnThe function used to serialise the ExternalServer into the unsigned char array which is the value stored in the ServersManager. If this is NULL then SerialiseExternalServerToJSON is used by default.
Returns
If 0, then the server was added successfully and can be freed. If 1 is returned then the server was added successfully and the ServersManager has taken ownership of the given ExternalServer and will take care of freeing it. Upon error, 1 will be returned.
See also
SerialiseExternalServerToJSON
sm_add_server_fn

◆ GetExternalServerFromServersManager()

ExternalServer * GetExternalServerFromServersManager ( ServersManager manager_p,
const char *const  server_uri_s,
ExternalServerDeserialiser  deserialise_fn 
)

Find a ExternalServer.

Get a previously-added ExternalServer. This is simply a convenience wrapper around sm_get_server_fn for the given ServersManager.

Parameters
manager_pThe ServersManager to search on.
server_uri_sThe uri for the ExternalServer to search for.
deserialise_fnThe function used to deserialise the data stored in this ServersManager to create ExternalServer. If this is NULL then DeserialiseExternalServerFromJSON is used by default.
Returns
A pointer to the matching ExternalServers or NULL if it could not be found.
See also
sm_get_server_fn

◆ RemoveExternalServerFromServersManager()

ExternalServer * RemoveExternalServerFromServersManager ( ServersManager manager_p,
const char *const  server_uri_s,
ExternalServerDeserialiser  deserialise_fn 
)

Remove a ExternalServer.

Remove a previously-added ExternalServer from the ServersManager. This is simply a convenience wrapper around sm_remove_server_fn for the given ServersManager.

Parameters
manager_pThe ServersManager to search on.
server_uri_sThe uri for the ExternalServer to search for.
deserialise_fnThe function used to deserialise the data stored in this ServersManager to create ExternalServer. If this is NULL then DeserialiseExternalServerFromJSON is used by default.
Returns
A pointer to the matching ExternalServers or NULL if it could not be found.
See also
sm_remove_server_fn

◆ GetAllExternalServersFromServersManager()

LinkedList * GetAllExternalServersFromServersManager ( ServersManager manager_p,
ExternalServerDeserialiser  deserialise_fn 
)

Get all ExternalServers.

Get a LinkedList of ExternalServerNodes for all active ExternalServers.

Parameters
manager_pThe ServersManager to remove the ExternalServer from.
deserialise_fnThe function used to deserialise the data stored in this ServersManager to create ExternalServer. If this is NULL then DeserialiseExternalServerFromJSON is used by default.
Returns
A LinkedList of const ExternalServerNodes or NULL if there are not any ExternalServers.
See also
sm_get_all_servers_fn

◆ FreeServersManager()

void FreeServersManager ( ServersManager manager_p)

Free a ServersManager.

Free a ServersManager and all of its associated ExternalServers.

Parameters
manager_pThe ServersManager to free.
See also
sm_free_servers_manager_fn

◆ AddExternalServerOperationsToJSON()

json_t * AddExternalServerOperationsToJSON ( ServersManager manager_p,
Operation  op 
)

Get the JSON fragment which will form part of a response to other servers and clients.

representing the capabilities available on for all available ExternalServers for a given Operation.

Parameters
manager_pThe ServersManager containing the details of all of the ExternalServers.
opThe Operation to get the available facilities for.
Returns
The JSON fragment containing all of the details or NULL upon error.

Field Documentation

◆ sm_plugin_p

struct Plugin* sm_plugin_p

The plugin that thjs JobsManager was loaded from.

◆ sm_server_id

uuid_t sm_server_id

The UUID for this Server.

◆ sm_server_id_s

char sm_server_id_s[UUID_STRING_BUFFER_SIZE]

The UUID of this ExternalServer as a string.

See also
sm_server_id

◆ sm_add_server_fn

int(* sm_add_server_fn) (struct ServersManager *manager_p, ExternalServer *server_p, ExternalServerSerialiser serialise_fn)

Add an ExternalServer to the ServersManager.

Parameters
manager_pThe ServersManager to add the ExternalServer to.
server_pThe ExternalServer to add.
serialise_fnThe function used to serialise the ExternalServer into the unsigned char array which is the value stored in the ServersManager. If this is NULL then SerialiseExternalServerToJSON is used by default.
Returns
If 0, then the server was added successfully and can be freed. If 1 is returned then the server was added successfully and the ServersManager has taken ownership of the given ExternalServer and will take care of freeing it. Upon error, 1 will be returned.
See also
SerialiseExternalServerToJSON

◆ sm_get_server_fn

ExternalServer*(* sm_get_server_fn) (struct ServersManager *manager_p, const char *const server_uri_s, ExternalServerDeserialiser deserialise_fn)

Find an ExternalServer.

Get a previously-added ExternalServer.

Parameters
manager_pThe ServersManager to add the ExternalServer to.
server_uri_sThe uri for the ExternalServer to search for.
deserialise_fnThe function used to deserialise the data stored in this ServersManager to create ExternalServer. If this is NULL then DeserialiseExternalServerFromJSON is used by default.
Returns
A pointer to the matching ExternalServer or NULL if it could not be found.
See also
GetExternalServerFromServersManager

◆ sm_remove_server_fn

ExternalServer*(* sm_remove_server_fn) (struct ServersManager *manager_p, const char *const server_uri_s, ExternalServerDeserialiser deserialise_fn)

Remove an ExternalServer.

Remove a previously-added ExternalServer.

Parameters
manager_pThe ServersManager to remove the ExternalServer from.
server_uri_sThe uri for the ExternalServer to search for.
deserialise_fnThe function used to deserialise the data stored in this ServersManager to create ExternalServer. If this is NULL then DeserialiseExternalServerFromJSON is used by default.
Returns
A pointer to the matching ExternalServer which will have been removed from the ServersManager or NULL if it could not be found.
See also
RemoveExternalServerFromServersManager

◆ sm_get_all_servers_fn

LinkedList*(* sm_get_all_servers_fn) (struct ServersManager *manager_p, ExternalServerDeserialiser deserialise_fn)

Get all ExternalServers.

Get a LinkedList of ExternalServerNodes for all active ExternalServers.

Parameters
manager_pThe ServersManager to remove the ExternalServer from.
deserialise_fnThe function used to deserialise the data stored in this ServersManager to create ExternalServer. If this is NULL then DeserialiseExternalServerFromJSON is used by default.
Returns
A LinkedList of ExternalServerNodes of all of the ExternalServers or NULL if there are not any.
See also
GetAllExternalServersFromServersManager

◆ sm_free_servers_manager_fn

void(* sm_free_servers_manager_fn) (struct ServersManager *manager_p)

Free a given ServersManager.

Parameters
manager_pThis ServersManager.

◆ sm_get_all_matching_servers_fn

LinkedList*(* sm_get_all_matching_servers_fn) (struct ServersManager *manager_p, const char *const local_service_name_s)

Get a LinkedList of ExternalServerNodes that have a given Service.

Parameters
manager_pThis ServersManager.
local_service_name_sThe name of the Service to match.
Returns
A LinkedList of ExternalServerNodes of all of the ExternalServers or NULL if there are not any.

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