nidas  v1.2-1520
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
nidas::core::DynamicLoader Class Reference

Class providing dynamic loader functionality of system functions dlopen() and dlsym() to look up symbols. More...

#include <DynamicLoader.h>

Public Member Functions

void * lookup (const std::string &name) throw (nidas::util::Exception)
 Search the main program itself, and its currently loaded libraries for a symbol. More...
 
void * lookup (const std::string &library, const std::string &name) throw (nidas::util::Exception)
 Return a pointer to a symbol from the given library. More...
 

Static Public Member Functions

static DynamicLoadergetInstance () throw (nidas::util::Exception)
 Get a pointer to the singleton instance of DynamicLoader. More...
 

Private Member Functions

 DynamicLoader () throw (nidas::util::Exception)
 
 DynamicLoader (const DynamicLoader &)
 No copy. More...
 
DynamicLoaderoperator= (const DynamicLoader &)
 No assignment. More...
 
 ~DynamicLoader ()
 

Private Attributes

void * _defhandle
 Handle, returned by dlopen(), of the program itself, and its linked and dynamically loaded libraries. More...
 
std::map< std::string, void * > _libhandles
 Handles, by library name, returned by dlopen() of libraries that are currently open, because one or more symbols have been found in them. More...
 

Static Private Attributes

static DynamicLoader_instance = 0
 
static nidas::util::Mutex _instanceLock
 

Detailed Description

Class providing dynamic loader functionality of system functions dlopen() and dlsym() to look up symbols.

Constructor & Destructor Documentation

DynamicLoader::DynamicLoader ( )
throw (nidas::util::Exception
)
private

References _defhandle.

Referenced by getInstance().

nidas::core::DynamicLoader::DynamicLoader ( const DynamicLoader )
private

No copy.

DynamicLoader::~DynamicLoader ( )
private

Member Function Documentation

DynamicLoader * DynamicLoader::getInstance ( )
throw (nidas::util::Exception
)
static

Get a pointer to the singleton instance of DynamicLoader.

References _instance, _instanceLock, and DynamicLoader().

Referenced by nidas::core::DOMObjectFactory::createObject().

void * DynamicLoader::lookup ( const std::string &  name)
throw (nidas::util::Exception
)

Search the main program itself, and its currently loaded libraries for a symbol.

Throws an exception if the lookup fails.

Referenced by nidas::core::DOMObjectFactory::createObject().

void* nidas::core::DynamicLoader::lookup ( const std::string &  library,
const std::string &  name 
)
throw (nidas::util::Exception
)

Return a pointer to a symbol from the given library.

@ param library: name of the library. @ param name: name of the symbol to look up.

If the library name is an empty string, then the libraries linked with the program, and any currently loaded dynamic libraries will be searched. If the library name is absolute (begins with a forward slash), then it is loaded. Otherwise a search for the library is done, using the program's library directory search path, which is controlled by compile time flags, the LD_LIBRARY_PATH environment variable, and ld.so/ldconfig/ld.so.conf. lookup() throws an exception if the library could not be found and loaded or the symbol could not be found in the library. If the symbol is found, the library will remain loaded, and symbols in that library can then be found via lookup(name), or by specifying an emptry string for the library.

DynamicLoader& nidas::core::DynamicLoader::operator= ( const DynamicLoader )
private

No assignment.

Member Data Documentation

void* nidas::core::DynamicLoader::_defhandle
private

Handle, returned by dlopen(), of the program itself, and its linked and dynamically loaded libraries.

Referenced by DynamicLoader().

DynamicLoader * DynamicLoader::_instance = 0
staticprivate

Referenced by getInstance().

n_u::Mutex DynamicLoader::_instanceLock
staticprivate

Referenced by getInstance().

std::map<std::string,void*> nidas::core::DynamicLoader::_libhandles
private

Handles, by library name, returned by dlopen() of libraries that are currently open, because one or more symbols have been found in them.


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