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);
316 <<
"Closing " << libName
317 <<
" with handle " <<
Foam::name(libPtrs_[index]) <<
nl;
321 libPtrs_[index] =
nullptr;
322 libNames_[index].clear();
327 <<
"Could not close " << libName <<
endl;
336 const label index = libNames_.rfind(libName);
343 return libPtrs_[index];
350 const word& libsEntry
358 for (
const fileName& libName : libNames)
366 return nOpen && nOpen == libNames.size();
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
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 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 no 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.
bool append(const fileName &libName)
Add to the list of names, but do not yet open.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
#define DebugInFunction
Report an information message using Foam::Info.
word name(const complex &c)
Return string representation of complex.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool open(bool verbose=true)
string expand(const std::string &str, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
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.
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
dlLibraryTable()=default
Construct null.
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.