Go to the documentation of this file.
20 #ifndef RTC_MODULEMANAGER_H
21 #define RTC_MODULEMANAGER_H
25 #include <coil/DynamicLib.h>
29 #include <coil/Properties.h>
38 #define CONFIG_EXT "manager.modules.config_ext"
39 #define CONFIG_PATH "manager.modules.config_path"
40 #define DETECT_MOD "manager.modules.detect_loadable"
41 #define MOD_LOADPTH "manager.modules.load_path"
42 #define INITFUNC_SFX "manager.modules.init_func_suffix"
43 #define INITFUNC_PFX "manager.modules.init_func_prefix"
44 #define ALLOW_ABSPATH "manager.modules.abs_path_allowed"
45 #define ALLOW_URL "manager.modules.download_allowed"
46 #define MOD_DWNDIR "manager.modules.download_dir"
47 #define MOD_DELMOD "manager.modules.download_cleanup"
48 #define MOD_PRELOAD "manager.modules.preload"
73 using vProperties = std::vector<coil::Properties>;
121 :
reason(std::move(_reason)) {}
136 :
name(std::move(_name)) {}
276 std::string
load(
const std::string& file_name);
305 std::string
load(
const std::string& file_name,
306 const std::string& init_func);
325 void unload(
const std::string& file_name);
349 void*
symbol(
const std::string& file_name,
const std::string& func_name);
368 void setLoadpath(
const std::vector<std::string>& load_path);
409 void addLoadpath(
const std::vector<std::string>& load_path);
549 std::string
findFile(
const std::string& fname,
550 const std::vector<std::string>& load_path);
573 bool fileExist(
const std::string& filename);
615 void getModuleList(
const std::string& lang, coil::vstring& modules);
624 void addNewFile(
const std::string& fpath, coil::vstring& modules,
const std::string& lang);
634 const coil::vstring& modules, vProperties& modprops);
685 std::string m_filepath;
687 explicit DllPred(
const char* filepath) : m_filepath(filepath) {}
689 : m_filepath(dll->properties[
"file_path"]) {}
692 return m_filepath == dllentity->
properties.getProperty(
"file_path");
788 #endif // RTC_MODULEMANAGER_H
std::string getInitFuncName(const std::string &file_path)
Create initialization function symbol.
StringVector::const_iterator StringVectorConstItr
Definition: ModuleManager.h:660
~ModuleManager()
Destructor.
std::string m_initFuncPrefix
Initial execution function prefix.
Definition: ModuleManager.h:753
Module unloading functor.
Definition: ModuleManager.h:771
ModuleNotFound(const std::string &_name)
Definition: ModuleManager.h:166
std::string m_initFuncSuffix
Initial execution function suffix.
Definition: ModuleManager.h:744
std::map< std::string, coil::vstring > m_loadfailmods
Definition: ModuleManager.h:783
InvalidArguments(const std::string &_reason)
Definition: ModuleManager.h:211
NotAllowedOperation(const std::string &_reason)
Definition: ModuleManager.h:196
InvalidOperation(const std::string &_reason)
Definition: ModuleManager.h:226
void allowAbsolutePath()
Allow absolute path when specify module path.
Definition: ModuleManager.h:463
Structure for DLL management.
Definition: ModuleManager.h:652
ObjectManager< const char *, DLLEntity, DllPred > m_modules
Module list that has already loaded.
Definition: ModuleManager.h:702
void removeInvalidModules()
Removing incalid module profiles.
coil::Properties & m_properties
Module Manager properties.
Definition: ModuleManager.h:674
Class for managing objects.
Definition: ObjectManager.h:51
void setLoadpath(const std::vector< std::string > &load_path)
Set the module load path.
void addNewFile(const std::string &fpath, coil::vstring &modules, const std::string &lang)
Adding file path not existing cache.
Structure for exception handling when specified file cannot be found.
Definition: ModuleManager.h:148
FileNotFound(const std::string &_name)
Definition: ModuleManager.h:151
StringVector m_configPath
Configuration path list.
Definition: ModuleManager.h:719
Structure for exception handling when file open is failed.
Definition: ModuleManager.h:118
Structure for exception handling when specified module cannot be found.
Definition: ModuleManager.h:163
Structure for exception handling when specified symbol cannot be found.
Definition: ModuleManager.h:178
coil::Properties properties
Definition: ModuleManager.h:654
void * symbol(const std::string &file_name, const std::string &func_name)
Refer to the symbol of the module.
bool m_downloadAllowed
Flag of URL when specify module for the load.
Definition: ModuleManager.h:727
SymbolNotFound(const std::string &_name)
Definition: ModuleManager.h:181
Logger class.
Definition: SystemLogger.h:99
void(*)(Manager *) ModuleInitFunc
Definition: ModuleManager.h:229
void allowModuleDownload()
Allow URL when specify module path.
Definition: ModuleManager.h:503
Structure for exception handling when specified argument is invalid.
Definition: ModuleManager.h:208
DllPred(const char *filepath)
Definition: ModuleManager.h:687
void disallowAbsolutePath()
Disallow absolute path when specify module path.
Definition: ModuleManager.h:481
std::vector< std::string > getLoadPath()
Get the module load path.
Definition: ModuleManager.h:387
void addLoadpath(const std::vector< std::string > &load_path)
Add the module load path.
std::string reason
Definition: ModuleManager.h:122
std::string findFile(const std::string &fname, const std::vector< std::string > &load_path)
Search the file from the LoadPath.
Logger rtclog
Logger stream.
Definition: ModuleManager.h:643
Structure for exception handling when specified operation cannot be allowed.
Definition: ModuleManager.h:193
std::vector< coil::Properties > getLoadedModules()
Get the module list that has been loaded.
ModuleManager class.
Definition: ModuleManager.h:71
std::string load(const std::string &file_name)
Load the module.
std::string name
Definition: ModuleManager.h:137
std::vector< DLLEntity > DllMap
Definition: ModuleManager.h:662
Module list that has already loaded.
Definition: ModuleManager.h:683
bool operator()(DLLEntity *dllentity)
Definition: ModuleManager.h:690
void getModuleProfiles(const std::string &lang, const coil::vstring &modules, vProperties &modprops)
Getting module properties from given language and file list.
DllPred(const DLLEntity *dll)
Definition: ModuleManager.h:688
void unload(const std::string &file_name)
Unload the module.
std::vector< std::string > StringVector
Definition: ModuleManager.h:658
Manager class.
Definition: Manager.h:90
bool fileExist(const std::string &filename)
Check whether the file exists.
void disallowModuleDownload()
Disallow URL when specify module path.
Definition: ModuleManager.h:521
bool m_absoluteAllowed
Flag of absolute path when specify module for the load.
Definition: ModuleManager.h:735
Structure for exception handling of unimplemented part and specified module missing.
Definition: ModuleManager.h:133
StringVector::iterator StringVectorItr
Definition: ModuleManager.h:659
StringVector m_loadPath
Module load path list.
Definition: ModuleManager.h:711
NotFound(std::string _name)
Definition: ModuleManager.h:135
coil::Properties Properties
Definition: RTC.h:72
ModuleManager(coil::Properties &prop)
Constructor.
void operator()(DLLEntity *dll)
Definition: ModuleManager.h:775
void unloadAll()
Unload all modules.
coil::vstring m_supported_languages
Definition: ModuleManager.h:762
coil::DynamicLib dll
Definition: ModuleManager.h:655
DllMap::iterator DllMapItr
Definition: ModuleManager.h:663
DllMap::const_iterator DllMapConstItr
Definition: ModuleManager.h:664
vProperties m_modprofs
Definition: ModuleManager.h:782
Structure for exception handling when specified operation is invalid.
Definition: ModuleManager.h:223
void getModuleList(const std::string &lang, coil::vstring &modules)
Getting loadable file list on the loadpath for given language.
Error(std::string _reason)
Definition: ModuleManager.h:120
std::vector< coil::Properties > getLoadableModules()
Get the loadable module list.