Graphite
Version 3
An experimental 3D geometry processing program
|
Manages dynamically loadable modules. More...
#include <OGF/basic/modules/modmgr.h>
Public Types | |
typedef void(* | function_ptr) () |
A generic function pointer. | |
Public Member Functions | |
bool | load_module (const std::string &module_name, bool quiet=false) |
Loads a dynamic module. More... | |
bool | bind_module (const std::string &module_name, Module *module) |
Declares a Module object to the ModuleManager. More... | |
bool | unbind_module (const std::string &module_name) |
Removes a Module object from the ModuleManager. More... | |
Module * | resolve_module (const std::string &module_name) |
Retreives a Module object by name. More... | |
virtual bool | get_local_value (const std::string &name, std::string &value) const |
overloads Environment::get_local_value() More... | |
virtual bool | set_local_value (const std::string &name, const std::string &value) |
overloads Environment::set_local_value() More... | |
Public Member Functions inherited from GEO::Environment | |
virtual bool | add_environment (Environment *env) |
Adds a child environment. More... | |
bool | has_value (const std::string &name) const |
Tests if a variable exists. More... | |
virtual bool | get_value (const std::string &name, std::string &value) const |
Retrieves the value of a variable. More... | |
std::string | get_value (const std::string &name) const |
Retrieves the value of a variable. More... | |
virtual bool | set_value (const std::string &name, const std::string &value) |
Sets a variable value. More... | |
virtual Environment * | find_environment (const std::string &name) |
Finds the environment that declares a variable as a local name. More... | |
virtual bool | add_observer (const std::string &name, VariableObserver *observer) |
Attaches an observer to a variable. More... | |
virtual bool | remove_observer (const std::string &name, VariableObserver *observer) |
Detaches an observer from a variable. More... | |
virtual bool | notify_observers (const std::string &name, bool recursive=false) |
Notifies observers. More... | |
Public Member Functions inherited from GEO::Counted | |
void | ref () const |
Increments the reference count. More... | |
void | unref () const |
Decrements the reference count. More... | |
bool | is_shared () const |
Check if the object is shared. More... | |
int | nb_refs () const |
Gets the number of references that point to this object. More... | |
Static Public Member Functions | |
static void | initialize () |
Initializes the ModuleManager system. More... | |
static void | terminate () |
Terminates the ModuleManager system. More... | |
static void | terminate_dynamic_modules () |
Terminates the dynamic modules. More... | |
static ModuleManager * | instance () |
Gets a pointer to the ModuleManager instance. More... | |
static function_ptr | resolve_function (const std::string &name) |
Finds a pointer to a function by its name. More... | |
static void * | resolve_symbol (const std::string &name) |
Finds a pointer to a symbol by its name. More... | |
static void | append_dynamic_libraries_path (const std::string &path) |
Adds a path where dynamic libraries can be loaded. More... | |
Static Public Member Functions inherited from GEO::Environment | |
static Environment * | instance () |
Gets the root environment. More... | |
static void | terminate () |
Cleans up the environment. More... | |
Static Public Member Functions inherited from GEO::Counted | |
static void | ref (const Counted *counted) |
Increments the reference count. More... | |
static void | unref (const Counted *counted) |
Decrements the reference count. More... | |
Protected Member Functions | |
ModuleManager () | |
Forbids construction by client code. | |
~ModuleManager () | |
Forbids destruction by client code. | |
void | do_terminate_modules () |
Terminates all the modules registered in the system. | |
Protected Member Functions inherited from GEO::Environment | |
~Environment () override | |
Environment destructor. More... | |
bool | notify_observers (const std::string &name, const std::string &value, bool recursive) |
Notifies observers. More... | |
bool | notify_local_observers (const std::string &name, const std::string &value) |
Notifies local observers. More... | |
Protected Member Functions inherited from GEO::Counted | |
Counted () | |
Creates a reference counted object. More... | |
virtual | ~Counted () |
Destroys a reference counted object. More... | |
|
static |
Adds a path where dynamic libraries can be loaded.
Under Windows, adds the path to the PATH environment variable. Under Unixes, adds the path to the LD_LIBRARY_PATH environment variable.
[in] | path | the path to be added. |
bool OGF::ModuleManager::bind_module | ( | const std::string & | module_name, |
Module * | module | ||
) |
Declares a Module object to the ModuleManager.
Ownership of the module object is transfered to the module manager.
[in] | module_name | name of the module |
[in] | module | a pointer to the module object |
true | if the module could be successfully bound |
false | otherwise (e.g. if a module with the same name was already bound) |
|
virtual |
overloads Environment::get_local_value()
Defines the "loaded_modules" and "loaded_dynamic_modules" variables.
[in] | name | name of the variable to be queried |
[out] | value | value of the variable |
true | if a variable with name was found |
false | otherwise |
Implements GEO::Environment.
|
static |
Initializes the ModuleManager system.
Called once when Graphite starts.
|
static |
Gets a pointer to the ModuleManager instance.
bool OGF::ModuleManager::load_module | ( | const std::string & | module_name, |
bool | quiet = false |
||
) |
Loads a dynamic module.
Searches a dll that matches the module name in the OGF path, managed by the FileManager.
[in] | module_name | the name of the module, as displayed to the user (without "lib" prefix, without ".dll" or ".so" extension) |
[in] | quiet | if true, status messages are displayed |
true | if the module was successfully loaded |
false | otherwise |
|
static |
Finds a pointer to a function by its name.
Searches all the functions currently loaded in all the dynamic libraries used by the current process.
[in] | name | the name of the function. |
Module* OGF::ModuleManager::resolve_module | ( | const std::string & | module_name | ) |
Retreives a Module object by name.
[in] | module_name | name of the module |
module_name
if it exists, nil otherwise
|
static |
Finds a pointer to a symbol by its name.
Searches all the functions currently loaded in all the dynamic libraries used by the current process.
[in] | name | the name of the symbol. |
|
virtual |
overloads Environment::set_local_value()
Defines no additional variable ("loaded_modules" and "loaded_dynamic_modules" are readonly).
[in] | name | name of the variable to be set |
[in] | value | new value for the variable |
true | if a variable with name could be set to value |
false | otherwise |
Implements GEO::Environment.
|
static |
Terminates the ModuleManager system.
Called once when Graphite exits.
|
static |
Terminates the dynamic modules.
The dynamic modules are those that are loaded on-demand by Graphite. This function is called once when Graphite exits.
bool OGF::ModuleManager::unbind_module | ( | const std::string & | module_name | ) |
Removes a Module object from the ModuleManager.
[in] | module_name | name of the module. |
true | if the module could be successfully unbound |
false | otherwise (e.g. if no module of that name was found in the ModuleManager) |