#include <ModuleManager.h>
Public Types | |
typedef void(* | ModuleInitFunc )(Manager *) |
Public Member Functions | |
ModuleManager (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) throw (ModuleNotFound, SymbolNotFound) |
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 < std::string > | getLoadedModules () |
Get the module list that has been loaded. | |
std::vector < std::string > | 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 | |
typedef std::vector < std::string > | StringVector |
typedef StringVector::iterator | StringVectorItr |
typedef StringVector::const_iterator | StringVectorConstItr |
typedef std::map < std::string, DLL > | DllMap |
typedef DllMap::iterator | DllMapItr |
typedef DllMap::const_iterator | DllMapConstItr |
Protected Attributes | |
Properties & | m_properties |
Module Manager properties. | |
DllMap | m_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. | |
Classes | |
struct | DLL |
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... |
This is a class to manage for loading and unloading modules.
typedef void(* RTC::ModuleManager::ModuleInitFunc)(Manager *) |
typedef std::vector<std::string> RTC::ModuleManager::StringVector [protected] |
typedef StringVector::iterator RTC::ModuleManager::StringVectorItr [protected] |
typedef StringVector::const_iterator RTC::ModuleManager::StringVectorConstItr [protected] |
typedef std::map<std::string, DLL> RTC::ModuleManager::DllMap [protected] |
typedef DllMap::iterator RTC::ModuleManager::DllMapItr [protected] |
typedef DllMap::const_iterator RTC::ModuleManager::DllMapConstItr [protected] |
RTC::ModuleManager::ModuleManager | ( | Properties & | prop | ) |
Constructor.
Constructor. Initialize based on information in the set Property object.
prop | Properties for initialization |
RTC::ModuleManager::~ModuleManager | ( | ) |
Destructor.
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.allowAbsolutePath is no, module of file_name will be searched from the default module load path and loaded.
file_name | The target module name for the loading |
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.
file_name | The target module name for the loading | |
init_func | Operation for initialization |
void RTC::ModuleManager::unload | ( | const std::string & | file_name | ) |
Unload the module.
Close and unload the specified module that has been loaded.
file_name | Name of module for the unloading |
void RTC::ModuleManager::unloadAll | ( | ) |
Unload all modules.
Unload all modules that have been loaded.
void* RTC::ModuleManager::symbol | ( | const std::string & | file_name, | |
const std::string & | func_name | |||
) | throw (ModuleNotFound, SymbolNotFound) |
Refer to the symbol of the module.
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.
load_path | List of module search path |
std::vector<std::string> RTC::ModuleManager::getLoadPath | ( | ) | [inline] |
Get the module load path.
Get the search path of the set module.
void RTC::ModuleManager::addLoadpath | ( | const std::vector< std::string > & | load_path | ) |
Add the module load path.
Add specified path list to search path list.
std::vector<std::string> RTC::ModuleManager::getLoadedModules | ( | ) |
Get the module list that has been loaded.
Get the module list that has been loaded.
std::vector<std::string> RTC::ModuleManager::getLoadableModules | ( | ) |
Get the loadable module list.
Get the loadable module list (not implemented).
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.
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.
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.
void RTC::ModuleManager::disallowModuleDownload | ( | ) | [inline] |
Disallow URL when specify module path.
Disallow URL when specify module for the load.
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.
fname | Target file name of the search | |
load_path | Path list for the search |
bool RTC::ModuleManager::fileExist | ( | const std::string & | filename | ) |
Check whether the file exists.
Check whether the specified file exists.
filename | Name of file existence for checking |
std::string RTC::ModuleManager::getInitFuncName | ( | const std::string & | file_path | ) |
Create initialization function symbol.
Assemble names of the initialization functions.
file_path | Name of module for initialization |
Properties& RTC::ModuleManager::m_properties [protected] |
Module Manager properties.
DllMap RTC::ModuleManager::m_modules [protected] |
Module list that has already loaded.
StringVector RTC::ModuleManager::m_loadPath [protected] |
Module load path list.
StringVector RTC::ModuleManager::m_configPath [protected] |
Configuration path list.
bool RTC::ModuleManager::m_downloadAllowed [protected] |
Flag of URL when specify module for the load.
bool RTC::ModuleManager::m_absoluteAllowed [protected] |
Flag of absolute path when specify module for the load.
std::string RTC::ModuleManager::m_initFuncSuffix [protected] |
Initial execution function suffix.
std::string RTC::ModuleManager::m_initFuncPrefix [protected] |
Initial execution function prefix.