ZOO-Project
Functions
service.c File Reference
#include "service.h"

Functions

void _dumpMap (map *t)
 Dump a map on stderr. More...
 
void dumpMap (map *t)
 Dump a map on stderr, see _dumpMap() More...
 
void dumpMapToFile (map *t, FILE *file)
 Dump a map to a file. More...
 
void dumpMaps (maps *m)
 Dump a maps on stderr, see dumpMap(). More...
 
void _dumpMapsToFile (maps *m, FILE *file, int limit)
 Dump a maps to a file, see dumpMapToFile(). More...
 
void dumpMapsToFile (maps *m, char *file_path, int limit)
 Dump a maps to a file, see _dumpMapsToFile(). More...
 
mapcreateMap (const char *name, const char *value)
 Create a new map. More...
 
mapscreateMaps (const char *name)
 Create a new maps with the given name. More...
 
int count (map *m)
 Count number of map in a map. More...
 
bool hasKey (map *m, const char *key)
 Verify if a key exist in a map. More...
 
mapsgetMaps (maps *m, const char *key)
 Access a specific maps. More...
 
mapgetMap (map *m, const char *key)
 Access a specific map. More...
 
mapgetLastMap (map *m)
 Access the last map. More...
 
mapgetMapFromMaps (maps *m, const char *key, const char *subkey)
 Access a specific map from a maps. More...
 
void freeMap (map **mo)
 Free allocated memory of a map. More...
 
void freeMaps (maps **mo)
 Free allocated memory of a maps. More...
 
bool hasElement (elements *e, const char *key)
 Verify if an elements contains a name equal to the given key. More...
 
elementsgetElements (elements *m, char *key)
 Access a specific elements named key. More...
 
void freeIOType (iotype **i)
 Free allocated memory of an iotype. More...
 
void freeElements (elements **e)
 Free allocated memory of an elements. More...
 
void freeService (service **s)
 Free allocated memory of a service. More...
 
void addToMap (map *m, const char *n, const char *v)
 Add key value pair to an existing map. More...
 
void addIntToMap (map *m, const char *n, const int v)
 Add a key and an integer value to an existing map. More...
 
mapaddToMapWithSize (map *m, const char *n, const char *v, int size)
 Add a key and a binary value to an existing map. More...
 
void addMapToMap (map **mo, map *mi)
 Add a map at the end of another map. More...
 
void addMapToIoType (iotype **io, map *mi)
 Add a map to iotype. More...
 
mapgetMapOrFill (map **m, const char *key, const char *value)
 Access a specific map or set its value. More...
 
bool contains (map *m, map *i)
 Verify if a map is contained in another map. More...
 
iotypegetIoTypeFromElement (elements *e, char *name, map *values)
 Access a specific iotype from an elements. More...
 
void loadMapBinary (map **out, map *in, int pos)
 Load binary values from a map (in) and add them to another map (out) More...
 
void loadMapBinaries (map **out, map *in)
 Load binary values from a map (in) and add them to another map (out). More...
 
mapsdupMaps (maps **mo)
 Duplicate a Maps. More...
 
void addMapsToMaps (maps **mo, maps *mi)
 Add a maps at the end of another maps. More...
 
mapgetMapArray (map *m, const char *key, int index)
 Access a specific map array element. More...
 
void setMapArray (map *m, const char *key, int index, const char *value)
 Add a key value in a MapArray for a specific index. More...
 
mapgetMapType (map *mt)
 Access the map "type". More...
 
int addMapsArrayToMaps (maps **mo, maps *mi, char *typ)
 Add a Maps containing a MapArray to a Maps. More...
 
void setMapInMaps (maps *m, const char *key, const char *subkey, const char *value)
 Set a key value pair to a map contained in a Maps. More...
 
elementscreateEmptyElements ()
 Create an empty elements. More...
 
elementscreateElements (char *name)
 Create a named elements. More...
 
void setElementsName (elements **elem, char *name)
 Set the name of an elements. More...
 
void dumpElements (elements *e)
 Dump an elements on stderr. More...
 
