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) | |
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< fileName > | loaded () 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< dlLibraryTable > | info () 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 dlLibraryTable & | libs () |
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... | |
A table of dynamically loaded libraries.
Definition at line 63 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 113 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 199 of file dlLibraryTable.C.
References dlLibraryTable::open().
|
explicit |
Open specified libraries, warn by default if problems occur.
Ignores duplicate names.
Definition at line 209 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 219 of file dlLibraryTable.C.
References dict, 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 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.
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 60 of file dlLibraryTable.C.
References fileName::nameLessExt(), and string::removeStart().
Referenced by codedBase::updateLibrary().
|
static |
Library fullname, prefix with 'lib', suffix with '.so'.
Definition at line 68 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 80 of file dlLibraryTable.C.
Referenced by CodedField< Type >::libs(), CodedFunction1< Type >::libs(), codedMixedFvPatchField< Type >::libs(), and CodedSource< Type >::libs().
|
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 142 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 154 of file dlLibraryTable.C.
bool empty | ( | ) | const |
True if there are no libraries loaded by the table.
Definition at line 256 of file dlLibraryTable.C.
Foam::label size | ( | ) | const |
The number of libraries loaded by the table.
Definition at line 270 of file dlLibraryTable.C.
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().
Names of the libraries in use, or requested.
Definition at line 228 of file dlLibraryTable.H.
Referenced by Foam::operator<<().
|
inline |
Pointers to the libraries in use. Access with caution.
Definition at line 234 of file dlLibraryTable.H.
Referenced by Foam::operator<<().
void clear | ( | ) |
Clears the table, without attempting to close the libraries.
Definition at line 286 of file dlLibraryTable.C.
Add to the list of names, but do not yet open.
Ignores duplicate names.
Definition at line 379 of file dlLibraryTable.C.
Add to the list of names, but do not yet open.
Ignores duplicate names.
Definition at line 393 of file dlLibraryTable.C.
References append().
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().
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 442 of file dlLibraryTable.C.
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().
Open the named libraries, warn by default if problems occur.
Ignores duplicate names.
Definition at line 488 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 317 of file dlLibraryTable.C.
References DebugInFunction, Foam::dlClose(), Foam::endl(), forAll, forAllReverse, Foam::name(), Foam::nl, and WarningInFunction.
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.
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.
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().
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().
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.
|
inline |
Return info proxy.
Used to print library table information to a stream
Definition at line 312 of file dlLibraryTable.H.
|
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().