FEDEM Solver  R8.0
Source code of the dynamics solver
Public Member Functions | Protected Types | Protected Member Functions | Private Types | Static Private Member Functions | Private Attributes | List of all members
FFaDynamicLibraryBase Class Reference

Base class for dynamic loading of shared object libraries. More...

#include <FFaDynamicLibraryBase.H>

Inheritance diagram for FFaDynamicLibraryBase:
Inheritance graph
[legend]

Public Member Functions

bool load (const std::string &libName, bool silence=false)
 Loads the library named libName. More...
 
bool unload (const std::string &libName, bool silence=false)
 Unloads the library named libName. More...
 
void unloadAll ()
 Unloads all libraries and clears the function cache. More...
 
bool areLibsLoaded () const
 Returns whether dynamics libraries have been loaded or not. More...
 
const char * getLibrary (size_t idx=1) const
 Returns the file name of the dynamic library, if loaded. More...
 

Protected Types

enum  LanguageBinding { Undefined , C , Fortran }
 Enums defining the supported language bindings. More...
 

Protected Member Functions

 FFaDynamicLibraryBase ()
 Default constructor. More...
 
virtual ~FFaDynamicLibraryBase ()
 The destructor unloads all dynamically loaded libraries. More...
 
DLPROC getProcAddr (const std::string &fName, bool silence=false) const
 Returns the function pointer for the named function. More...
 
DLPROC getProcAddr (const std::string &cName, const std::string &fName, LanguageBinding &lang, bool silence=false) const
 Returns the function pointer for the named function. More...
 
DLPROC getProcAddress (const std::string &fName, size_t procID) const
 Returns the function pointer for the given function. More...
 
DLPROC getProcAddress (const std::string &cName, const std::string &fName, LanguageBinding &lang, size_t procID) const
 Returns the function pointer for the given function. More...
 

Private Types

typedef std::pair< LanguageBinding, void * > LibHandle
 Dynamic library handle with associated language binding. More...
 
typedef std::pair< DLPROC, LanguageBindingcache_info
 Function pointer with language binding. More...
 

Static Private Member Functions

static DLPROC getAddress (const LibHandle &lib, const std::string &fname)
 Returns the pointer to a named function. More...
 

Private Attributes

std::vector< cache_infomyProcCache
 Function pointer cache. More...
 
std::map< std::string, LibHandlemyLibHandles
 Dynamic library container. More...
 

Detailed Description

Base class for dynamic loading of shared object libraries.

Member Typedef Documentation

◆ cache_info

Function pointer with language binding.

◆ LibHandle

typedef std::pair<LanguageBinding,void*> FFaDynamicLibraryBase::LibHandle
private

Dynamic library handle with associated language binding.

Member Enumeration Documentation

◆ LanguageBinding

Enums defining the supported language bindings.

Enumerator
Undefined 
Fortran 

Constructor & Destructor Documentation

◆ FFaDynamicLibraryBase()

FFaDynamicLibraryBase::FFaDynamicLibraryBase ( )
inlineprotected

Default constructor.

◆ ~FFaDynamicLibraryBase()

virtual FFaDynamicLibraryBase::~FFaDynamicLibraryBase ( )
inlineprotectedvirtual

The destructor unloads all dynamically loaded libraries.

Member Function Documentation

◆ areLibsLoaded()

bool FFaDynamicLibraryBase::areLibsLoaded ( ) const
inline

Returns whether dynamics libraries have been loaded or not.

◆ getAddress()

DLPROC FFaDynamicLibraryBase::getAddress ( const LibHandle lib,
const std::string &  fname 
)
staticprivate

Returns the pointer to a named function.

◆ getLibrary()

const char * FFaDynamicLibraryBase::getLibrary ( size_t  idx = 1) const

Returns the file name of the dynamic library, if loaded.

◆ getProcAddr() [1/2]

DLPROC FFaDynamicLibraryBase::getProcAddr ( const std::string &  cName,
const std::string &  fName,
LanguageBinding lang,
bool  silence = false 
) const
protected

Returns the function pointer for the named function.

The language binding is set depending on whether the provided cName (C/C++) or fName (Fortran) is found.

◆ getProcAddr() [2/2]

DLPROC FFaDynamicLibraryBase::getProcAddr ( const std::string &  fName,
bool  silence = false 
) const
protected

Returns the function pointer for the named function.

Does not store the pointer in the cache, so this method should only be used for non-critical functions invoked only a few times.

◆ getProcAddress() [1/2]

DLPROC FFaDynamicLibraryBase::getProcAddress ( const std::string &  cName,
const std::string &  fName,
LanguageBinding lang,
size_t  procID 
) const
protected

Returns the function pointer for the given function.

The pointer is stored in a local cache to speed up repeated calls.

◆ getProcAddress() [2/2]

DLPROC FFaDynamicLibraryBase::getProcAddress ( const std::string &  fName,
size_t  procID 
) const
protected

Returns the function pointer for the given function.

The pointer is stored in a local cache to speed up repeated calls.

◆ load()

bool FFaDynamicLibraryBase::load ( const std::string &  libName,
bool  silence = false 
)

Loads the library named libName.

Returns
true if OK and false if the library is not available.

◆ unload()

bool FFaDynamicLibraryBase::unload ( const std::string &  libName,
bool  silence = false 
)

Unloads the library named libName.

Returns
true if found and false if the library was not loaded.

◆ unloadAll()

void FFaDynamicLibraryBase::unloadAll ( )

Unloads all libraries and clears the function cache.

Member Data Documentation

◆ myLibHandles

std::map<std::string,LibHandle> FFaDynamicLibraryBase::myLibHandles
private

Dynamic library container.

◆ myProcCache

std::vector<cache_info> FFaDynamicLibraryBase::myProcCache
mutableprivate

Function pointer cache.


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