OpenRTM-aist 2.0.2
Loading...
Searching...
No Matches
RTC::ModuleManager Class Reference

ModuleManager class. More...

#include <ModuleManager.h>

Collaboration diagram for RTC::ModuleManager:

Classes

struct  DLLEntity
 Structure for DLL management . More...
 
class  DllPred
 Module list that has already loaded . More...
 
struct  Error
 Structure for exception handling when file open is failed . More...
 
struct  FileNotFound
 Structure for exception handling when specified file cannot be found . More...
 
struct  InvalidArguments
 Structure for exception handling when specified argument is invalid. . More...
 
struct  InvalidOperation
 Structure for exception handling when specified operation is invalid. . More...
 
struct  ModuleNotFound
 Structure for exception handling when specified module cannot be found . More...
 
struct  NotAllowedOperation
 Structure for exception handling when specified operation cannot be allowed. . More...
 
struct  NotFound
 Structure for exception handling of unimplemented part and specified module missing . More...
 
struct  SymbolNotFound
 Structure for exception handling when specified symbol cannot be found . More...
 
class  UnloadPred
 Module unloading functor . More...
 

Public Types

using ModuleInitFunc = void (*)(Manager*)
 

Public Member Functions

 ModuleManager (coil::Properties &prop)
 Constructor.
 
 ~ModuleManager ()
 Destructor.
 
std::string load (const std::string &file_name)
 Load the module.
 
std::string load (const std::string &file_name, const std::string &init_func)
 Load and intialize the module.
 
void unload (const std::string &file_name)
 Unload the module.
 
void unloadAll ()
 Unload all modules.
 
void * symbol (const std::string &file_name, const std::string &func_name)
 Refer to the symbol of the module .
 
void setLoadpath (const std::vector< std::string > &load_path)
 Set the module load path.
 
std::vector< std::string > getLoadPath ()
 Get the module load path.
 
void addLoadpath (const std::vector< std::string > &load_path)
 Add the module load path.
 
std::vector< coil::Properties > getLoadedModules ()
 Get the module list that has been loaded.
 
std::vector< coil::Properties > getLoadableModules ()
 Get the loadable module list.
 
void allowAbsolutePath ()
 Allow absolute path when specify module path.
 
void disallowAbsolutePath ()
 Disallow absolute path when specify module path.
 
void allowModuleDownload ()
 Allow URL when specify module path.
 
void disallowModuleDownload ()
 Disallow URL when specify module path.
 
std::string findFile (const std::string &fname, const std::vector< std::string > &load_path)
 Search the file from the LoadPath.
 
bool fileExist (const std::string &filename)
 Check whether the file exists.
 
std::string getInitFuncName (const std::string &file_path)
 Create initialization function symbol.
 

Protected Types

using StringVector = std::vector<std::string>
 
using StringVectorItr = StringVector::iterator
 
using StringVectorConstItr = StringVector::const_iterator
 
using DllMap = std::vector<DLLEntity>
 
using DllMapItr = DllMap::iterator
 
using DllMapConstItr = DllMap::const_iterator
 

Protected Member Functions

void removeInvalidModules ()
 Removing incalid module profiles .
 
void getModuleList (const std::string &lang, coil::vstring &modules)
 Getting loadable file list on the loadpath for given language .
 
void addNewFile (const std::string &fpath, coil::vstring &modules, const std::string &lang)
 Adding file path not existing cache .
 
void getModuleProfiles (const std::string &lang, const coil::vstring &modules, vProperties &modprops)
 Getting module properties from given language and file list .
 

Protected Attributes

Logger rtclog
 Logger stream .
 
coil::Properties & m_properties
 Module Manager properties .
 
ObjectManager< const char *, DLLEntity, DllPredm_modules
 Module list that has already loaded .
 
StringVector m_loadPath
 Module load path list .
 
StringVector m_configPath
 Configuration path list .
 
bool m_downloadAllowed
 Flag of URL when specify module for the load. .
 
bool m_absoluteAllowed
 Flag of absolute path when specify module for the load. .
 
