Privacy
An open-source, flexible 3D physical simulation framework
lib_manager::LibManager Class Reference

#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...
 
LibInterfaceacquireLibrary (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)
 
LibInterfacegetLibrary (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, libStructlibMap
 The container in which information on all managed libraries is stored. More...
 

Detailed Description

Definition at line 62 of file LibManager.hpp.

Member Enumeration Documentation

◆ ErrorNumber

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.

Constructor & Destructor Documentation

◆ LibManager()

lib_manager::LibManager::LibManager ( )

Definition at line 64 of file LibManager.cpp.

◆ ~LibManager()

lib_manager::LibManager::~LibManager ( )

Definition at line 72 of file LibManager.cpp.

Member Function Documentation

◆ acquireLibrary()

LibInterface * lib_manager::LibManager::acquireLibrary ( const std::string &  libName)

Returns a pointer to the libStruct associated with the requested library.

Parameters
libNameThe name of the requested library.
Returns
A libStruct* if library is registered, otherwise 0.

Definition at line 294 of file LibManager.cpp.

◆ acquireLibraryAs()

template<typename T >
T * lib_manager::LibManager::acquireLibraryAs ( const std::string &  libName,
bool  load = false 
)

Definition at line 113 of file LibManager.hpp.

◆ addLibrary()

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.

Parameters
_libA pointer to any class implementing the LibInterface.

Definition at line 128 of file LibManager.cpp.

◆ clearLibraries()

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.

◆ dumpTo()

void lib_manager::LibManager::dumpTo ( const std::string &  filepath) const

Writes the names, source and revision of all registered libraries to the specified file.

Parameters
filepathThe path of the file where the names should be dumped.

Definition at line 436 of file LibManager.cpp.

◆ findLibrary()

std::string lib_manager::LibManager::findLibrary ( const std::string &  libName)

Searches for a library on the hard drive by checking the PATH environment.

Parameters
libNameCan be the name of the library or the whole path.
Returns
libPath

Definition at line 219 of file LibManager.cpp.

◆ getAllLibraries()

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.

Parameters
libList

Definition at line 392 of file LibManager.cpp.

◆ getAllLibraryNames()

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.

Parameters
libNameListA pointer to a list of strings.

Definition at line 404 of file LibManager.cpp.

◆ getLibrary()

LibInterface* lib_manager::LibManager::getLibrary ( const std::string &  libName)
inline

Definition at line 89 of file LibManager.hpp.

◆ getLibraryAs()

template<typename T >
T* lib_manager::LibManager::getLibraryAs ( const std::string &  libName,
bool  load = false 
)
inline

Definition at line 91 of file LibManager.hpp.

◆ getLibraryInfo()

LibInfo lib_manager::LibManager::getLibraryInfo ( const std::string &  libName) const

Accepts a constant string and returns a LibInfo struct.

Parameters
libName
Returns

Definition at line 416 of file LibManager.cpp.

◆ loadConfigFile()

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.

Parameters
config_file

Definition at line 353 of file LibManager.cpp.

◆ loadLibrary()

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.

Parameters
libPathThe path to the library.
config
Returns

Definition at line 161 of file LibManager.cpp.

◆ releaseLibrary()

LibManager::ErrorNumber lib_manager::LibManager::releaseLibrary ( const std::string &  libName)

Releases a previously acquired library.

Parameters
libName
Returns

Definition at line 311 of file LibManager.cpp.

◆ unloadLibrary()

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.

Member Data Documentation

◆ errMessage

std::string lib_manager::LibManager::errMessage[5]

Definition at line 73 of file LibManager.hpp.

◆ libMap

std::map<std::string, libStruct> lib_manager::LibManager::libMap
private

The container in which information on all managed libraries is stored.

Definition at line 107 of file LibManager.hpp.


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