void dumpElementsAsYAML (elements *e, int level)
 Dump an elements on stderr using the YAML syntaxe. More...
 
elementsdupElements (elements *e)
 Duplicate an elements. More...
 
void addToElements (elements **m, elements *e)
 Add an elements to another elements. More...
 
void setServiceName (service **serv, char *name)
 Set the name of a service. More...
 
void dumpService (service *s)
 Dump a service on stderr. More...
 
void dumpServiceAsYAML (service *s)
 Dump a service on stderr using the YAML syntaxe. More...
 
servicedupService (service *s)
 Duplicate a service. More...
 
void dumpRegistry (registry *r)
 Print the registry on stderr. More...
 
bool addServiceToRegistry (registry **reg, char *name, service *content)
 Add a service to the registry. More...
 
void freeRegistry (registry **r)
 Free memory allocated for the registry. More...
 
servicegetServiceFromRegistry (registry *r, char *level, char *sname)
 Access a service in the registry. More...
 
void inheritMap (map **out, map *in)
 Apply inheritance to an out map from a reference in map. More...
 
void inheritIOType (iotype **out, iotype *in)
 Apply inheritance to an out iotype from a reference in iotype. More...
 
void inheritElements (elements **out, elements *in)
 Apply inheritance to an out elements from a reference in elements. More...
 
void inheritance (registry *r, service **s)
 Apply inheritance to a service based on a registry. More...
 
void mapsToCharXXX (maps *m, char ***c)
 Convert a maps to a char*** (only used for Fortran support) More...
 
void charxxxToMaps (char ***c, maps **m)
 Convert a char*** to a maps (only used for Fortran support) More...
 

Function Documentation

void _dumpMap ( map t)

Dump a map on stderr.

Parameters
tthe map to dump
void _dumpMapsToFile ( maps m,
FILE *  file,
int  limit 
)

Dump a maps to a file, see dumpMapToFile().

Parameters
mthe map to dump
filethe the file pointer to store the map
void addIntToMap ( map m,
const char *  n,
const int  v 
)

Add a key and an integer value to an existing map.

Parameters
mthe map to add the KVP
nthe key to add
vthe corresponding value to add
int addMapsArrayToMaps ( maps **  mo,
maps mi,
char *  typ 
)

Add a Maps containing a MapArray to a Maps.

See also
getMapType
Parameters
mothe maps
mithe maps
typthe map "type"
Returns
void addMapsToMaps ( maps **  mo,
maps mi 
)

Add a maps at the end of another maps.

See also
addMapToMap, dupMaps, getMaps
Parameters
mothe maps to add mi
mithe maps to add to mo
void addMapToIoType ( iotype **  io,
map mi 
)

Add a map to iotype.

Parameters
iothe iotype to add the map
mithe map to add to io
void addMapToMap ( map **  mo,
map mi 
)

Add a map at the end of another map.

Parameters
mothe map to add mi
mithe map to add to mo
bool addServiceToRegistry ( registry **  reg,
char *  name,
service content 
)

Add a service to the registry.

Parameters
regthe resgitry to add the service
namethe registry name to update
contentthe service to add
void addToElements ( elements **  m,
elements e 
)

Add an elements to another elements.

See also
dupElements
Parameters
mthe elements to add the e
ethe elements to be added to m
void addToMap ( map m,
const char *  n,
const char *  v 
)

Add key value pair to an existing map.

Parameters
mthe map to add the KVP
nthe key to add
vthe corresponding value to add
map* addToMapWithSize ( map m,
const char *  n,
const char *  v,
int  size 
)

Add a key and a binary value to an existing map.

Parameters
mthe map to add the KVP
nthe key to add
vthe corresponding value to add
sizethe size of the given value
Returns
a pointer to the updated map m
void charxxxToMaps ( char ***  c,
maps **  m 
)

Convert a char*** to a maps (only used for Fortran support)

Parameters
cthe array to convert
mthe resulting maps
bool contains ( map m,
map i 
)

Verify if a map is contained in another map.

Parameters
mthe map to search for i
ithe map to search in m
Returns
true if i was found in m, false in other case
int count ( map m)

Count number of map in a map.

Parameters
mthe maps to count
Returns
number of map in a map
elements* createElements ( char *  name)

Create a named elements.

Parameters
namethe elements name
Returns
a pointer to the allocated elements
elements* createEmptyElements ( )

Create an empty elements.

Returns
a pointer to the allocated elements
map* createMap ( const char *  name,
const char *  value 
)

Create a new map.

Parameters
namethe key to add to the map
valuethe corresponding value to add to the map
Returns
a pointer to the allocated map
maps* createMaps ( const char *  name)

Create a new maps with the given name.

Parameters
nameof the maps
Returns
the allocated map
void dumpElements ( elements e)

Dump an elements on stderr.

Parameters
ethe elements to dump
void dumpElementsAsYAML ( elements e,
int  level 
)

Dump an elements on stderr using the YAML syntaxe.

Parameters
ethe elements to dump
void dumpMap ( map t)

Dump a map on stderr, see _dumpMap()

Parameters
tthe map to dump
void dumpMaps ( maps m)

Dump a maps on stderr, see dumpMap().

Parameters
mthe map to dump
void dumpMapsToFile ( maps m,
char *  file_path,
int  limit 
)

Dump a maps to a file, see _dumpMapsToFile().

Parameters
mthe map to dump
file_paththe full path to the file name to store the map
limitthe number limiting the maps to be dumped
void dumpMapToFile ( map t,
FILE *  file 
)

Dump a map to a file.

Parameters
tthe map to dump to file
filethe file pointer to store the map
void dumpRegistry ( registry r)

Print the registry on stderr.

Parameters
rthe registry
void dumpService ( service s)

Dump a service on stderr.

Parameters
sthe service to dump
void dumpServiceAsYAML ( service s)

Dump a service on stderr using the YAML syntaxe.

Parameters
sthe service to dump
elements* dupElements ( elements e)

Duplicate an elements.

Parameters
ethe elements to clone
Returns
the allocated elements containing a copy of the elements e
maps* dupMaps ( maps **  mo)

Duplicate a Maps.

Parameters
mothe maps to clone
Returns
the allocated maps containing a copy of the mo maps
service* dupService ( service s)

Duplicate a service.

Parameters
sthe service to clone
Returns
the allocated service containing a copy of the serfvice s
void freeElements ( elements **  e)

Free allocated memory of an elements.

Require to call free on e after calling this function.

Parameters
ethe iotype to free
void freeIOType ( iotype **  i)

Free allocated memory of an iotype.

Require to call free on i after calling this function.

Parameters
ithe iotype to free
void freeMap ( map **  mo)

Free allocated memory of a map.

Require to call free on mo after calling this function.

Parameters
mothe map to free
void freeMaps ( maps **  mo)

Free allocated memory of a maps.

Require to call free on mo after calling this function.

Parameters
mothe maps to free
void freeRegistry ( registry **  r)

Free memory allocated for the registry.

Parameters
rthe registry
void freeService ( service **  s)

Free allocated memory of a service.

Require to call free on e after calling this function.

Parameters
sthe service to free
elements* getElements ( elements m,
char *  key 
)

Access a specific elements named key.

Parameters
mthe elements to search
keythe elements name to search
Returns
a pointer to the specific element if found, NULL in other case.
iotype* getIoTypeFromElement ( elements e,
char *  name,
map values 
)

Access a specific iotype from an elements.

Parameters
ethe elements to search for the name
namethe name to search in the elements e
valuesthe map to verify it was contained in the defaults or supported content of the elements e
Returns
a pointer on the iotype found or NULL if not found
map* getLastMap ( map m)

Access the last map.

Parameters
mthe map to search for the lastest map
Returns
a pointer on the lastest map found or NULL if not found
map* getMap ( map m,
const char *  key 
)

Access a specific map.

Parameters
mthe map to search for the key
keythe key to search in the map
Returns
a pointer on the map found or NULL if not found
map* getMapArray ( map m,
const char *  key,
int  index 
)

