Loading...
Searching...
No Matches
dlLibraryTable Class Reference

A table of dynamically loaded libraries. More...

#include <dlLibraryTable.H>

Public Types

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

Public Member Functions

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

Static Public Member Functions

static word basename (const fileName &libPath)
 Library basename without leading 'lib' or trailing '.so'.
static word fullname (word libName)
 Library fullname, prefix with 'lib', suffix with '.so'.
static dlLibraryTablelibs ()
 Table of global libraries.
static bool loadHook (void *handle, const std::string &funcName, const bool verbose=false, const std::string &context="")
 Low-level interface to execute global "void funcName(true)" from the library, typically for additional loading.
static bool unloadHook (void *handle, const std::string &funcName, const bool verbose=false, const std::string &context="")
 Low-level interface to execute global "void funcName(false)" from the library, typically for unloading.

Static Public Attributes

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

Detailed Description

A table of dynamically loaded libraries.

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

Definition at line 60 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 128 of file dlLibraryTable.H.

Constructor & Destructor Documentation

◆ dlLibraryTable() [1/7]

dlLibraryTable ( )
default

Default construct.

Referenced by dlLibraryTable(), dlLibraryTable(), dlLibraryTable(), libs(), operator=(), and operator=().

Here is the caller graph for this function:

◆ dlLibraryTable() [2/7]

dlLibraryTable ( const dlLibraryTable & )
delete

No copy construct.

References dlLibraryTable().

Here is the call graph for this function:

◆ dlLibraryTable() [3/7]

dlLibraryTable ( dlLibraryTable && )
default

Move construct.

References dlLibraryTable().

Here is the call graph for this function:

◆ 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 191 of file dlLibraryTable.C.

References 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 201 of file dlLibraryTable.C.

References 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 211 of file dlLibraryTable.C.

References dict, keyType::LITERAL, and open().

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 224 of file dlLibraryTable.C.

References dict, and dlLibraryTable().

Here is the call graph for this function:

◆ ~dlLibraryTable()

Destructor. Closes all libraries loaded by the table.

Definition at line 238 of file dlLibraryTable.C.

References close(), and dlcloseOnTerminate.

Here is the call graph for this function:

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.

References dlLibraryTable().

Here is the call graph for this function:

◆ operator=() [2/2]

dlLibraryTable & operator= ( dlLibraryTable && )
default

Move assignment.

References dict, dlLibraryTable(), loaded(), Foam::noexcept, and size().

Here is the call graph for this function:

◆ basename()

Foam::word basename ( const fileName & libPath)
static

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

Definition at line 53 of file dlLibraryTable.C.

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

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 61 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 73 of file dlLibraryTable.C.

References dlLibraryTable().

Referenced by renumberMethod::New().

Here is the call graph for this function:
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 134 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 146 of file dlLibraryTable.C.

◆ empty()

bool empty ( ) const
noexcept

True if there are no libraries loaded by the table.

Definition at line 249 of file dlLibraryTable.C.

References Foam::noexcept.

◆ size()

Foam::label size ( ) const
noexcept

The number of libraries loaded by the table.

Definition at line 263 of file dlLibraryTable.C.

References Foam::noexcept.

Referenced by operator=().

Here is the caller graph for this function:

◆ loaded()

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

Names of the libraries in use.

Definition at line 286 of file dlLibraryTable.C.

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

Referenced by operator=().

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

◆ names()

const UList< fileName > & names ( ) const
inlinenoexcept

Names of the libraries in use, or requested.

Definition at line 288 of file dlLibraryTable.H.

References names(), and Foam::noexcept.

Referenced by names().

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

◆ pointers()

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

Pointers to the libraries in use. Access with caution.

Definition at line 296 of file dlLibraryTable.H.

References Foam::noexcept.

◆ clear()

void clear ( )

Clears the table, without attempting to close the libraries.

Definition at line 279 of file dlLibraryTable.C.

◆ push_back() [1/2]

bool push_back ( const fileName & libName)

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

Ignores empty and duplicate names.

Definition at line 372 of file dlLibraryTable.C.

References string::contains().

Referenced by append(), append(), and push_back().

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

◆ push_back() [2/2]

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

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

Ignores empty and duplicate names.

Definition at line 386 of file dlLibraryTable.C.

References push_back().

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 push_back().

Definition at line 402 of file dlLibraryTable.C.

References forAll.

Referenced by dlLibraryTable(), dlLibraryTable(), dlLibraryTable(), GAMGAgglomeration::New(), renumberMethod::New(), open(), open(), open(), open(), and 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 434 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 453 of file dlLibraryTable.C.

References 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 480 of file dlLibraryTable.C.

References 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 310 of file dlLibraryTable.C.

References DebugInFunction, Foam::dlClose(), Foam::endl(), forAll, forAllReverse, Foam::name(), Foam::nl, List< T >::resize(), and WarningInFunction.

Referenced by ~dlLibraryTable().

Here is the call graph for this function:
Here is the caller 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 507 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 563 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 576 of file dlLibraryTable.C.

References dict, keyType::LITERAL, and open().

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 592 of file dlLibraryTable.C.

References dict, and open().

Here is the call graph for this function:

◆ open() [7/7]

template<class TablePtr>
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 28 of file dlLibraryTableTemplates.C.

References dict, Foam::endl(), keyType::LITERAL, Foam::nl, open(), UList< T >::size(), and WarningInFunction.

Here is the call graph for this function:

◆ info()

InfoProxy< dlLibraryTable > info ( ) const
inlinenoexcept

Return info proxy, used to print library table information to a stream.

Definition at line 412 of file dlLibraryTable.H.

References Foam::noexcept.

◆ append() [1/2]

bool append ( const fileName & libName)
inline

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

FOAM_DEPRECATED_FOR(2024-04, "push_back()")

Definition at line 422 of file dlLibraryTable.H.

References push_back().

Here is the call graph for this function:

◆ append() [2/2]

label append ( const UList< fileName > & libNames)
inline

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

FOAM_DEPRECATED_FOR(2024-04, "push_back()")

Definition at line 432 of file dlLibraryTable.H.

References push_back().

Here is the call graph for this function:

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 118 of file dlLibraryTable.H.

Referenced by ~dlLibraryTable().


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