Leosac
0.8.0
Open Source Access Control
|
A second module manager that loads "ZMQ aware" module – modules that talks to the application through message passing. More...
#include <module_manager.hpp>
Classes | |
struct | ModuleInfo |
Internal helper struct that store informations related to module that are useful to the module manager. More... | |
Public Member Functions | |
ModuleManager (zmqpp::context &ctx, Leosac::Kernel &k) | |
Construct the module manager. More... | |
~ModuleManager () | |
void | initModules () |
Actually call the init_module() function of each library we loaded. More... | |
bool | initModule (const std::string &name) |
Attempt to find a module using its name, then load it. More... | |
void | initModule (ModuleInfo *modinfo) |
Initialize a module. More... | |
void | stopModules (bool soft=false) |
Opposite of init module. More... | |
void | addToPath (const std::string &dir) |
Add a directory to a path. More... | |
bool | loadModule (const std::string &module_name) |
Search the path and load a module based on a property tree for this module. More... | |
std::vector< std::string > | modules_names () const |
Returns the list of the name of the loaded modules. More... | |
bool | has_module (const std::string &name) const |
Do we have some informations about the module "name". More... | |
const std::vector< std::string > & | get_module_path () const |
Return the list of paths where we search for module. More... | |
Private Member Functions | |
void | unloadLibraries () |
Close library handler. More... | |
bool | stopModule (const std::string &name) |
Stop a module by name and remove its config info from the config manager. More... | |
void | stopModule (ModuleInfo *modinfo, bool soft=false) |
Stop a specific module and remove its config info from the config manager. More... | |
ModuleInfo * | find_module_by_name (const std::string &name) const |
std::shared_ptr< DynamicLibrary > | load_library_file (const std::string &full_path) |
This will load (actually calling dlopen()) the library file located at full_path. More... | |
Private Attributes | |
std::vector< std::string > | path_ |
std::set< ModuleInfo > | modules_ |
zmqpp::context & | ctx_ |
Leosac::ConfigManager & | config_manager_ |
Leosac::CoreUtilsPtr | core_utils_ |
A second module manager that loads "ZMQ aware" module – modules that talks to the application through message passing.
A second loader is necessary because the procedure of loading a module differs. No reference to an object is returned when loading a module. The module will lives in its own thread and other components can talk to it.
Definition at line 54 of file module_manager.hpp.
ModuleManager::ModuleManager | ( | zmqpp::context & | ctx, |
Leosac::Kernel & | k | ||
) |
Construct the module manager.
ctx | the zeroMQ context to pass around to module. |
Definition at line 29 of file module_manager.cpp.
ModuleManager::~ModuleManager | ( | ) |
Definition at line 36 of file module_manager.cpp.
void ModuleManager::addToPath | ( | const std::string & | dir | ) |
Add a directory to a path.
If the path already exist, it is ignored.
Definition at line 148 of file module_manager.cpp.
|
private |
Definition at line 291 of file module_manager.cpp.
const std::vector< std::string > & ModuleManager::get_module_path | ( | ) | const |
Return the list of paths where we search for module.
Definition at line 306 of file module_manager.cpp.
bool ModuleManager::has_module | ( | const std::string & | name | ) | const |
Do we have some informations about the module "name".
It returns true if we have it in our modules_ list. Returning true here means that we have a shared library handler, thus meaning the module is loaded (maybe not initialized).
Definition at line 301 of file module_manager.cpp.
bool ModuleManager::initModule | ( | const std::string & | name | ) |
Attempt to find a module using its name, then load it.
Definition at line 133 of file module_manager.cpp.
void ModuleManager::initModule | ( | ModuleInfo * | modinfo | ) |
Initialize a module.
Definition at line 78 of file module_manager.cpp.
void ModuleManager::initModules | ( | ) |
Actually call the init_module() function of each library we loaded.
The module initialization order is honored because the modules_ set is ordered.
Definition at line 69 of file module_manager.cpp.
|
private |
This will load (actually calling dlopen()) the library file located at full_path.
It returns a DynamicLibrary pointer that can be used to retrieve symbol from the shared object. It it failed, returns nullptr.
Definition at line 182 of file module_manager.cpp.
bool ModuleManager::loadModule | ( | const std::string & | module_name | ) |
Search the path and load a module based on a property tree for this module.
Mandatory data are the module "name" and the "file" location (the name of the .so to load).
The first file to match (looping over the path array) will be loaded.
Definition at line 154 of file module_manager.cpp.
std::vector< std::string > ModuleManager::modules_names | ( | ) | const |
Returns the list of the name of the loaded modules.
Definition at line 278 of file module_manager.cpp.
|
private |
Stop a module by name and remove its config info from the config manager.
Definition at line 240 of file module_manager.cpp.
|
private |
Stop a specific module and remove its config info from the config manager.
Definition at line 211 of file module_manager.cpp.
void ModuleManager::stopModules | ( | bool | soft = false | ) |
Opposite of init module.
this stop all modules thread and perform cleanup.
Definition at line 198 of file module_manager.cpp.
|
private |
Close library handler.
Cleanup code, call from destructor only.
Definition at line 53 of file module_manager.cpp.
|
private |
Definition at line 217 of file module_manager.hpp.
|
private |
Definition at line 218 of file module_manager.hpp.
|
private |
Definition at line 216 of file module_manager.hpp.
|
private |
Definition at line 214 of file module_manager.hpp.
|
private |
Definition at line 213 of file module_manager.hpp.