Go to the documentation of this file.
44 void* Foam::dlLibraryTable::openLibrary
46 const fileName& libName,
59 <<
"Opened " << libName
66 os <<
"Could not load " << libName <<
nl << msg.c_str() <<
endl;
107 for (
const void* ptr : libPtrs_)
123 for (
const void* ptr : libPtrs_)
141 void* ptr = libPtrs_[i];
145 libNames_[i].clear();
152 <<
"Closed [" << i <<
"] " << libNames_[i]
155 libPtrs_[i] =
nullptr;
156 libNames_[i].clear();
165 <<
"Failed closing " << libNames_[i]
173 if (nLoaded && nLoaded != libPtrs_.size())
179 if (libPtrs_[i] !=
nullptr)
183 libPtrs_[nLoaded] = libPtrs_[i];
184 libNames_[nLoaded] = std::move(libNames_[i]);
192 libPtrs_.resize(nLoaded);
193 libNames_.resize(nLoaded);
199 if (libName.empty() || libNames_.found(libName))
204 libPtrs_.append(
nullptr);
205 libNames_.append(libName);
215 for (
const fileName& libName : libNames)
234 const fileName& libName = libNames_[i];
236 if (libPtrs_[i] ==
nullptr && !libName.empty())
239 void* ptr = openLibrary(libName, verbose);
248 libNames_[i].clear();
253 return nOpen && nOpen == nCand;
263 void* ptr = openLibrary(libName, verbose);
267 libPtrs_.append(ptr);
268 libNames_.append(libName);
283 for (
const fileName& libName : libNames)
285 const label index = libNames_.find(libName);
287 if (index >= 0 && libPtrs_[index] !=
nullptr)
298 return nOpen && nOpen == libNames.size();
308 const label index = libNames_.rfind(libName);
315 void* ptr = libPtrs_[index];
318 <<
"Closing " << libName
323 libPtrs_[index] =
nullptr;
324 libNames_[index].clear();
329 <<
"Could not close " << libName <<
endl;
338 const label index = libNames_.rfind(libName);
345 return libPtrs_[index];
352 const word& libsEntry
360 for (
const fileName& libName : libNames)
368 return nOpen && nOpen == libNames.size();
387 const void* ptr = tbl.
pointers()[i];
const UList< void * > & pointers() const
Pointers to the libraries in use. Access with caution.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A table of dynamically loaded libraries.
void * findLibrary(const fileName &libName)
Find the handle of the named library.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
A class for handling words, derived from Foam::string.
A helper class for outputting values to Ostream.
A class for handling file names.
bool close(const fileName &libName, bool verbose=true)
Close the named library, optionally warn if problems occur.
Ostream & endl(Ostream &os)
Add newline and flush stream.
OSstream Serr
An Ostream wrapper for std::cerr.
bool empty() const
True if there are no libraries loaded by the table.
#define forAll(list, i)
Loop across all elements in list.
void clear(bool verbose=true)
Clearing closes all libraries loaded by the table.
string expand(const std::string &s, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
bool append(const fileName &libName)
Add to the list of names, but do not yet open.
#define DebugInFunction
Report an information message using Foam::Info.
word name(const complex &c)
Return string representation of complex.
const UList< fileName > & names() const
Names of the libraries in use, or requested.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool open(bool verbose=true)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool dlClose(void *handle)
Close a dlopened library using handle. Return true if successful.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
label size() const
The number of libraries loaded by the table.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Begin list [isseparator].
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
dlLibraryTable()=default
Default construct.
void * dlOpen(const fileName &libName, const bool check=true)
Open a shared library and return handle to library.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
~dlLibraryTable()
Destructor. Closes all libraries loaded by the table.