#include <manager.h>
Public Types | |
| enum | { errSuccess = 0, errOpen = 1, errLookup = 2, errUnavailable = 3, errConfig = 4, errLoad = 5, errCore = 6, errNonZeroRefs = 7, errStop = 8 } |
| Possible error codes for the error_code() function. More... | |
|
typedef std::list < Module * > | list_type |
| Type of the list of modules. | |
Public Member Functions | |
| ModManager (Core &core, ConfModuleA const &confmodule) | |
| Constructor. | |
| ~ModManager () | |
| Destructor. | |
| void | broadcast (int state, Module &sender, int msg, void *arg) |
| Sends a notification message to all modules in load order. | |
| void | broadcast_reverse (int state, Module &sender, int msg, void *arg) |
| Sends a notification message to all modules in reverse load order. | |
| Module * | find (std::string const &name) const |
| Finds a loaded module by name. | |
| Module * | find (std::string const &name, int state) const |
| Finds a module by name and state. | |
| Interface * | find_interface (PSIID iid, Module **from=NULL) const |
| Finds an exposed interface in one of the loaded modules. | |
| bool | load (std::string const &name) |
| Loads a module. | |
| bool | load (LoadModule const &lm) |
| Loads modules as specified by the load-module directive. | |
| bool | reload () |
| Reloads the configuration for all modules. | |
| void | start () |
| Starts all modules. | |
| void | stop () |
| Stops all modules. | |
| bool | unload (Module &module) |
| Unloads a module. | |
| Core & | core () const |
| Returns the core. | |
| std::string const & | error () const |
| Returns a description of the last error that occured. | |
| int | error_code () const |
| Returns the code of the last error that occured. | |
| void | global (conf::ConfGlobalQ &global) |
| Sets the ConfGlobalQ object used to configure modules. | |
| list_type const & | modules () const |
| Returns the list of loaded modules. | |
| bool | started () const |
| Returns whether the modules manager is started. | |
| anonymous enum |
| errSuccess | No error. |
| errOpen | Library open error. |
| errLookup | Library lookup error (can't find *_get or *_release). |
| errUnavailable | Module unavailable (*_get failed). |
| errConfig | Module configuration error. |
| errLoad | Module::load() failed. |
| errCore | Forbidden operation on the core module. |
| errNonZeroRefs | Reference count is non-zero. |
| errStop | Can't stop module. |
| modules::ModManager::ModManager | ( | Core & | core, | |
| ConfModuleA const & | confmodule | |||
| ) |
| void modules::ModManager::broadcast | ( | int | state, | |
| Module & | sender, | |||
| int | msg, | |||
| void * | arg | |||
| ) |
Calls the Module::notify() function for all modules in a given state, in the order they were loaded, using the given parameters.
| [in] | state | An or'ed set of states the module must have to receive the notification (the msLoaded state is implied). |
| [in] | sender | The module sending the notification. This module, which can be NULL, won't get the notification. |
| [in] | msg | The notification message. |
| [in] | arg | An optional parameter that may be used to pass additional data. |
| void modules::ModManager::broadcast_reverse | ( | int | state, | |
| Module & | sender, | |||
| int | msg, | |||
| void * | arg | |||
| ) |
Calls the Module::notify() function for all modules in a given state, in the reverse order they were loaded, using the given parameters.
| [in] | state | An or'ed set of states the module must have to receive the notification (the msLoaded state is implied). |
| [in] | sender | The module sending the notification. This module, which can be NULL, won't get the notification. |
| [in] | msg | The notification message. |
| [in] | arg | An optional parameter that may be used to pass additional data. |
| Module* modules::ModManager::find | ( | std::string const & | name | ) | const |
Finds a loaded module with the given name.
| [in] | name | The name of the module to find (case-sensitive). |
| Module* modules::ModManager::find | ( | std::string const & | name, | |
| int | state | |||
| ) | const |
Finds a module by name and state.
| [in] | name | The name of the module to find (case-sensitive). |
| [in] | state | An or'ed set of states the module must have to be found. |
Finds an exposed interface in one of the loaded (possibly not started) modules. This calls Module::interface() on all loaded modules until it finds it.
| [in] | iid | The interface identifier |
| [out] | from | If non-NULL, will point to the module that exposes the interface on return. |
| bool modules::ModManager::load | ( | std::string const & | name | ) |
Loads a module.
This method first looks for a .deps file in the module path and will load each module listed in it (one per line). If the file doesn't exist, no errors are returned.
A successful load does NOT guarantee that the module is in the Module::msLoaded state yet. Other modules calling this function should wait to get the Module::mnLoaded notification before using the module.
The module is started by this function as well, but only if the start() function has already been called by the core.
| [in] | name | The module name. |
| bool modules::ModManager::load | ( | LoadModule const & | lm | ) |
| bool modules::ModManager::reload | ( | ) |
| void modules::ModManager::start | ( | ) |
| void modules::ModManager::stop | ( | ) |
| bool modules::ModManager::unload | ( | Module & | module | ) |
Unloads a module. The module is first stopped if it was started. If it fails, then the module is NOT unloaded.
A module can't be unloaded if its reference count is non-zero and you can't unload the core module. Attempting to do so will result in a failure.
| [in] | module | The module to be unloaded. |
| std::string const& modules::ModManager::error | ( | ) | const [inline] |
Returns a description of the last error that occured, after a failed call to load() or unload().
| int modules::ModManager::error_code | ( | ) | const [inline] |
Returns the code of the last error that occured, after a failed call to load() or unload().
| void modules::ModManager::global | ( | conf::ConfGlobalQ & | global | ) | [inline] |
| list_type const& modules::ModManager::modules | ( | ) | const [inline] |
1.5.3