mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add verbose option for dlLibraryTable::open/close
- allows silent operation when we know what we are doing.
This commit is contained in:
@ -62,19 +62,26 @@ Foam::dlLibraryTable::~dlLibraryTable()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::dlLibraryTable::open(const fileName& functionLibName)
|
bool Foam::dlLibraryTable::open
|
||||||
|
(
|
||||||
|
const fileName& functionLibName,
|
||||||
|
const bool verbose
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (functionLibName.size())
|
if (functionLibName.size())
|
||||||
{
|
{
|
||||||
void* functionLibPtr = dlOpen(functionLibName);
|
void* functionLibPtr = dlOpen(functionLibName);
|
||||||
|
|
||||||
if (!functionLibPtr)
|
if (!functionLibPtr)
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"dlLibraryTable::open(const fileName& functionLibName)"
|
"dlLibraryTable::open(const fileName&)"
|
||||||
) << "could not load " << functionLibName
|
) << "could not load " << functionLibName
|
||||||
<< endl;
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -97,7 +104,11 @@ bool Foam::dlLibraryTable::open(const fileName& functionLibName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::dlLibraryTable::close(const fileName& functionLibName)
|
bool Foam::dlLibraryTable::close
|
||||||
|
(
|
||||||
|
const fileName& functionLibName,
|
||||||
|
const bool verbose
|
||||||
|
)
|
||||||
{
|
{
|
||||||
void* libPtr = findLibrary(functionLibName);
|
void* libPtr = findLibrary(functionLibName);
|
||||||
if (libPtr)
|
if (libPtr)
|
||||||
@ -105,12 +116,15 @@ bool Foam::dlLibraryTable::close(const fileName& functionLibName)
|
|||||||
loadedLibraries.erase(libPtr);
|
loadedLibraries.erase(libPtr);
|
||||||
|
|
||||||
if (!dlClose(libPtr))
|
if (!dlClose(libPtr))
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"dlLibraryTable::close(const fileName& functionLibName)"
|
"dlLibraryTable::close(const fileName&)"
|
||||||
) << "could not close " << functionLibName
|
) << "could not close " << functionLibName
|
||||||
<< endl;
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -144,7 +158,7 @@ bool Foam::dlLibraryTable::open
|
|||||||
{
|
{
|
||||||
fileNameList libNames(dict.lookup(libsEntry));
|
fileNameList libNames(dict.lookup(libsEntry));
|
||||||
|
|
||||||
bool allOpened = (libNames.size() > 0);
|
bool allOpened = !libNames.empty();
|
||||||
|
|
||||||
forAll(libNames, i)
|
forAll(libNames, i)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -94,11 +94,11 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Open the named library
|
//- Open the named library, optionally with warnings if problems occur
|
||||||
static bool open(const fileName& name);
|
static bool open(const fileName& name, const bool verbose = true);
|
||||||
|
|
||||||
//- Close the named library
|
//- Close the named library, optionally with warnings if problems occur
|
||||||
static bool close(const fileName& name);
|
static bool close(const fileName& name, const bool verbose = true);
|
||||||
|
|
||||||
//- Find the handle of the named library
|
//- Find the handle of the named library
|
||||||
static void* findLibrary(const fileName& name);
|
static void* findLibrary(const fileName& name);
|
||||||
@ -109,7 +109,7 @@ public:
|
|||||||
|
|
||||||
//- Open all the libraries listed in the 'libsEntry' entry in the
|
//- Open all the libraries listed in the 'libsEntry' entry in the
|
||||||
// given dictionary if present and check the additions
|
// given dictionary if present and check the additions
|
||||||
// to the give constructor table
|
// to the given constructor table
|
||||||
template<class TablePtr>
|
template<class TablePtr>
|
||||||
static bool open
|
static bool open
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user