![]() |
An open-source, flexible 3D physical simulation framework
|
#include <LibManager.hpp>
Public Types | |
enum | ErrorNumber { LIBMGR_NO_ERROR = 0, LIBMGR_ERR_NO_LIBRARY = 1, LIBMGR_ERR_LIBNAME_EXISTS = 2, LIBMGR_ERR_NOT_ABLE_TO_LOAD = 3, LIBMGR_ERR_LIB_IN_USE = 4 } |
Public Member Functions | |
LibManager () | |
~LibManager () | |
void | addLibrary (LibInterface *_lib) |
Registers a new library. More... | |
ErrorNumber | loadLibrary (const std::string &libPath, void *config=NULL, bool silent=false, bool noCallback=false) |
Loads a library from a specified path from the hard drive. More... | |
std::string | findLibrary (const std::string &libName) |
Searches for a library on the hard drive by checking the PATH environment. More... | |
LibInterface * | acquireLibrary (const std::string &libName) |
Returns a pointer to the libStruct associated with the requested library. More... | |
template<typename T > | |
T * | acquireLibraryAs (const std::string &libName, bool load=false) |
LibInterface * | getLibrary (const std::string &libName) |
template<typename T > | |
T * | getLibraryAs (const std::string &libName, bool load=false) |
ErrorNumber | releaseLibrary (const std::string &libName) |
Releases a previously acquired library. More... | |
ErrorNumber | unloadLibrary (const std::string &libPath) |
This method is not to be directly called. More... | |
void | loadConfigFile (const std::string &config_file) |
Loads all libraries specified in a configuration file. More... | |
void | getAllLibraries (std::list< LibInterface *> *libList) |
Accepts a pointer to a list of type LibInterface and appends pointers to all registered libraries. More... | |
void | getAllLibraryNames (std::list< std::string > *libNameList) const |
Accepts a pointer to a string list and appends the names of the registered libraries. More... | |
LibInfo | getLibraryInfo (const std::string &libName) const |
Accepts a constant string and returns a LibInfo struct. More... | |
void | dumpTo (const std::string &filename) const |
Writes the names, source and revision of all registered libraries to the specified file. More... | |
void | clearLibraries (void) |
Empties the libMap field and deletes all items (libStructs) from memory. More... | |
Public Attributes | |
std::string | errMessage [5] |
Private Attributes | |
std::map< std::string, libStruct > | libMap |
The container in which information on all managed libraries is stored. More... | |
Definition at line 62 of file LibManager.hpp.
Enumerator | |
---|---|
LIBMGR_NO_ERROR | |
LIBMGR_ERR_NO_LIBRARY | |
LIBMGR_ERR_LIBNAME_EXISTS | |
LIBMGR_ERR_NOT_ABLE_TO_LOAD | |
LIBMGR_ERR_LIB_IN_USE |
Definition at line 65 of file LibManager.hpp.
lib_manager::LibManager::LibManager | ( | ) |
Definition at line 64 of file LibManager.cpp.
lib_manager::LibManager::~LibManager | ( | ) |
Definition at line 72 of file LibManager.cpp.
LibInterface * lib_manager::LibManager::acquireLibrary | ( | const std::string & | libName | ) |
Returns a pointer to the libStruct associated with the requested library.
libName | The name of the requested library. |
Definition at line 294 of file LibManager.cpp.
T * lib_manager::LibManager::acquireLibraryAs | ( | const std::string & | libName, |
bool | load = false |
||
) |
Definition at line 113 of file LibManager.hpp.
void lib_manager::LibManager::addLibrary | ( | LibInterface * | _lib | ) |
Registers a new library.
An associated libStruct is created and all other registered libraries are informed about the new library by calling the newLibLoaded() method of their interface.
_lib | A pointer to any class implementing the LibInterface. |
Definition at line 128 of file LibManager.cpp.
void lib_manager::LibManager::clearLibraries | ( | void | ) |
Empties the libMap field and deletes all items (libStructs) from memory.
Definition at line 99 of file LibManager.cpp.
void lib_manager::LibManager::dumpTo | ( | const std::string & | filepath | ) | const |
Writes the names, source and revision of all registered libraries to the specified file.
filepath | The path of the file where the names should be dumped. |
Definition at line 436 of file LibManager.cpp.
std::string lib_manager::LibManager::findLibrary | ( | const std::string & | libName | ) |
Searches for a library on the hard drive by checking the PATH environment.
libName | Can be the name of the library or the whole path. |
Definition at line 219 of file LibManager.cpp.
void lib_manager::LibManager::getAllLibraries | ( | std::list< LibInterface *> * | libList | ) |
Accepts a pointer to a list of type LibInterface and appends pointers to all registered libraries.
libList |
Definition at line 392 of file LibManager.cpp.
void lib_manager::LibManager::getAllLibraryNames | ( | std::list< std::string > * | libNameList | ) | const |
Accepts a pointer to a string list and appends the names of the registered libraries.
libNameList | A pointer to a list of strings. |
Definition at line 404 of file LibManager.cpp.
|
inline |
Definition at line 89 of file LibManager.hpp.
|
inline |
Definition at line 91 of file LibManager.hpp.
LibInfo lib_manager::LibManager::getLibraryInfo | ( | const std::string & | libName | ) | const |
Accepts a constant string and returns a LibInfo struct.
libName |
Definition at line 416 of file LibManager.cpp.
void lib_manager::LibManager::loadConfigFile | ( | const std::string & | config_file | ) |
Loads all libraries specified in a configuration file.
The configuration file has to be a text file that contains one library path per line; each can have a maximum length of 255 characters.
config_file |
Definition at line 353 of file LibManager.cpp.
LibManager::ErrorNumber lib_manager::LibManager::loadLibrary | ( | const std::string & | libPath, |
void * | config = NULL , |
||
bool | silent = false , |
||
bool | noCallback = false |
||
) |
Loads a library from a specified path from the hard drive.
This function can be used to load a library (or plugin) through the LibManager at runtime rather than adding an already-existing instance with the addLibrary method.
libPath | The path to the library. |
config |
Definition at line 161 of file LibManager.cpp.
LibManager::ErrorNumber lib_manager::LibManager::releaseLibrary | ( | const std::string & | libName | ) |
Releases a previously acquired library.
libName |
Definition at line 311 of file LibManager.cpp.
LibManager::ErrorNumber lib_manager::LibManager::unloadLibrary | ( | const std::string & | libPath | ) |
This method is not to be directly called.
Use releaseLibrary() instead.
Definition at line 326 of file LibManager.cpp.
std::string lib_manager::LibManager::errMessage[5] |
Definition at line 73 of file LibManager.hpp.
|
private |
The container in which information on all managed libraries is stored.
Definition at line 107 of file LibManager.hpp.