Home2L - C/C++ API  v1.2-2-ga4fe (2023-04-15)
Smart Tools for a Private Home

Description

Init/done and persistence.

Collaboration diagram for General:

Init/Done ...

void EnvInit (int argc, char **argv, const char *specOptionsUsage=NULL, const char *instanceName=NULL, bool noBanner=false)
 Initialize the environment module. More...
 
void EnvPrintBanner ()
 Print the tool banner (only useful if banner was suppressed in the EnvInit() call).
 
void EnvDone ()
 Shutdown the environment module.
 

Persistence ...

void EnvEnablePersistence (bool writeThrough=true, const char *_varFileName=NULL)
 Enable the persistence of all environment variables starting with "var.*". More...
 
void EnvFlush ()
 Write back any persistent variables now.
 

Function Documentation

◆ EnvInit()

void EnvInit ( int  argc,
char **  argv,
const char *  specOptionsUsage = NULL,
const char *  instanceName = NULL,
bool  noBanner = false 
)

Initialize the environment module.

Parameters
argcis the main funcion's 'argc' parameter.
argvis the main funcion's 'argv' parameter.
specOptionsUsageallows to add extra usage information on specific tool options.
instanceNamedefines the instance name, which otherwise is derived from the executable name (argv[0]).
noBannersuppresses the output of the tool banner (for command line tools with minimal output).

◆ EnvEnablePersistence()

void EnvEnablePersistence ( bool  writeThrough = true,
const char *  _varFileName = NULL 
)

Enable the persistence of all environment variables starting with "var.*".

Parameters
writeThroughdecides whether the file is written back automatically with each EnvPut() call changing any "var.*" variable. If set to 'false', the file is only written back on shutdown ( EnvDone() ) or on a explicit flush ( EnvFlush() ).
_varFileNameis the filename to store the variables, which should be pathname relative to the "var" directory. By default, "home2l-<instance name>.conf" is used. It is discouraged to pass an absolute path there.

Persistent variables are (tried to be) read from the filesystem on this call, and they may override any settings in the main configuration file.

This function may be called multiple times, for example, on tool initialization and then later again inside RcInit(), if the user has declared persistent resources. On the second invocation, '_varFileName' must be NULL. If 'writeThrough' is set differently, a logical OR of all passed values will become effective.