dlLibraryTable Class Reference

A table of dynamically loaded libraries. More...

Public Types

typedef void(* loaderType) (bool)
 Global loader/unloader function type (C-linkage) More...
 

Public Member Functions

 ClassName ("dlLibraryTable")
 Declare name of the class and its debug switch. More...
 
 dlLibraryTable ()=default
 Default construct. More...
 
 dlLibraryTable (const dlLibraryTable &)=delete
 No copy construct. More...
 
 dlLibraryTable (dlLibraryTable &&)=default
 Move construct. More...
 
void operator= (const dlLibraryTable &)=delete
 No copy assignment. More...
 
dlLibraryTableoperator= (dlLibraryTable &&)=default
 Move assignment. More...
 
 dlLibraryTable (const UList< fileName > &libNames, bool verbose=true)
 Open specified libraries, warn by default if problems occur. More...
 
 dlLibraryTable (std::initializer_list< fileName > libNames, bool verbose=true)
 Open specified libraries, warn by default if problems occur. More...
 
 dlLibraryTable (const word &libsEntry, const dictionary &dict, bool verbose=true)
 
 dlLibraryTable (const dictionary &dict, const word &libsEntry, bool verbose=true)
 
 ~dlLibraryTable ()
 Destructor. Closes all libraries loaded by the table. More...
 
bool empty () const
 True if there are no libraries loaded by the table. More...
 
label size () const
 The number of libraries loaded by the table. More...
 
List< fileNameloaded () const
 Names of the libraries in use. More...
 
const UList< fileName > & names () const
 Names of the libraries in use, or requested. More...
 
const UList< void * > & pointers () const
 Pointers to the libraries in use. Access with caution. More...
 
void clear ()
 Clears the table, without attempting to close the libraries. More...
 
bool append (const fileName &libName)
 Add to the list of names, but do not yet open. More...
 
label append (const UList< fileName > &libNames)
 Add to the list of names, but do not yet open. More...
 
bool open (bool verbose=true)
 
void * open (const fileName &libName, bool verbose=true)
 Open the named library, warn by default if problems occur. More...
 
bool open (const UList< fileName > &libNames, bool verbose=true)
 Open the named libraries, warn by default if problems occur. More...
 
bool open (std::initializer_list< fileName > libNames, bool verbose=true)
 Open the named libraries, warn by default if problems occur. More...
 
void close (bool verbose=true)
 
bool close (const fileName &libName, bool verbose=true)
 Close the named library, optionally warn if problems occur. More...
 
void * findLibrary (const fileName &libName)
 Find the handle of the named library. More...
 
bool open (const word &libsEntry, const dictionary &dict, bool verbose=true)
 Open libraries listed in the 'libsEntry' entry in the dictionary. More...
 
bool open (const dictionary &dict, const word &libsEntry)
 Open libraries listed in the 'libsEntry' entry in the dictionary. More...
 
template<class TablePtr >
bool open (const dictionary &dict, const word &libsEntry, const TablePtr &tablePtr, bool verbose=true)
 
InfoProxy< dlLibraryTableinfo () const
 Return info proxy. More...
 

Static Public Member Functions

static word basename (const fileName &libPath)
 Library basename without leading 'lib' or trailing '.so'. More...
 
static word fullname (word libName)
 Library fullname, prefix with 'lib', suffix with '.so'. More...
 
static dlLibraryTablelibs ()
 Table of global libraries. More...
 
static bool loadHook (void *handle, const std::string &funcName, const bool verbose=false, const std::string &context="")
 
static bool unloadHook (void *handle, const std::string &funcName, const bool verbose=false, const std::string &context="")
 

Static Public Attributes

static int dlcloseOnTerminate
 Use dlclose() when clearing the dlLibraryTable. More...
 

Detailed Description

A table of dynamically loaded libraries.

See also
Foam::dlOpen Foam::dlClose
Source files

Definition at line 63 of file dlLibraryTable.H.

Member Typedef Documentation

◆ loaderType

