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... | |
dlLibraryTable & | operator= (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) | |
Open libraries listed in 'libsEntry' entry in the dictionary, warn by default if problems occur. More... | |
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. More... | |
~dlLibraryTable () | |
Destructor. Closes all libraries loaded by the table. More... | |
bool | empty () const noexcept |
True if there are no libraries loaded by the table. More... | |
label | size () const noexcept |
The number of libraries loaded by the table. More... | |
List< fileName > | loaded () const |
Names of the libraries in use. More... | |
const UList< fileName > & | names () const noexcept |
Names of the libraries in use, or requested. More... | |
const UList< void * > & | pointers () const noexcept |
Pointers to the libraries in use. Access with caution. More... | |
void | clear () |
Clears the table, without attempting to close the libraries. More... | |
bool | push_back (const fileName &libName) |
Add to the list of names, but do not yet open. More... | |
label | push_back (const UList< fileName > &libNames) |
Add to the list of names, but do not yet open. More... | |
bool | open (bool verbose=true) |
Open named, but unopened libraries. These names will normally have been added with push_back(). More... | |
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) |
Close all libraries loaded by the table and remove the closed functions from the table. More... | |
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) |
Open all libraries listed in the 'libsEntry' entry in the given dictionary and check the additions to the given constructor table. More... | |
InfoProxy< dlLibraryTable > | info () const noexcept |
Return info proxy, used to print library table information to a stream. 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... | |
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 dlLibraryTable & | libs () |
Table of global libraries. More... | |
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. More... | |
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. More... | |
Static Public Attributes | |
static int | dlcloseOnTerminate |
Use dlclose() when clearing the dlLibraryTable. More... | |
A table of dynamically loaded libraries.
Definition at line 60 of file dlLibraryTable.H.
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.
|
default |
Default construct.
|
delete |
No copy construct.
|
default |
Move construct.
|
explicit |
Open specified libraries, warn by default if problems occur.
Ignores duplicate names.
Definition at line 192 of file dlLibraryTable.C.
References dlLibraryTable::open().
|
explicit |
Open specified libraries, warn by default if problems occur.
Ignores duplicate names.
Definition at line 202 of file dlLibraryTable.C.
References dlLibraryTable::open().
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 212 of file dlLibraryTable.C.
References dict, keyType::LITERAL, dlLibraryTable::open(), and dictionary::readIfPresent().
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 225 of file dlLibraryTable.C.
~dlLibraryTable | ( | ) |
Destructor. Closes all libraries loaded by the table.
Definition at line 238 of file dlLibraryTable.C.
References dlLibraryTable::dlcloseOnTerminate.
ClassName | ( | "dlLibraryTable" | ) |
Declare name of the class and its debug switch.
|
delete |
No copy assignment.
|
default |
Move assignment.
|
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().
|
static |
Library fullname, prefix with 'lib', suffix with '.so'.
Definition at line 61 of file dlLibraryTable.C.
References word::ext(), and EXT_SO.
Referenced by dynamicCode::libPath(), and dynamicCode::libRelPath().
|
static |
Table of global libraries.
Definition at line 73 of file dlLibraryTable.C.
Referenced by CodedField< Type >::libs(), CodedFunction1< Type >::libs(), codedMixedFvPatchField< Type >::libs(), CodedSource< Type >::libs(), and renumberMethod::New().
|
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.
context | Calling context for warnings |
Definition at line 135 of file dlLibraryTable.C.
|
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.
context | Calling context for warnings |
Definition at line 147 of file dlLibraryTable.C.
|
noexcept |
True if there are no libraries loaded by the table.
Definition at line 249 of file dlLibraryTable.C.
|
noexcept |
The number of libraries loaded by the table.
Definition at line 263 of file dlLibraryTable.C.
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().
Names of the libraries in use, or requested.
Definition at line 288 of file dlLibraryTable.H.
|
inlinenoexcept |
Pointers to the libraries in use. Access with caution.
Definition at line 296 of file dlLibraryTable.H.
void clear | ( | ) |
Clears the table, without attempting to close the libraries.
Definition at line 279 of file dlLibraryTable.C.
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 dlLibraryTable::append().
Add to the list of names, but do not yet open.
Ignores empty and duplicate names.
Definition at line 386 of file dlLibraryTable.C.
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(), renumberMethod::New(), GAMGAgglomeration::New(), functionObject::New(), and dlLibraryTable::open().
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.
Definition at line 435 of file dlLibraryTable.C.
Open the named libraries, warn by default if problems occur.
Ignores duplicate names.
Definition at line 454 of file dlLibraryTable.C.
References dlLibraryTable::open(), and UList< T >::size().
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 481 of file dlLibraryTable.C.
References dlLibraryTable::open().
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, and WarningInFunction.
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 508 of file dlLibraryTable.C.
References DebugInFunction, Foam::dlClose(), Foam::endl(), Foam::name(), Foam::nl, and WarningInFunction.
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.
bool open | ( | const word & | libsEntry, |
const dictionary & | dict, | ||
bool | verbose = true |
||
) |
Open libraries listed in the 'libsEntry' entry in the dictionary.
Definition at line 577 of file dlLibraryTable.C.
References dict, keyType::LITERAL, dlLibraryTable::open(), and dictionary::readIfPresent().
bool open | ( | const dictionary & | dict, |
const word & | libsEntry | ||
) |
Open libraries listed in the 'libsEntry' entry in the dictionary.
Verbose = true
Definition at line 593 of file dlLibraryTable.C.
References dict, and dlLibraryTable::open().
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 29 of file dlLibraryTableTemplates.C.
References Foam::ensightOutput::debug, dict, Foam::endl(), Foam::nl, and WarningInFunction.
|
inlinenoexcept |
Return info proxy, used to print library table information to a stream.
Definition at line 412 of file dlLibraryTable.H.
|
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 dlLibraryTable::push_back().
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 dlLibraryTable::push_back().
|
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::~dlLibraryTable().