ENH: dlLibraryTable: moved library handles to objects
This commit is contained in:
parent
804b801458
commit
a791316896
@ -257,7 +257,7 @@ Foam::Time::Time
|
|||||||
graphFormat_("raw"),
|
graphFormat_("raw"),
|
||||||
runTimeModifiable_(true),
|
runTimeModifiable_(true),
|
||||||
|
|
||||||
readLibs_(controlDict_, "libs"),
|
libs_(controlDict_, "libs"),
|
||||||
functionObjects_(*this)
|
functionObjects_(*this)
|
||||||
{
|
{
|
||||||
// Explicitly set read flags on objectRegistry so anything constructed
|
// Explicitly set read flags on objectRegistry so anything constructed
|
||||||
@ -343,7 +343,7 @@ Foam::Time::Time
|
|||||||
graphFormat_("raw"),
|
graphFormat_("raw"),
|
||||||
runTimeModifiable_(true),
|
runTimeModifiable_(true),
|
||||||
|
|
||||||
readLibs_(controlDict_, "libs"),
|
libs_(controlDict_, "libs"),
|
||||||
functionObjects_(*this)
|
functionObjects_(*this)
|
||||||
{
|
{
|
||||||
// Explicitly set read flags on objectRegistry so anything constructed
|
// Explicitly set read flags on objectRegistry so anything constructed
|
||||||
@ -430,7 +430,7 @@ Foam::Time::Time
|
|||||||
graphFormat_("raw"),
|
graphFormat_("raw"),
|
||||||
runTimeModifiable_(true),
|
runTimeModifiable_(true),
|
||||||
|
|
||||||
readLibs_(controlDict_, "libs"),
|
libs_(controlDict_, "libs"),
|
||||||
functionObjects_(*this)
|
functionObjects_(*this)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -166,8 +166,8 @@ private:
|
|||||||
//- Is runtime modification of dictionaries allowed?
|
//- Is runtime modification of dictionaries allowed?
|
||||||
Switch runTimeModifiable_;
|
Switch runTimeModifiable_;
|
||||||
|
|
||||||
//- Instantiate a dummy class to cause the reading of dynamic libraries
|
//- Any loaded dynamic libraries
|
||||||
dlLibraryTable::readDlLibrary readLibs_;
|
dlLibraryTable libs_;
|
||||||
|
|
||||||
//- Function objects executed at start and on ++, +=
|
//- Function objects executed at start and on ++, +=
|
||||||
mutable functionObjectList functionObjects_;
|
mutable functionObjectList functionObjects_;
|
||||||
@ -375,6 +375,12 @@ public:
|
|||||||
return functionObjects_;
|
return functionObjects_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- External access to the loaded libraries
|
||||||
|
dlLibraryTable& libs()
|
||||||
|
{
|
||||||
|
return libs_;
|
||||||
|
}
|
||||||
|
|
||||||
//- Return true if time currently being sub-cycled, otherwise false
|
//- Return true if time currently being sub-cycled, otherwise false
|
||||||
bool subCycling() const
|
bool subCycling() const
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,7 @@ License
|
|||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "PstreamReduceOps.H"
|
#include "PstreamReduceOps.H"
|
||||||
|
|
||||||
|
#include "long.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -61,6 +62,36 @@ const Foam::word Foam::functionEntries::codeStream::codeTemplateC
|
|||||||
= "codeStreamTemplate.C";
|
= "codeStreamTemplate.C";
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::dictionary& Foam::functionEntries::codeStream::topDict
|
||||||
|
(
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const dictionary& p = dict.parent();
|
||||||
|
|
||||||
|
if (&p != &dict && !p.name().empty())
|
||||||
|
{
|
||||||
|
return topDict(p);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::dlLibraryTable& Foam::functionEntries::codeStream::libs
|
||||||
|
(
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const IOdictionary& d = static_cast<const IOdictionary&>(topDict(dict));
|
||||||
|
return const_cast<Time&>(d.time()).libs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::functionEntries::codeStream::execute
|
bool Foam::functionEntries::codeStream::execute
|
||||||
@ -99,8 +130,15 @@ bool Foam::functionEntries::codeStream::execute
|
|||||||
const fileName libPath = dynCode.libPath();
|
const fileName libPath = dynCode.libPath();
|
||||||
|
|
||||||
// see if library is loaded
|
// see if library is loaded
|
||||||
void* lib = dlLibraryTable::findLibrary(libPath);
|
void* lib = NULL;
|
||||||
|
if
|
||||||
|
(
|
||||||
|
isA<IOdictionary>(topDict(parentDict))
|
||||||
|
&& parentDict.dictName() != Time::controlDictName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
lib = libs(parentDict).findLibrary(libPath);
|
||||||
|
}
|
||||||
|
|
||||||
if (!lib)
|
if (!lib)
|
||||||
{
|
{
|
||||||
@ -110,9 +148,27 @@ bool Foam::functionEntries::codeStream::execute
|
|||||||
|
|
||||||
// nothing loaded
|
// nothing loaded
|
||||||
// avoid compilation if possible by loading an existing library
|
// avoid compilation if possible by loading an existing library
|
||||||
if (!lib && dlLibraryTable::open(libPath, false))
|
if (!lib)
|
||||||
{
|
{
|
||||||
lib = dlLibraryTable::findLibrary(libPath);
|
if
|
||||||
|
(
|
||||||
|
isA<IOdictionary>(topDict(parentDict))
|
||||||
|
&& parentDict.dictName() != Time::controlDictName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Uncached opening of libPath
|
||||||
|
lib = dlOpen(libPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -167,7 +223,16 @@ bool Foam::functionEntries::codeStream::execute
|
|||||||
// all processes must wait for compile to finish
|
// all processes must wait for compile to finish
|
||||||
reduce(create, orOp<bool>());
|
reduce(create, orOp<bool>());
|
||||||
|
|
||||||
if (!dlLibraryTable::open(libPath, false))
|
if
|
||||||
|
(
|
||||||
|
isA<IOdictionary>(topDict(parentDict))
|
||||||
|
&& parentDict.dictName() != Time::controlDictName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Cached access to dl libs. Guarantees clean up upon destruction
|
||||||
|
// of Time.
|
||||||
|
dlLibraryTable& dlLibs = libs(parentDict);
|
||||||
|
if (!dlLibs.open(libPath, false))
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
@ -179,7 +244,13 @@ bool Foam::functionEntries::codeStream::execute
|
|||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
lib = dlLibraryTable::findLibrary(libPath);
|
lib = dlLibs.findLibrary(libPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Uncached opening of libPath
|
||||||
|
lib = dlOpen(libPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,6 +98,8 @@ SourceFiles
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
class dlLibraryTable;
|
||||||
|
|
||||||
namespace functionEntries
|
namespace functionEntries
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -113,9 +115,14 @@ class codeStream
|
|||||||
//- Interpreter function type
|
//- Interpreter function type
|
||||||
typedef void (*streamingFunctionType)(Ostream&, const dictionary&);
|
typedef void (*streamingFunctionType)(Ostream&, const dictionary&);
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Helper function: parent (of parent etc.) of dictionary up to the top
|
||||||
|
static const dictionary& topDict(const dictionary&);
|
||||||
|
|
||||||
|
//- Helper function: access to dlLibraryTable of Time
|
||||||
|
static dlLibraryTable& libs(const dictionary& dict);
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
codeStream(const codeStream&);
|
codeStream(const codeStream&);
|
||||||
|
|
||||||
|
@ -26,11 +26,6 @@ License
|
|||||||
#include "dlLibraryTable.H"
|
#include "dlLibraryTable.H"
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::dlLibraryTable Foam::dlLibraryTable::loadedLibraries;
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::dlLibraryTable::dlLibraryTable()
|
Foam::dlLibraryTable::dlLibraryTable()
|
||||||
@ -39,11 +34,13 @@ Foam::dlLibraryTable::dlLibraryTable()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::dlLibraryTable::readDlLibrary::readDlLibrary
|
Foam::dlLibraryTable::dlLibraryTable
|
||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
const word& libsEntry
|
const word& libsEntry
|
||||||
)
|
)
|
||||||
|
:
|
||||||
|
HashTable<fileName, void*, Hash<void*> >()
|
||||||
{
|
{
|
||||||
open(dict, libsEntry);
|
open(dict, libsEntry);
|
||||||
}
|
}
|
||||||
@ -91,14 +88,7 @@ bool Foam::dlLibraryTable::open
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (loadedLibraries.insert(functionLibPtr, functionLibName))
|
return insert(functionLibPtr, functionLibName);
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -117,7 +107,7 @@ bool Foam::dlLibraryTable::close
|
|||||||
void* libPtr = findLibrary(functionLibName);
|
void* libPtr = findLibrary(functionLibName);
|
||||||
if (libPtr)
|
if (libPtr)
|
||||||
{
|
{
|
||||||
loadedLibraries.erase(libPtr);
|
erase(libPtr);
|
||||||
|
|
||||||
if (!dlClose(libPtr))
|
if (!dlClose(libPtr))
|
||||||
{
|
{
|
||||||
@ -141,7 +131,7 @@ bool Foam::dlLibraryTable::close
|
|||||||
|
|
||||||
void* Foam::dlLibraryTable::findLibrary(const fileName& functionLibName)
|
void* Foam::dlLibraryTable::findLibrary(const fileName& functionLibName)
|
||||||
{
|
{
|
||||||
forAllConstIter(dlLibraryTable, loadedLibraries, iter)
|
forAllConstIter(dlLibraryTable, *this, iter)
|
||||||
{
|
{
|
||||||
if (iter() == functionLibName)
|
if (iter() == functionLibName)
|
||||||
{
|
{
|
||||||
|
@ -63,30 +63,15 @@ class dlLibraryTable
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static data members
|
|
||||||
|
|
||||||
//- Static data someStaticData
|
|
||||||
static dlLibraryTable loadedLibraries;
|
|
||||||
|
|
||||||
|
|
||||||
// Public classes
|
|
||||||
|
|
||||||
//- Class whose construction causes the reading of dynamic libraries
|
|
||||||
class readDlLibrary
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
//- Read all the libraries listed in the 'libsEntry' entry in the
|
|
||||||
// given dictionary if present
|
|
||||||
readDlLibrary(const dictionary&, const word& libsEntry);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
dlLibraryTable();
|
dlLibraryTable();
|
||||||
|
|
||||||
|
//- Construct from dictionary and name of 'libs' entry giving
|
||||||
|
// the libraries to load
|
||||||
|
dlLibraryTable(const dictionary&, const word&);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
~dlLibraryTable();
|
~dlLibraryTable();
|
||||||
@ -95,23 +80,23 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Open the named library, optionally with warnings if problems occur
|
//- Open the named library, optionally with warnings if problems occur
|
||||||
static bool open(const fileName& name, const bool verbose = true);
|
bool open(const fileName& name, const bool verbose = true);
|
||||||
|
|
||||||
//- Close the named library, optionally with warnings if problems occur
|
//- Close the named library, optionally with warnings if problems occur
|
||||||
static bool close(const fileName& name, const bool verbose = true);
|
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);
|
void* findLibrary(const fileName& name);
|
||||||
|
|
||||||
//- 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
|
// given dictionary if present
|
||||||
static bool open(const dictionary&, const word& libsEntry);
|
bool open(const dictionary&, const word& libsEntry);
|
||||||
|
|
||||||
//- 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 given constructor table
|
// to the given constructor table
|
||||||
template<class TablePtr>
|
template<class TablePtr>
|
||||||
static bool open
|
bool open
|
||||||
(
|
(
|
||||||
const dictionary&,
|
const dictionary&,
|
||||||
const word& libsEntry,
|
const word& libsEntry,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -26,6 +26,7 @@ License
|
|||||||
#include "functionObject.H"
|
#include "functionObject.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "dlLibraryTable.H"
|
#include "dlLibraryTable.H"
|
||||||
|
#include "Time.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
|
|||||||
Info<< "Selecting function " << functionType << endl;
|
Info<< "Selecting function " << functionType << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
dlLibraryTable::open
|
const_cast<Time&>(t).libs().open
|
||||||
(
|
(
|
||||||
functionDict,
|
functionDict,
|
||||||
"functionObjectLibs",
|
"functionObjectLibs",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -104,7 +104,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
|
|||||||
{
|
{
|
||||||
const word agglomeratorType(controlDict.lookup("agglomerator"));
|
const word agglomeratorType(controlDict.lookup("agglomerator"));
|
||||||
|
|
||||||
dlLibraryTable::open
|
const_cast<Time&>(mesh.thisDb().time()).libs().open
|
||||||
(
|
(
|
||||||
controlDict,
|
controlDict,
|
||||||
"geometricGAMGAgglomerationLibs",
|
"geometricGAMGAgglomerationLibs",
|
||||||
@ -159,7 +159,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
|
|||||||
{
|
{
|
||||||
const word agglomeratorType(controlDict.lookup("agglomerator"));
|
const word agglomeratorType(controlDict.lookup("agglomerator"));
|
||||||
|
|
||||||
dlLibraryTable::open
|
const_cast<Time&>(mesh.thisDb().time()).libs().open
|
||||||
(
|
(
|
||||||
controlDict,
|
controlDict,
|
||||||
"algebraicGAMGAgglomerationLibs",
|
"algebraicGAMGAgglomerationLibs",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -49,7 +49,7 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
|
|||||||
|
|
||||||
Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;
|
Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;
|
||||||
|
|
||||||
dlLibraryTable::open
|
const_cast<Time&>(io.time()).libs().open
|
||||||
(
|
(
|
||||||
dict,
|
dict,
|
||||||
"dynamicFvMeshLibs",
|
"dynamicFvMeshLibs",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -79,7 +79,7 @@ Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::New(const polyMesh& mesh)
|
|||||||
|
|
||||||
Info<< "Selecting motion solver: " << solverTypeName << endl;
|
Info<< "Selecting motion solver: " << solverTypeName << endl;
|
||||||
|
|
||||||
dlLibraryTable::open
|
const_cast<Time&>(mesh.time()).libs().open
|
||||||
(
|
(
|
||||||
solverDict,
|
solverDict,
|
||||||
"motionSolverLibs",
|
"motionSolverLibs",
|
||||||
|
@ -59,14 +59,18 @@ void* Foam::codedFixedValueFvPatchField<Type>::loadLibrary
|
|||||||
const fileName& libPath,
|
const fileName& libPath,
|
||||||
const string& globalFuncName,
|
const string& globalFuncName,
|
||||||
const dictionary& contextDict
|
const dictionary& contextDict
|
||||||
)
|
) const
|
||||||
{
|
{
|
||||||
void* lib = 0;
|
void* lib = 0;
|
||||||
|
|
||||||
// avoid compilation by loading an existing library
|
// avoid compilation by loading an existing library
|
||||||
if (!libPath.empty() && dlLibraryTable::open(libPath, false))
|
if (!libPath.empty())
|
||||||
{
|
{
|
||||||
lib = dlLibraryTable::findLibrary(libPath);
|
dlLibraryTable& libs = const_cast<Time&>(this->db().time()).libs();
|
||||||
|
|
||||||
|
if (libs.open(libPath, false))
|
||||||
|
{
|
||||||
|
lib = libs.findLibrary(libPath);
|
||||||
|
|
||||||
// verify the loaded version and unload if needed
|
// verify the loaded version and unload if needed
|
||||||
if (lib)
|
if (lib)
|
||||||
@ -88,10 +92,11 @@ void* Foam::codedFixedValueFvPatchField<Type>::loadLibrary
|
|||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"codedFixedValueFvPatchField<Type>::updateLibrary()",
|
"codedFixedValueFvPatchField<Type>::"
|
||||||
|
"updateLibrary()",
|
||||||
contextDict
|
contextDict
|
||||||
) << "Failed looking up symbol " << globalFuncName << nl
|
) << "Failed looking up symbol " << globalFuncName
|
||||||
<< "from " << libPath << exit(FatalIOError);
|
<< nl << "from " << libPath << exit(FatalIOError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -104,7 +109,7 @@ void* Foam::codedFixedValueFvPatchField<Type>::loadLibrary
|
|||||||
<< "from " << libPath << exit(FatalIOError);
|
<< "from " << libPath << exit(FatalIOError);
|
||||||
|
|
||||||
lib = 0;
|
lib = 0;
|
||||||
if (!dlLibraryTable::close(libPath, false))
|
if (!libs.close(libPath, false))
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
@ -117,6 +122,7 @@ void* Foam::codedFixedValueFvPatchField<Type>::loadLibrary
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
@ -128,15 +134,19 @@ void Foam::codedFixedValueFvPatchField<Type>::unloadLibrary
|
|||||||
const fileName& libPath,
|
const fileName& libPath,
|
||||||
const string& globalFuncName,
|
const string& globalFuncName,
|
||||||
const dictionary& contextDict
|
const dictionary& contextDict
|
||||||
)
|
) const
|
||||||
{
|
{
|
||||||
void* lib = 0;
|
void* lib = 0;
|
||||||
|
|
||||||
if (!libPath.empty())
|
if (libPath.empty())
|
||||||
{
|
{
|
||||||
lib = dlLibraryTable::findLibrary(libPath);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dlLibraryTable& libs = const_cast<Time&>(this->db().time()).libs();
|
||||||
|
|
||||||
|
lib = libs.findLibrary(libPath);
|
||||||
|
|
||||||
if (!lib)
|
if (!lib)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -166,7 +176,7 @@ void Foam::codedFixedValueFvPatchField<Type>::unloadLibrary
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dlLibraryTable::close(libPath, false))
|
if (!libs.close(libPath, false))
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
@ -334,7 +344,7 @@ void Foam::codedFixedValueFvPatchField<Type>::updateLibrary() const
|
|||||||
|
|
||||||
|
|
||||||
// the correct library was already loaded => we are done
|
// the correct library was already loaded => we are done
|
||||||
if (dlLibraryTable::findLibrary(libPath))
|
if (const_cast<Time&>(this->db().time()).libs().findLibrary(libPath))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -130,20 +130,20 @@ class codedFixedValueFvPatchField
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Load specified library and execute globalFuncName(true)
|
//- Load specified library and execute globalFuncName(true)
|
||||||
static void* loadLibrary
|
void* loadLibrary
|
||||||
(
|
(
|
||||||
const fileName& libPath,
|
const fileName& libPath,
|
||||||
const string& globalFuncName,
|
const string& globalFuncName,
|
||||||
const dictionary& contextDict
|
const dictionary& contextDict
|
||||||
);
|
) const;
|
||||||
|
|
||||||
//- Execute globalFuncName(false) and unload specified library
|
//- Execute globalFuncName(false) and unload specified library
|
||||||
static void unloadLibrary
|
void unloadLibrary
|
||||||
(
|
(
|
||||||
const fileName& libPath,
|
const fileName& libPath,
|
||||||
const string& globalFuncName,
|
const string& globalFuncName,
|
||||||
const dictionary& contextDict
|
const dictionary& contextDict
|
||||||
);
|
) const;
|
||||||
|
|
||||||
//- Set the rewrite vars controlling the Type
|
//- Set the rewrite vars controlling the Type
|
||||||
static void setFieldTemplates(dynamicCode& dynCode);
|
static void setFieldTemplates(dynamicCode& dynCode);
|
||||||
|
@ -54,14 +54,18 @@ void* Foam::codedFunctionObject::loadLibrary
|
|||||||
const fileName& libPath,
|
const fileName& libPath,
|
||||||
const string& globalFuncName,
|
const string& globalFuncName,
|
||||||
const dictionary& contextDict
|
const dictionary& contextDict
|
||||||
)
|
) const
|
||||||
{
|
{
|
||||||
void* lib = 0;
|
void* lib = 0;
|
||||||
|
|
||||||
// avoid compilation by loading an existing library
|
// avoid compilation by loading an existing library
|
||||||
if (!libPath.empty() && dlLibraryTable::open(libPath, false))
|
if (!libPath.empty())
|
||||||
{
|
{
|
||||||
lib = dlLibraryTable::findLibrary(libPath);
|
dlLibraryTable& libs = const_cast<Time&>(time_).libs();
|
||||||
|
|
||||||
|
if (libs.open(libPath, false))
|
||||||
|
{
|
||||||
|
lib = libs.findLibrary(libPath);
|
||||||
|
|
||||||
// verify the loaded version and unload if needed
|
// verify the loaded version and unload if needed
|
||||||
if (lib)
|
if (lib)
|
||||||
@ -85,8 +89,8 @@ void* Foam::codedFunctionObject::loadLibrary
|
|||||||
(
|
(
|
||||||
"codedFunctionObject::updateLibrary()",
|
"codedFunctionObject::updateLibrary()",
|
||||||
contextDict
|
contextDict
|
||||||
) << "Failed looking up symbol " << globalFuncName << nl
|
) << "Failed looking up symbol " << globalFuncName
|
||||||
<< "from " << libPath << exit(FatalIOError);
|
<< nl << "from " << libPath << exit(FatalIOError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -99,7 +103,7 @@ void* Foam::codedFunctionObject::loadLibrary
|
|||||||
<< "from " << libPath << exit(FatalIOError);
|
<< "from " << libPath << exit(FatalIOError);
|
||||||
|
|
||||||
lib = 0;
|
lib = 0;
|
||||||
if (!dlLibraryTable::close(libPath, false))
|
if (!libs.close(libPath, false))
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
@ -112,6 +116,7 @@ void* Foam::codedFunctionObject::loadLibrary
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
@ -122,15 +127,19 @@ void Foam::codedFunctionObject::unloadLibrary
|
|||||||
const fileName& libPath,
|
const fileName& libPath,
|
||||||
const string& globalFuncName,
|
const string& globalFuncName,
|
||||||
const dictionary& contextDict
|
const dictionary& contextDict
|
||||||
)
|
) const
|
||||||
{
|
{
|
||||||
void* lib = 0;
|
void* lib = 0;
|
||||||
|
|
||||||
if (!libPath.empty())
|
if (libPath.empty())
|
||||||
{
|
{
|
||||||
lib = dlLibraryTable::findLibrary(libPath);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dlLibraryTable& libs = const_cast<Time&>(time_).libs();
|
||||||
|
|
||||||
|
lib = libs.findLibrary(libPath);
|
||||||
|
|
||||||
if (!lib)
|
if (!lib)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -160,7 +169,7 @@ void Foam::codedFunctionObject::unloadLibrary
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dlLibraryTable::close(libPath, false))
|
if (!libs.close(libPath, false))
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
@ -274,7 +283,7 @@ void Foam::codedFunctionObject::updateLibrary() const
|
|||||||
|
|
||||||
|
|
||||||
// the correct library was already loaded => we are done
|
// the correct library was already loaded => we are done
|
||||||
if (dlLibraryTable::findLibrary(libPath))
|
if (const_cast<Time&>(time_).libs().findLibrary(libPath))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -88,20 +88,20 @@ protected:
|
|||||||
typedef void (*loaderFunctionType)(bool);
|
typedef void (*loaderFunctionType)(bool);
|
||||||
|
|
||||||
//- Load specified library and execute globalFuncName(true)
|
//- Load specified library and execute globalFuncName(true)
|
||||||
static void* loadLibrary
|
void* loadLibrary
|
||||||
(
|
(
|
||||||
const fileName& libPath,
|
const fileName& libPath,
|
||||||
const string& globalFuncName,
|
const string& globalFuncName,
|
||||||
const dictionary& contextDict
|
const dictionary& contextDict
|
||||||
);
|
) const;
|
||||||
|
|
||||||
//- Execute globalFuncName(false) and unload specified library
|
//- Execute globalFuncName(false) and unload specified library
|
||||||
static void unloadLibrary
|
void unloadLibrary
|
||||||
(
|
(
|
||||||
const fileName& libPath,
|
const fileName& libPath,
|
||||||
const string& globalFuncName,
|
const string& globalFuncName,
|
||||||
const dictionary& contextDict
|
const dictionary& contextDict
|
||||||
);
|
) const;
|
||||||
|
|
||||||
|
|
||||||
//- Create library based on the dynamicCodeContext
|
//- Create library based on the dynamicCodeContext
|
||||||
|
Loading…
Reference in New Issue
Block a user