typedef void(* loaderType(bool)

Global loader/unloader function type (C-linkage)

Called with true on load, false on unload.

Definition at line 113 of file dlLibraryTable.H.

Constructor & Destructor Documentation

◆ dlLibraryTable() [1/7]

dlLibraryTable ( )
default

Default construct.

◆ dlLibraryTable() [2/7]

dlLibraryTable ( const dlLibraryTable )
delete

No copy construct.

◆ dlLibraryTable() [3/7]

dlLibraryTable ( dlLibraryTable &&  )
default

Move construct.

◆ dlLibraryTable() [4/7]

dlLibraryTable ( const UList< fileName > &  libNames,
bool  verbose = true 
)
explicit

Open specified libraries, warn by default if problems occur.

Ignores duplicate names.

Definition at line 199 of file dlLibraryTable.C.

References dlLibraryTable::open().

Here is the call graph for this function:

◆ dlLibraryTable() [5/7]

dlLibraryTable ( std::initializer_list< fileName libNames,
bool  verbose = true 
)
explicit

Open specified libraries, warn by default if problems occur.

Ignores duplicate names.

Definition at line 209 of file dlLibraryTable.C.

References dlLibraryTable::open().

Here is the call graph for this function:

◆ dlLibraryTable() [6/7]

dlLibraryTable ( const word libsEntry,
const dictionary dict,
bool  verbose = true 
)

Open libraries listed in 'libsEntry' entry in the dictionary, warn by default if problems occur

Definition at line 219 of file dlLibraryTable.C.

References dict, dlLibraryTable::open(), and dictionary::readIfPresent().

Here is the call graph for this function:

◆ dlLibraryTable() [7/7]

dlLibraryTable ( const dictionary dict,
const word libsEntry,
bool  verbose = true 
)

Open libraries listed in 'libsEntry' entry in the dictionary, warn by default if problems occur

Definition at line 232 of file dlLibraryTable.C.

◆ ~dlLibraryTable()

Destructor. Closes all libraries loaded by the table.

Definition at line 245 of file dlLibraryTable.C.

References dlLibraryTable::dlcloseOnTerminate.

Member Function Documentation

◆ ClassName()

ClassName ( "dlLibraryTable"  )

Declare name of the class and its debug switch.

◆ operator=() [1/2]

void operator= ( const dlLibraryTable )
delete

No copy assignment.

◆ operator=() [2/2]

dlLibraryTable& operator= ( dlLibraryTable &&  )
default

Move assignment.

◆ basename()

Foam::word basename ( const fileName libPath)
static

Library basename without leading 'lib' or trailing '.so'.

Definition at line 60 of file dlLibraryTable.C.

References fileName::nameLessExt(), and string::removeStart().

Referenced by codedBase::updateLibrary().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fullname()

Foam::word fullname ( word  libName)
static

Library fullname, prefix with 'lib', suffix with '.so'.

Note
the suffix is system-dependent

Definition at line 68 of file dlLibraryTable.C.

References word::ext(), and EXT_SO.

Referenced by dynamicCode::libPath(), and dynamicCode::libRelPath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ libs()

Foam::dlLibraryTable & libs ( )
static

Table of global libraries.

Definition at line 80 of file dlLibraryTable.C.

Referenced by CodedField< Type >::libs(), CodedFunction1< Type >::libs(), codedMixedFvPatchField< Type >::libs(), and CodedSource< Type >::libs().

Here is the caller graph for this function:

◆ loadHook()

bool loadHook ( void *  handle,
const std::string &  funcName,
const bool  verbose = false,
const std::string &  context = "" 
)
static

Low-level interface to execute global "void funcName(true)" from the library, typically for additional loading.

If called, it should be the first step after opening a library.

Returns
true if the function was found and executed
Parameters
contextCalling context for warnings

Definition at line 142 of file dlLibraryTable.C.

◆ unloadHook()

bool unloadHook ( void *  handle,
const std::string &  funcName,
const bool  verbose = false,
const std::string &  context = "" 
)
static

Low-level interface to execute global "void funcName(false)" from the library, typically for unloading.

If called, it should be the last step before closing a library.

Returns
true if the function was found and executed
Parameters
contextCalling context for warnings

Definition at line 154 of file dlLibraryTable.C.

◆ empty()

bool empty ( ) const

True if there are no libraries loaded by the table.

Definition at line 256 of file dlLibraryTable.C.

◆ size()

Foam::label size ( ) const

The number of libraries loaded by the table.

Definition at line 270 of file dlLibraryTable.C.

◆ loaded()

Foam::List< Foam::fileName > loaded ( ) const

Names of the libraries in use.

Definition at line 293 of file dlLibraryTable.C.

References forAll, and List< T >::resize().

Here is the call graph for this function:

◆ names()

const UList<fileName>& names ( ) const
inline

Names of the libraries in use, or requested.

Definition at line 228 of file dlLibraryTable.H.

Referenced by Foam::operator<<().

Here is the caller graph for this function:

◆ pointers()

const UList<void*>& pointers ( ) const
inline

Pointers to the libraries in use. Access with caution.

Definition at line 234 of file dlLibraryTable.H.

Referenced by Foam::operator<<().

Here is the caller graph for this function:

◆ clear()

void clear ( )

Clears the table, without attempting to close the libraries.

Definition at line 286 of file dlLibraryTable.C.

◆ append() [1/2]

bool append ( const fileName libName)

Add to the list of names, but do not yet open.

Ignores duplicate names.

Definition at line 379 of file dlLibraryTable.C.

◆ append() [2/2]

Foam::label append ( const UList< fileName > &  libNames)

Add to the list of names, but do not yet open.

Ignores duplicate names.

Definition at line 393 of file dlLibraryTable.C.

References append().

Here is the call graph for this function:

◆ open() [1/7]

bool open ( bool  verbose = true)

Open named, but unopened libraries. These names will normally have been added with the append() method.

Definition at line 409 of file dlLibraryTable.C.

References forAll.

Referenced by dlLibraryTable::dlLibraryTable(), dynamicFvMesh::New(), GAMGAgglomeration::New(), functionObject::New(), and dlLibraryTable::open().

Here is the caller graph for this function:

◆ open() [2/7]

void * open ( const fileName libName,
bool  verbose = true 
)

Open the named library, warn by default if problems occur.

An empty name is a silent no-op and always returns nullptr.

Returns
a pointer to the library opened, or nullptr on failure.

Definition at line 442 of file dlLibraryTable.C.

◆ open() [3/7]

bool open ( const UList< fileName > &  libNames,
bool  verbose = true 
)

Open the named libraries, warn by default if problems occur.

Ignores duplicate names.

Definition at line 461 of file dlLibraryTable.C.

References dlLibraryTable::open(), and UList< T >::size().

Here is the call graph for this function:

◆ open() [4/7]

bool open ( std::initializer_list< fileName libNames,
bool  verbose = true 
)

Open the named libraries, warn by default if problems occur.

Ignores duplicate names.

Definition at line 488 of file dlLibraryTable.C.

References dlLibraryTable::open().

Here is the call graph for this function:

◆ close() [1/2]

void close ( bool  verbose = true)

Close all libraries loaded by the table and remove the closed functions from the table.

Definition at line 317 of file dlLibraryTable.C.

References DebugInFunction, Foam::dlClose(), Foam::endl(), forAll, forAllReverse, Foam::name(), Foam::nl, and WarningInFunction.

Here is the call graph for this function:

◆ close() [2/2]

bool close ( const fileName libName,
bool  verbose = true 
)

Close the named library, optionally warn if problems occur.

Using an empty name is a no-op and always returns false.

Definition at line 515 of file dlLibraryTable.C.

References DebugInFunction, Foam::dlClose(), Foam::endl(), Foam::name(), Foam::nl, and WarningInFunction.

Here is the call graph for this function:

◆ findLibrary()

void * findLibrary ( const fileName libName)

Find the handle of the named library.

Using an empty name is a no-op and always returns nullptr.

Definition at line 570 of file dlLibraryTable.C.

◆ open() [5/7]

bool open ( const word libsEntry,
const dictionary dict,
bool  verbose = true 
)

Open libraries listed in the 'libsEntry' entry in the dictionary.

Definition at line 584 of file dlLibraryTable.C.

References dict, dlLibraryTable::open(), and dictionary::readIfPresent().

Here is the call graph for this function:

◆ open() [6/7]

bool open ( const dictionary dict,
const word libsEntry 
)

Open libraries listed in the 'libsEntry' entry in the dictionary.

Verbose = true

Definition at line 600 of file dlLibraryTable.C.

References dict, and dlLibraryTable::open().

Here is the call graph for this function:

◆ open() [7/7]

bool open ( const dictionary dict,
const word libsEntry,
const TablePtr &  tablePtr,
bool  verbose = true 
)

Open all libraries listed in the 'libsEntry' entry in the given dictionary and check the additions to the given constructor table

Definition at line 36 of file dlLibraryTableTemplates.C.

References Foam::expressions::patchExpr::debug, dict, Foam::endl(), Foam::nl, and WarningInFunction.

Here is the call graph for this function:

◆ info()

InfoProxy<dlLibraryTable> info ( ) const
inline

Return info proxy.

Used to print library table information to a stream

Definition at line 312 of file dlLibraryTable.H.

Member Data Documentation

◆ dlcloseOnTerminate

int dlcloseOnTerminate
static

Use dlclose() when clearing the dlLibraryTable.

This is presumably cleaner, but can also remove functions that are still needed (eg, to terminate the library itself)

Definition at line 106 of file dlLibraryTable.H.

Referenced by dlLibraryTable::~dlLibraryTable().


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