std::string m_initFuncSuffix
 Initial execution function suffix .
 
std::string m_initFuncPrefix
 Initial execution function prefix .
 
coil::vstring m_supported_languages
 
vProperties m_modprofs
 
std::map< std::string, coil::vstring > m_loadfailmods
 

Detailed Description

ModuleManager class.

This is a class to manage for loading and unloading modules.

Since
0.4.0

Member Typedef Documentation

◆ DllMap

using RTC::ModuleManager::DllMap = std::vector<DLLEntity>
protected

◆ DllMapConstItr

using RTC::ModuleManager::DllMapConstItr = DllMap::const_iterator
protected

◆ DllMapItr

using RTC::ModuleManager::DllMapItr = DllMap::iterator
protected

◆ ModuleInitFunc

◆ StringVector

using RTC::ModuleManager::StringVector = std::vector<std::string>
protected

◆ StringVectorConstItr

using RTC::ModuleManager::StringVectorConstItr = StringVector::const_iterator
protected

◆ StringVectorItr

using RTC::ModuleManager::StringVectorItr = StringVector::iterator
protected

Constructor & Destructor Documentation

◆ ModuleManager()

RTC::ModuleManager::ModuleManager ( coil::Properties & prop)
explicit

Constructor.

Constructor. Initialize based on information in the set Property object.

Parameters
propProperties for initialization

◆ ~ModuleManager()

RTC::ModuleManager::~ModuleManager ( )

Destructor.

Member Function Documentation

◆ addLoadpath()

void RTC::ModuleManager::addLoadpath ( const std::vector< std::string > & load_path)

Add the module load path.

Add specified path list to search path list.

Returns
load_path List of additional module search path

◆ addNewFile()

void RTC::ModuleManager::addNewFile ( const std::string & fpath,
coil::vstring & modules,
const std::string & lang )
protected

Adding file path not existing cache .

◆ allowAbsolutePath()

void RTC::ModuleManager::allowAbsolutePath ( )
inline

Allow absolute path when specify module path.

Set to allow the absolute path when specify the module for the load.

References m_absoluteAllowed.

◆ allowModuleDownload()

void RTC::ModuleManager::allowModuleDownload ( )
inline

Allow URL when specify module path.

Allow URL when specify module for the load. When this setup is allowed, downloading and loading the module will be allowed.

References m_downloadAllowed.

◆ disallowAbsolutePath()

void RTC::ModuleManager::disallowAbsolutePath ( )
inline

Disallow absolute path when specify module path.

Set to disallow the absolute path when specify the module for the load.

References m_absoluteAllowed.

◆ disallowModuleDownload()

void RTC::ModuleManager::disallowModuleDownload ( )
inline

Disallow URL when specify module path.

Disallow URL when specify module for the load.

References m_downloadAllowed.

◆ fileExist()

bool RTC::ModuleManager::fileExist ( const std::string & filename)

Check whether the file exists.

Check whether the specified file exists.

Parameters
filenameName of file existence for checking
Returns
File existence result(File existence:true, Else:false)

◆ findFile()

std::string RTC::ModuleManager::findFile ( const std::string & fname,
const std::vector< std::string > & load_path )

Search the file from the LoadPath.

Check whether the specified file exists in the specified path.

Parameters
fnameTarget file name of the search
load_pathPath list for the search
Returns
File name that was found

◆ getInitFuncName()

std::string RTC::ModuleManager::getInitFuncName ( const std::string & file_path)

Create initialization function symbol.

Assemble names of the initialization functions.

Parameters
file_pathName of module for initialization
Returns
Assembly result of initialization function name

◆ getLoadableModules()

std::vector< coil::Properties > RTC::ModuleManager::getLoadableModules ( )

Get the loadable module list.

Get the loadable module list (not implemented).

Returns
Loadable module list

◆ getLoadedModules()

std::vector< coil::Properties > RTC::ModuleManager::getLoadedModules ( )

Get the module list that has been loaded.

Get the module list that has been loaded.

