mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: various dlLibraryTable improvements/refinements (#1737)
- libs() singleton method for global library handling - explicit handling of empty filename for dlLibraryTable open/close. Largely worked before, but now be more explicit about its behaviour. - add (key, dict) constructor and open() methods. More similarity to dimensionedType, Enum etc, and there is no ambiguity with the templated open(). - construct or open from initializer_list of names - optional verbosity when opening with auxiliary table, avoid duplicate messages or spurious messages for these. - basename and fullname methods (migrated from dynamicCode). - centralise low-level load/unload hooks - adjust close to also dlclose() aliased library names.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -145,18 +145,13 @@ Foam::functionEntries::codeStream::getFunction
|
||||
|
||||
if (isA<baseIOdictionary>(topDict))
|
||||
{
|
||||
// Cached access to dl libs. Guarantees clean up upon destruction
|
||||
// of Time.
|
||||
dlLibraryTable& dlLibs = libs(parentDict);
|
||||
if (dlLibs.open(libPath, false))
|
||||
{
|
||||
lib = dlLibs.findLibrary(libPath);
|
||||
}
|
||||
// Cached access to libs, with cleanup upon termination
|
||||
lib = libs(parentDict).open(libPath, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Uncached opening of libPath. Do not complain if cannot be loaded
|
||||
lib = dlOpen(libPath, false);
|
||||
lib = Foam::dlOpen(libPath, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,14 +294,13 @@ Foam::functionEntries::codeStream::getFunction
|
||||
|
||||
if (isA<baseIOdictionary>(topDict))
|
||||
{
|
||||
// Cached access to dl libs. Guarantees clean up upon destruction
|
||||
// of Time.
|
||||
dlLibraryTable& dlLibs = libs(parentDict);
|
||||
|
||||
// Cached access to libs, with cleanup upon termination
|
||||
DebugPout
|
||||
<< "Opening cached dictionary:" << libPath << endl;
|
||||
|
||||
if (!dlLibs.open(libPath, false))
|
||||
lib = libs(parentDict).open(libPath, false);
|
||||
|
||||
if (!lib)
|
||||
{
|
||||
FatalIOErrorInFunction(parentDict)
|
||||
<< "Failed loading library " << libPath << nl
|
||||
@ -314,8 +308,6 @@ Foam::functionEntries::codeStream::getFunction
|
||||
<< " in system/controlDict?"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
lib = dlLibs.findLibrary(libPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -323,7 +315,7 @@ Foam::functionEntries::codeStream::getFunction
|
||||
DebugPout
|
||||
<< "Opening uncached dictionary:" << libPath << endl;
|
||||
|
||||
lib = dlOpen(libPath, true);
|
||||
lib = Foam::dlOpen(libPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,7 +338,7 @@ Foam::functionEntries::codeStream::getFunction
|
||||
streamingFunctionType function =
|
||||
reinterpret_cast<streamingFunctionType>
|
||||
(
|
||||
dlSym(lib, dynCode.codeName())
|
||||
Foam::dlSym(lib, dynCode.codeName())
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user