Access a specific map array element.

Parameters
mthe map to search for the key
keythe key to search in the map
indexof the MapArray
Returns
a pointer on the map found or NULL if not found
map* getMapFromMaps ( maps m,
const char *  key,
const char *  subkey 
)

Access a specific map from a maps.

Parameters
mthe maps to search for the key
keythe key to search in the maps
subkeythe key to search in the map (found for the key, if any)
Returns
a pointer on the map found or NULL if not found
map* getMapOrFill ( map **  m,
const char *  key,
const char *  value 
)

Access a specific map or set its value.

Parameters
mthe map to search for the key
keythe key to search/add in the map
valuethe value to add if the key does not exist
Returns
a pointer on the map found or NULL if not found
maps* getMaps ( maps m,
const char *  key 
)

Access a specific maps.

Parameters
mthe maps to search for the key
keythe key to search in the maps
Returns
a pointer on the maps found or NULL if not found
map* getMapType ( map mt)

Access the map "type".

Parameters
mtthe map
Returns
a pointer on the map for mimeType/dataType/CRS if found, NULL in other case
service* getServiceFromRegistry ( registry r,
char *  level,
char *  sname 
)

Access a service in the registry.

Parameters
rthe registry
levelthe regitry to search ("concept", "generic" or "implementation")
snamethe service name
Returns
the service pointer if a corresponding service was found or NULL
bool hasElement ( elements e,
const char *  key 
)

Verify if an elements contains a name equal to the given key.

Parameters
ethe elements to search for the key
keythe elements name to search
Returns
true if the elements contains the name, false in other cases.
bool hasKey ( map m,
const char *  key 
)

Verify if a key exist in a map.

Parameters
mthe map to search for the key
keythe key to search in the map
Returns
true if the key wwas found, false in other case
void inheritance ( registry r,
service **  s 
)

Apply inheritance to a service based on a registry.

Parameters
rthe registry storing profiles hierarchy
sthe service to update depending on its inheritance
void inheritElements ( elements **  out,
elements in 
)

Apply inheritance to an out elements from a reference in elements.

Parameters
outthe elements to update
inthe reference elements (containing inherited properties)
void inheritIOType ( iotype **  out,
iotype in 
)

Apply inheritance to an out iotype from a reference in iotype.

Parameters
outthe iotype to update
inthe reference iotype (containing inherited properties)
void inheritMap ( map **  out,
map in 
)

Apply inheritance to an out map from a reference in map.

Parameters
outthe map to update
inthe reference map (containing inherited properties)
void loadMapBinaries ( map **  out,
map in 
)

Load binary values from a map (in) and add them to another map (out).

This function will take care of MapArray.

See also
loadMapBinary
Parameters
outthe map to add binaries values
inthe map containing the binary values to add ti out
void loadMapBinary ( map **  out,
map in,
int  pos 
)

Load binary values from a map (in) and add them to another map (out)

Parameters
outthe map to add binaries values
inthe map containing the binary values to add ti out
posindex of the binary in an array (in case of "MapArray")
void mapsToCharXXX ( maps m,
char ***  c 
)

Convert a maps to a char*** (only used for Fortran support)

Parameters
mthe maps to convert
cthe resulting array
void setElementsName ( elements **  elem,
char *  name 
)

Set the name of an elements.

Parameters
namethe elements name
Returns
a pointer to the allocated elements
void setMapArray ( map m,
const char *  key,
int  index,
const char *  value 
)

Add a key value in a MapArray for a specific index.

Parameters
mthe map to search for the key
keythe key to search in the map
indexthe index of the MapArray
valuethe value to set in the MapArray
Returns
a pointer on the map found or NULL if not found
void setMapInMaps ( maps m,
const char *  key,
const char *  subkey,
const char *  value 
)

Set a key value pair to a map contained in a Maps.

Parameters
mthe maps
keythe maps name
subkeythe map name included in the maps corresponding to key
valuethe corresponding value to add in the map
void setServiceName ( service **  serv,
char *  name 
)

Set the name of a service.

Parameters
namethe service name