Returns
List of module that has been loaded

◆ getLoadPath()

std::vector< std::string > RTC::ModuleManager::getLoadPath ( )
inline

Get the module load path.

Get the search path of the set module.

Returns
load_path List of module search path

References m_loadPath.

◆ getModuleList()

void RTC::ModuleManager::getModuleList ( const std::string & lang,
coil::vstring & modules )
protected

Getting loadable file list on the loadpath for given language .

◆ getModuleProfiles()

void RTC::ModuleManager::getModuleProfiles ( const std::string & lang,
const coil::vstring & modules,
vProperties & modprops )
protected

Getting module properties from given language and file list .

◆ load() [1/2]

std::string RTC::ModuleManager::load ( const std::string & file_name)

Load the module.

Load file_name as DLL or a shared liblary. The file_name is specified by the relative path to default load path (manager.modules.load_path).

If Property manager.modules.abs_path_allowed is yes, the load module can be specified by the absolute path.
If Property manager.modules.download_allowed is yes, the load module can be specified with URL.

The file_name can be specified by the absolute path. If manager.modules.abs_path_allowed is no, module of file_name will be searched from the default module load path and loaded.

Parameters
file_nameThe target module name for the loading
Returns
Name of module for the specified load

◆ load() [2/2]

std::string RTC::ModuleManager::load ( const std::string & file_name,
const std::string & init_func )

Load and intialize the module.

Load the specified file as DLL or a shared library, and execute operation for specified initialization.

Parameters
file_nameThe target module name for the loading
init_funcOperation for initialization
Returns
Name of module for the specified load

◆ removeInvalidModules()

void RTC::ModuleManager::removeInvalidModules ( )
protected

Removing incalid module profiles .

◆ setLoadpath()

void RTC::ModuleManager::setLoadpath ( const std::vector< std::string > & load_path)

Set the module load path.

Specify searching path to find the target module when loading module.

Parameters
load_pathList of module search path

◆ symbol()

void * RTC::ModuleManager::symbol ( const std::string & file_name,
const std::string & func_name )

Refer to the symbol of the module .

◆ unload()

void RTC::ModuleManager::unload ( const std::string & file_name)

Unload the module.

Close and unload the specified module that has been loaded.

Parameters
file_nameName of module for the unloading

◆ unloadAll()

void RTC::ModuleManager::unloadAll ( )

Unload all modules.

Unload all modules that have been loaded.

Member Data Documentation

◆ m_absoluteAllowed

bool RTC::ModuleManager::m_absoluteAllowed
protected

Flag of absolute path when specify module for the load. .

Referenced by allowAbsolutePath(), and disallowAbsolutePath().

◆ m_configPath

StringVector RTC::ModuleManager::m_configPath
protected

Configuration path list .

◆ m_downloadAllowed

bool RTC::ModuleManager::m_downloadAllowed
protected

Flag of URL when specify module for the load. .

Referenced by allowModuleDownload(), and disallowModuleDownload().

◆ m_initFuncPrefix

std::string RTC::ModuleManager::m_initFuncPrefix
protected

Initial execution function prefix .

◆ m_initFuncSuffix

std::string RTC::ModuleManager::m_initFuncSuffix
protected

Initial execution function suffix .

◆ m_loadfailmods

std::map<std::string, coil::vstring> RTC::ModuleManager::m_loadfailmods
protected

◆ m_loadPath

StringVector RTC::ModuleManager::m_loadPath
protected

Module load path list .

Referenced by getLoadPath().

◆ m_modprofs

vProperties RTC::ModuleManager::m_modprofs
protected

◆ m_modules

ObjectManager<const char*, DLLEntity, DllPred> RTC::ModuleManager::m_modules
protected

Module list that has already loaded .

◆ m_properties

coil::Properties& RTC::ModuleManager::m_properties
protected

Module Manager properties .

◆ m_supported_languages

coil::vstring RTC::ModuleManager::m_supported_languages
protected

◆ rtclog

Logger RTC::ModuleManager::rtclog
protected

Logger stream .


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