Fawkes API  Fawkes Development Version
fawkes::ModuleManager Class Reference

Dynamic module manager. More...

#include <>>

Public Member Functions

 ModuleManager (const char *module_base_dir, Module::ModuleFlags open_flags=Module::MODULE_FLAGS_DEFAULT)
 Constructor of NetworkManagerTemplate. More...
 
virtual ~ModuleManager ()
 Destructor. More...
 
virtual Moduleopen_module (const char *filename)
 Open a module. More...
 
virtual void close_module (Module *module)
 Close a module by Module instance. More...
 
virtual void close_module (const char *filename)
 Close a module by filename. More...
 
virtual bool module_opened (const char *filename)
 Check if the module is already opened. More...
 
virtual Moduleget_module (const char *filename)
 Get a module if opened. More...
 
virtual const char * get_module_file_extension ()
 Get the file extension for the current module type. More...
 
void set_open_flags (Module::ModuleFlags open_flags)
 Set flags to open modules with. More...
 

Detailed Description

Dynamic module manager.

Manager to load and unload modules, keeps track of loaded modules and does not reload modules if they are already loaded.

Author
Tim Niemueller

Definition at line 40 of file module_manager.h.

Constructor & Destructor Documentation

◆ ModuleManager()

fawkes::ModuleManager::ModuleManager ( const char *  module_base_dir,
Module::ModuleFlags  open_flags = Module::MODULE_FLAGS_DEFAULT 
)

Constructor of NetworkManagerTemplate.

Parameters
module_base_dirThe module basedir where to look for plugins
open_flagsflags to pass to modules when opening them

Definition at line 45 of file module_manager.cpp.

◆ ~ModuleManager()

fawkes::ModuleManager::~ModuleManager ( )
virtual

Destructor.

Definition at line 55 of file module_manager.cpp.

Member Function Documentation

◆ close_module() [1/2]

void fawkes::ModuleManager::close_module ( Module module)
virtual

Close a module by Module instance.

Parameters
moduleThe module that is to be closed

Definition at line 117 of file module_manager.cpp.

References fawkes::Module::get_base_filename().

Referenced by fawkes::BlackBoardInstanceFactory::delete_interface_instance().

◆ close_module() [2/2]

void fawkes::ModuleManager::close_module ( const char *  filename)
virtual

Close a module by filename.

Parameters
filenamethe name of the module file that should be closed, this is compared to loaded modules and must match what Module::GetBaseFilename() returns

Definition at line 129 of file module_manager.cpp.

References fawkes::Mutex::lock(), and fawkes::Mutex::unlock().

◆ get_module()

Module * fawkes::ModuleManager::get_module ( const char *  filename)
virtual

Get a module if opened.

This will return a pointer to a module if it had already been opened! The reference count is increased and you have to manually unref the module once you are done with it! This method works similar to open_module() with the difference that it is not tried to load the module if it is not open.

Parameters
filenamefile name of the module
Returns
a pointer to the module with the reference cound incremented by one if the module had been opened already or NULL if it was not opened.

Definition at line 153 of file module_manager.cpp.

Referenced by fawkes::BlackBoardInstanceFactory::delete_interface_instance().

◆ get_module_file_extension()

const char * fawkes::ModuleManager::get_module_file_extension ( )
virtual

Get the file extension for the current module type.

Returns
Returns a string with the file extension that has to be used for modules on the current system (for example "so")

Definition at line 183 of file module_manager.cpp.

References fawkes::Module::get_file_extension().

Referenced by fawkes::BlackBoardInstanceFactory::delete_interface_instance(), and fawkes::BlackBoardInstanceFactory::new_interface_instance().

◆ module_opened()

bool fawkes::ModuleManager::module_opened ( const char *  filename)
virtual

Check if the module is already opened.

Parameters
filenamethe name of the module file to check if it is opened. It is compared to loaded modules and must match what Module::get_base_filename() returns
Returns
true if module has been opened, false otherwise

Definition at line 172 of file module_manager.cpp.

◆ open_module()

Module * fawkes::ModuleManager::open_module ( const char *  filename)
virtual

Open a module.

Parameters
filenameThe file name of the module that should be opened. If the ModuleManager implementation takes a base dir argument (recommended) this filename is relative to that base dir
Returns
Returns the module if the file was opened successfully or NULL otherwise. Do NOT delete the module after usage but use closeModule to close it.
Exceptions
ModuleOpenExceptionthrown if the module could not be opened

Definition at line 87 of file module_manager.cpp.

References fawkes::Module::get_base_filename(), fawkes::Mutex::lock(), fawkes::Module::open(), and fawkes::Mutex::unlock().

Referenced by fawkes::BlackBoardInstanceFactory::new_interface_instance().

◆ set_open_flags()

void fawkes::ModuleManager::set_open_flags ( Module::ModuleFlags  open_flags)

Set flags to open modules with.

Parameters
open_flagsflags to pass to modules when opening them

Definition at line 70 of file module_manager.cpp.

Referenced by fawkes::PluginManager::PluginManager(), and fawkes::PluginManager::set_module_flags().


The documentation for this class was generated from the following files: