nidas v1.2.3
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

voidlookup (const std::string &name)
 Search the main program itself, and its currently loaded libraries for a symbol.
 
voidlookup (const std::string &library, const std::string &name)
 Return a pointer to a symbol from the given library.
 

Static Public Member Functions

static DynamicLoadergetInstance ()
 Get a pointer to the singleton instance of DynamicLoader.
 

Private Member Functions

 DynamicLoader ()
 
 DynamicLoader (const DynamicLoader &)
 No copy.
 
DynamicLoaderoperator= (const DynamicLoader &)
 No assignment.
 
 ~DynamicLoader ()
 

Private Attributes

void_defhandle
 Handle, returned by dlopen(), of the program itself, and its linked and dynamically loaded libraries.
 
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.
 

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() [1/2]

DynamicLoader::DynamicLoader ( )
private

◆ DynamicLoader() [2/2]

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

No copy.

◆ ~DynamicLoader()

DynamicLoader::~DynamicLoader ( )
private

Member Function Documentation

◆ getInstance()

DynamicLoader * DynamicLoader::getInstance ( )
static

Get a pointer to the singleton instance of DynamicLoader.

Exceptions
nidas::util::Exception

References _instance, _instanceLock, DynamicLoader(), and nidas::core::getSample().

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

◆ lookup() [1/2]

void * DynamicLoader::lookup ( const std::string & library,
const std::string & name )

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.

Exceptions
nidas::util::Exception

References _instanceLock, _libhandles, and nidas::core::getSample().

◆ lookup() [2/2]

void * DynamicLoader::lookup ( const std::string & name)

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

Throws an exception if the lookup fails.

Exceptions
nidas::util::Exception

References _defhandle, _instanceLock, and nidas::core::getSample().

◆ operator=()

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

No assignment.

Member Data Documentation

◆ _defhandle

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

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

Referenced by DynamicLoader(), and lookup().

◆ _instance

DynamicLoader * DynamicLoader::_instance = 0
staticprivate

Referenced by getInstance().

◆ _instanceLock

n_u::Mutex DynamicLoader::_instanceLock
staticprivate

Referenced by getInstance(), lookup(), and lookup().

◆ _libhandles

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.

Referenced by DynamicLoader(), and lookup().


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