CppMicroServices

C++ Micro Services: ModuleSettings Class Reference
ModuleSettings Class Reference

Query and set certain properties of the CppMicroServices library. More...

Public Types

typedef std::vector< std::string > PathList
 

Static Public Member Functions

static std::string CURRENT_MODULE_PATH ()
 Returns a special string which can be used as an argument for a AddAutoLoadPath() call. More...
 
static bool IsThreadingSupportEnabled ()
 
static bool IsAutoLoadingEnabled ()
 
static void SetAutoLoadingEnabled (bool enable)
 Enable or disable auto-loading support. More...
 
static PathList GetAutoLoadPaths ()
 
static void SetAutoLoadPaths (const PathList &paths)
 Set a list of paths in the file-system from which modules should be auto-loaded. More...
 
static void AddAutoLoadPath (const std::string &path)
 Add a path in the file-system to the list of paths from which modules will be auto-loaded. More...
 
static void SetStoragePath (const std::string &path)
 Set a local storage path for persistend module data. More...
 
static std::string GetStoragePath ()
 Get the absolute path for persistent data. More...
 

Detailed Description

Query and set certain properties of the CppMicroServices library.

The following environment variables influence the runtime behavior of the CppMicroServices library:

  • US_DISABLE_AUTOLOADING If set, auto-loading of modules is disabled.
  • US_AUTOLOAD_PATHS A ':' (Unix) or ';' (Windows) separated list of paths from which modules should be auto-loaded.
Remarks
This class is thread safe.

Member Typedef Documentation

typedef std::vector<std::string> ModuleSettings::PathList

Member Function Documentation

static void ModuleSettings::AddAutoLoadPath ( const std::string &  path)
static

Add a path in the file-system to the list of paths from which modules will be auto-loaded.

Parameters
pathThe additional absolute auto-load path in the file-system.
static std::string ModuleSettings::CURRENT_MODULE_PATH ( )
static

Returns a special string which can be used as an argument for a AddAutoLoadPath() call.

When a module is loaded and this string has been added as a path to the list of auto-load paths the CppMicroServices library will auto-load all modules from the currently being loaded module's auto-load directory.

Returns
A string to be used in AddAutoLoadPath().
Remarks
The returned string is contained in the default set of auto-load paths, unless a new set of paths is given by a call to SetAutoLoadPaths().
See Also
MicroServices_AutoLoading
US_INITIALIZE_MODULE
static PathList ModuleSettings::GetAutoLoadPaths ( )
static
Returns
A list of paths in the file-system from which modules will be auto-loaded.
static std::string ModuleSettings::GetStoragePath ( )
static

Get the absolute path for persistent data.

The returned path might be empty. If the path is non-empty, it is safe to assume that the path exists and is writable.

Returns
The absolute path to the persistent storage path.
static bool ModuleSettings::IsAutoLoadingEnabled ( )
static
Returns
true if support for module auto-loading is enabled, false otherwise.
Remarks
This method will always return false if support for auto-loading has not been configured into the CppMicroServices library or if it has been disabled by defining the US_DISABLE_AUTOLOADING environment variable.
static bool ModuleSettings::IsThreadingSupportEnabled ( )
static
Returns
true if threading support has been configured into the CppMicroServices library, false otherwise.
static void ModuleSettings::SetAutoLoadingEnabled ( bool  enable)
static

Enable or disable auto-loading support.

Parameters
enableIf true, enable auto-loading support, disable it otherwise.
Remarks
Calling this method will have no effect if support for auto-loading has not been configured into the CppMicroServices library of it it has been disabled by defining the US_DISABLE_AUTOLOADING envrionment variable.
static void ModuleSettings::SetAutoLoadPaths ( const PathList paths)
static

Set a list of paths in the file-system from which modules should be auto-loaded.

Parameters
pathsA list of absolute file-system paths.
static void ModuleSettings::SetStoragePath ( const std::string &  path)
static

Set a local storage path for persistend module data.

This path is used as a base directory for providing modules with a storage path for writing persistent data. The callee must ensure that the provided path exists and is writable.

See Also
ModuleContext::GetDataFile(const std::string&)
Parameters
pathAn absolute path for writing persistent data.