added postFixedSubRegistry
This commit is contained in:
parent
1169678229
commit
9cf1ef5f18
10 changed files with 374 additions and 13 deletions
|
@ -629,6 +629,7 @@ DebugSwitches
|
|||
nutWallFunction 0;
|
||||
obj 0;
|
||||
objectRegistry 0;
|
||||
postfixedSubRegistry 0;
|
||||
octree 0;
|
||||
octreeDataEdges 0;
|
||||
octreeDataFace 0;
|
||||
|
|
|
@ -169,6 +169,7 @@ $(regIOobject)/regIOobjectWrite.C
|
|||
|
||||
db/IOobjectList/IOobjectList.C
|
||||
db/objectRegistry/objectRegistry.C
|
||||
db/postfixedSubRegistry/postfixedSubRegistry.C
|
||||
db/CallbackRegistry/CallbackRegistryName.C
|
||||
db/dlLibraryTable/dlLibraryTable.C
|
||||
|
||||
|
@ -176,7 +177,6 @@ db/functionObjects/functionObject/functionObject.C
|
|||
db/functionObjects/functionObjectList/functionObjectList.C
|
||||
db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C
|
||||
|
||||
|
||||
Time = db/Time
|
||||
$(Time)/TimePaths.C
|
||||
$(Time)/TimeState.C
|
||||
|
|
|
@ -113,6 +113,34 @@ bool Foam::IOobject::IOobject::fileNameComponents
|
|||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IOobject::IOobject
|
||||
(
|
||||
const word& name,
|
||||
const Time& time,
|
||||
readOption ro,
|
||||
writeOption wo
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
headerClassName_(typeName),
|
||||
note_(),
|
||||
instance_(""),
|
||||
local_(),
|
||||
db_(time),
|
||||
rOpt_(ro),
|
||||
wOpt_(wo),
|
||||
registerObject_(false),
|
||||
objState_(GOOD)
|
||||
{
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
Info<< "Constructing IOobject called " << name_
|
||||
<< " of type " << headerClassName_
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::IOobject::IOobject
|
||||
(
|
||||
const word& name,
|
||||
|
@ -123,7 +151,7 @@ Foam::IOobject::IOobject
|
|||
bool registerObject
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
name_(registry.mangleFileName(name)),
|
||||
headerClassName_(typeName),
|
||||
note_(),
|
||||
instance_(instance),
|
||||
|
@ -154,7 +182,7 @@ Foam::IOobject::IOobject
|
|||
bool registerObject
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
name_(registry.mangleFileName(name)),
|
||||
headerClassName_(typeName),
|
||||
note_(),
|
||||
instance_(instance),
|
||||
|
|
|
@ -179,6 +179,15 @@ public:
|
|||
|
||||
// Constructors
|
||||
|
||||
//- Construct from name, instance, registry, io options
|
||||
IOobject
|
||||
(
|
||||
const word& name,
|
||||
const Time& registry,
|
||||
readOption r = NO_READ,
|
||||
writeOption w = NO_WRITE
|
||||
);
|
||||
|
||||
//- Construct from name, instance, registry, io options
|
||||
IOobject
|
||||
(
|
||||
|
|
|
@ -45,11 +45,9 @@ Foam::objectRegistry::objectRegistry
|
|||
IOobject
|
||||
(
|
||||
string::validate<word>(t.caseName()),
|
||||
"",
|
||||
t,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE,
|
||||
false
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
true // to flag that this is the top-level regIOobject
|
||||
),
|
||||
|
@ -78,6 +76,24 @@ Foam::objectRegistry::objectRegistry
|
|||
}
|
||||
|
||||
|
||||
Foam::objectRegistry::objectRegistry
|
||||
(
|
||||
const IOobject& io,
|
||||
const fileName& dbDir,
|
||||
const label nIoObjects
|
||||
)
|
||||
:
|
||||
regIOobject(io),
|
||||
HashTable<regIOobject*>(nIoObjects),
|
||||
time_(io.time()),
|
||||
parent_(io.db()),
|
||||
dbDir_(dbDir),
|
||||
event_(1)
|
||||
{
|
||||
writeOpt() = IOobject::AUTO_WRITE;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::objectRegistry::~objectRegistry()
|
||||
|
@ -135,6 +151,12 @@ Foam::wordList Foam::objectRegistry::names(const word& ClassName) const
|
|||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::objectRegistry::mangleFileName(const fileName& fName) const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
|
||||
const Foam::objectRegistry& Foam::objectRegistry::subRegistry
|
||||
(
|
||||
const word& name
|
||||
|
|
|
@ -105,6 +105,14 @@ public:
|
|||
const label nIoObjects = 128
|
||||
);
|
||||
|
||||
//- Construct a sub-registry given an IObject to describe the registry
|
||||
// and an initial estimate for the number of entries
|
||||
explicit objectRegistry
|
||||
(
|
||||
const IOobject& io,
|
||||
const fileName& dbDir,
|
||||
const label nIoObjects = 128
|
||||
);
|
||||
|
||||
// Destructor
|
||||
|
||||
|
@ -133,6 +141,14 @@ public:
|
|||
return dbDir_;
|
||||
}
|
||||
|
||||
fileName& dbDir()
|
||||
{
|
||||
return dbDir_;
|
||||
}
|
||||
|
||||
//- Return mangled fileName
|
||||
virtual fileName mangleFileName (const fileName&) const;
|
||||
|
||||
//- Return the list of names of the IOobjects
|
||||
wordList names() const;
|
||||
|
||||
|
@ -168,10 +184,10 @@ public:
|
|||
virtual void rename(const word& newName);
|
||||
|
||||
//- Add an regIOobject to registry
|
||||
bool checkIn(regIOobject&) const;
|
||||
virtual bool checkIn(regIOobject&) const;
|
||||
|
||||
//- Remove an regIOobject from registry
|
||||
bool checkOut(regIOobject&) const;
|
||||
virtual bool checkOut(regIOobject&) const;
|
||||
|
||||
|
||||
// Reading
|
||||
|
|
144
src/OpenFOAM/db/postfixedSubRegistry/postfixedSubRegistry.C
Normal file
144
src/OpenFOAM/db/postfixedSubRegistry/postfixedSubRegistry.C
Normal file
|
@ -0,0 +1,144 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright held by original author
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "postfixedSubRegistry.H"
|
||||
#include "Pstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(postfixedSubRegistry, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::postfixedSubRegistry::postfixedSubRegistry
|
||||
(
|
||||
const IOobject& io,
|
||||
const label nIoObjects
|
||||
)
|
||||
:
|
||||
objectRegistry(io, io.db().dbDir(), nIoObjects)
|
||||
{
|
||||
writeOpt() = IOobject::NO_WRITE;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::postfixedSubRegistry::~postfixedSubRegistry()
|
||||
{
|
||||
objectRegistry::clear();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileName Foam::postfixedSubRegistry::mangleFileName(const fileName& fName) const
|
||||
{
|
||||
return fileName(fName+name());
|
||||
}
|
||||
|
||||
|
||||
bool Foam::postfixedSubRegistry::checkIn(regIOobject& io) const
|
||||
{
|
||||
if (postfixedSubRegistry::debug)
|
||||
{
|
||||
Pout<< "postfixedSubRegistry::checkIn(regIOobject&) : "
|
||||
<< name() << " : checking in " << io.name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
word demangledName = io.name();
|
||||
demangledName = demangledName(io.name().size() - name().size());
|
||||
|
||||
// Check into Mesh-Registry under full name
|
||||
const_cast<objectRegistry&>(parent()).insert(io.name(), &io);
|
||||
|
||||
// Check into Mesh-Registry under short name
|
||||
return const_cast<postfixedSubRegistry&>(*this).insert(demangledName, &io);;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::postfixedSubRegistry::checkOut(regIOobject& io) const
|
||||
{
|
||||
word demangledName = io.name();
|
||||
demangledName = demangledName(io.name().size() - name().size());
|
||||
iterator iter = const_cast<postfixedSubRegistry&>(*this).find(demangledName);
|
||||
iterator iterPar = const_cast<objectRegistry&>(parent()).find(io.name());
|
||||
|
||||
if (iter != end() && iterPar != end())
|
||||
{
|
||||
if (postfixedSubRegistry::debug)
|
||||
{
|
||||
Pout<< "postfixedSubRegistry::checkOut(regIOobject&) : "
|
||||
<< name() << " : checking out " << io.name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (iter() != &io || iterPar() != &io)
|
||||
{
|
||||
if (postfixedSubRegistry::debug)
|
||||
{
|
||||
WarningIn("postfixedSubRegistry::checkOut(regIOobject&)")
|
||||
<< name() << " : attempt to checkOut copy of " << io.name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool hasErased =
|
||||
const_cast<postfixedSubRegistry&>(*this).erase(iter)
|
||||
&& const_cast<objectRegistry&>(parent()).erase(iterPar);
|
||||
|
||||
if (io.ownedByRegistry())
|
||||
{
|
||||
delete iter();
|
||||
}
|
||||
|
||||
return hasErased;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (postfixedSubRegistry::debug)
|
||||
{
|
||||
Pout<< "postfixedSubRegistry::checkOut(regIOobject&) : "
|
||||
<< name() << " : could not find " << io.name()
|
||||
<< " in registry " << name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
136
src/OpenFOAM/db/postfixedSubRegistry/postfixedSubRegistry.H
Normal file
136
src/OpenFOAM/db/postfixedSubRegistry/postfixedSubRegistry.H
Normal file
|
@ -0,0 +1,136 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright held by original author
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::postfixedSubRegistry
|
||||
|
||||
Description
|
||||
Registry of regIOobjects
|
||||
|
||||
SourceFiles
|
||||
postfixedSubRegistry.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef postfixedSubRegistry_H
|
||||
#define postfixedSubRegistry_H
|
||||
|
||||
#include "objectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class postfixedSubRegistry Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class postfixedSubRegistry
|
||||
:
|
||||
public objectRegistry
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow Copy constructor
|
||||
postfixedSubRegistry(const postfixedSubRegistry&);
|
||||
|
||||
//- Disallow default bitwise copy construct and assignment
|
||||
void operator=(const postfixedSubRegistry&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Declare type name for this IOobject
|
||||
TypeName("postfixedSubRegistry");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct a sub-registry given an IObject to describe the registry
|
||||
// and an initial estimate for the number of entries
|
||||
explicit postfixedSubRegistry
|
||||
(
|
||||
const IOobject& io,
|
||||
const label nIoObjects = 128
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~postfixedSubRegistry();
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return mangled fileName
|
||||
virtual fileName mangleFileName (const fileName&) const;
|
||||
|
||||
// Edit
|
||||
|
||||
//- Add an regIOobject to registry
|
||||
virtual bool checkIn(regIOobject&) const;
|
||||
|
||||
//- Remove an regIOobject from registry
|
||||
virtual bool checkOut(regIOobject&) const;
|
||||
|
||||
// Reading
|
||||
|
||||
//- Return true if any of the object's files have been modified
|
||||
virtual bool modified() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Read object if modified
|
||||
virtual bool readIfModified()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Writing
|
||||
|
||||
virtual bool writeObject
|
||||
(
|
||||
IOstream::streamFormat fmt,
|
||||
IOstream::versionNumber ver,
|
||||
IOstream::compressionType cmp
|
||||
) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
|
@ -47,7 +47,7 @@ Foam::hCombustionThermo::hCombustionThermo(const fvMesh& mesh)
|
|||
(
|
||||
"h",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
obj,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
|
|
|
@ -75,21 +75,26 @@ public:
|
|||
autoPtr,
|
||||
hCombustionThermo,
|
||||
fvMesh,
|
||||
(const fvMesh& mesh),
|
||||
(mesh)
|
||||
(const fvMesh& mesh, const objectRegistry& obj),
|
||||
(mesh, obj)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary and mesh
|
||||
hCombustionThermo(const fvMesh&);
|
||||
hCombustionThermo(const fvMesh&, const objectRegistry&);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Standard selection based on fvMesh
|
||||
static autoPtr<hCombustionThermo> New(const fvMesh&);
|
||||
static autoPtr<hCombustionThermo> New(const fvMesh&, const objectRegistry&);
|
||||
|
||||
static autoPtr<hCombustionThermo> New(const fvMesh& mesh)
|
||||
{
|
||||
return New(mesh, mesh)
|
||||
}
|
||||
|
||||
//- Select and check that package contains 'thermoType'
|
||||
static autoPtr<hCombustionThermo> NewType
|
||||
|
|
Reference in a new issue