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);
550 const std::vector<std::string>& load_path);
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");
Class for managing objects.
Definition ObjectManager.h:52
Logger class.
Definition SystemLogger.h:101
Manager class.
Definition Manager.h:91
Module list that has already loaded .
Definition ModuleManager.h:684
DllPred(const char *filepath)
Definition ModuleManager.h:687
DllPred(const DLLEntity *dll)
Definition ModuleManager.h:688
bool operator()(DLLEntity *dllentity)
Definition ModuleManager.h:690
Module unloading functor .
Definition ModuleManager.h:772
void operator()(DLLEntity *dll)
Definition ModuleManager.h:775
ModuleManager class.
Definition ModuleManager.h:72
void(*)(Manager *) ModuleInitFunc
Definition ModuleManager.h:229
StringVector m_loadPath
Module load path list .
Definition ModuleManager.h:711
std::string m_initFuncPrefix
Initial execution function prefix .
Definition ModuleManager.h:753
void addLoadpath(const std::vector< std::string > &load_path)
Add the module load path.
std::string load(const std::string &file_name)
Load the module.
StringVector::iterator StringVectorItr
Definition ModuleManager.h:659
void disallowAbsolutePath()
Disallow absolute path when specify module path.
Definition ModuleManager.h:481
void unload(const std::string &file_name)
Unload the module.
void * symbol(const std::string &file_name, const std::string &func_name)
Refer to the symbol of the module .
std::map< std::string, coil::vstring > m_loadfailmods
Definition ModuleManager.h:783
ObjectManager< const char *, DLLEntity, DllPred > m_modules
Module list that has already loaded .
Definition ModuleManager.h:702
ModuleManager(coil::Properties &prop)
Constructor.
std::vector< std::string > getLoadPath()
Get the module load path.
Definition ModuleManager.h:387
void allowAbsolutePath()
Allow absolute path when specify module path.
Definition ModuleManager.h:463
std::vector< coil::Properties > getLoadedModules()
Get the module list that has been loaded.
coil::vstring m_supported_languages
Definition ModuleManager.h:762
std::string load(const std::string &file_name, const std::string &init_func)
Load and intialize the module.
void getModuleProfiles(const std::string &lang, const coil::vstring &modules, vProperties &modprops)
Getting module properties from given language and file list .
std::vector< DLLEntity > DllMap
Definition ModuleManager.h:662
DllMap::iterator DllMapItr
Definition ModuleManager.h:663
void disallowModuleDownload()
Disallow URL when specify module path.
Definition ModuleManager.h:521
std::string findFile(const std::string &fname, const std::vector< std::string > &load_path)
Search the file from the LoadPath.
void removeInvalidModules()
Removing incalid module profiles .
std::string getInitFuncName(const std::string &file_path)
Create initialization function symbol.
bool m_absoluteAllowed
Flag of absolute path when specify module for the load. .
Definition ModuleManager.h:735
void addNewFile(const std::string &fpath, coil::vstring &modules, const std::string &lang)
Adding file path not existing cache .
void allowModuleDownload()
Allow URL when specify module path.
Definition ModuleManager.h:503
void unloadAll()
Unload all modules.
DllMap::const_iterator DllMapConstItr
Definition ModuleManager.h:664
std::vector< coil::Properties > getLoadableModules()
Get the loadable module list.
void setLoadpath(const std::vector< std::string > &load_path)
Set the module load path.
coil::Properties & m_properties
Module Manager properties .
Definition ModuleManager.h:674
void getModuleList(const std::string &lang, coil::vstring &modules)
Getting loadable file list on the loadpath for given language .
bool m_downloadAllowed
Flag of URL when specify module for the load. .
Definition ModuleManager.h:727
bool fileExist(const std::string &filename)
Check whether the file exists.
StringVector::const_iterator StringVectorConstItr
Definition ModuleManager.h:660
std::string m_initFuncSuffix
Initial execution function suffix .
Definition ModuleManager.h:744
StringVector m_configPath
Configuration path list .
Definition ModuleManager.h:719
~ModuleManager()
Destructor.
vProperties m_modprofs
Definition ModuleManager.h:782
std::vector< std::string > StringVector
Definition ModuleManager.h:658
Logger rtclog
Logger stream .
Definition ModuleManager.h:643
Structure for DLL management .
Definition ModuleManager.h:653
coil::Properties properties
Definition ModuleManager.h:654
coil::DynamicLib dll
Definition ModuleManager.h:655
Structure for exception handling when file open is failed .
Definition ModuleManager.h:119
std::string reason
Definition ModuleManager.h:122
Error(std::string _reason)
Definition ModuleManager.h:120
Structure for exception handling when specified file cannot be found .
Definition ModuleManager.h:150
FileNotFound(const std::string &_name)
Definition ModuleManager.h:151
Structure for exception handling when specified argument is invalid. .
Definition ModuleManager.h:210
InvalidArguments(const std::string &_reason)
Definition ModuleManager.h:211
Structure for exception handling when specified operation is invalid. .
Definition ModuleManager.h:225
InvalidOperation(const std::string &_reason)
Definition ModuleManager.h:226
Structure for exception handling when specified module cannot be found .
Definition ModuleManager.h:165
ModuleNotFound(const std::string &_name)
Definition ModuleManager.h:166
Structure for exception handling when specified operation cannot be allowed. .
Definition ModuleManager.h:195
NotAllowedOperation(const std::string &_reason)
Definition ModuleManager.h:196
Structure for exception handling of unimplemented part and specified module missing .
Definition ModuleManager.h:134
std::string name
Definition ModuleManager.h:137
NotFound(std::string _name)
Definition ModuleManager.h:135
Structure for exception handling when specified symbol cannot be found .
Definition ModuleManager.h:180
SymbolNotFound(const std::string &_name)
Definition ModuleManager.h:181