Commit a1db98fa authored by mattijs's avatar mattijs
Browse files

dependency checking

parent ea736dd8
......@@ -55,7 +55,8 @@ Foam::objectRegistry::objectRegistry
HashTable<regIOobject*>(nIoObjects),
time_(t),
parent_(t),
dbDir_(name())
dbDir_(name()),
event_(1)
{}
......@@ -69,7 +70,8 @@ Foam::objectRegistry::objectRegistry
HashTable<regIOobject*>(nIoObjects),
time_(io.time()),
parent_(io.db()),
dbDir_(parent_.dbDir()/local()/name())
dbDir_(parent_.dbDir()/local()/name()),
event_(1)
{
writeOpt() = IOobject::AUTO_WRITE;
}
......@@ -135,6 +137,42 @@ const Foam::objectRegistry& Foam::objectRegistry::subRegistry
}
Foam::label Foam::objectRegistry::getEvent() const
{
label curEvent = event_++;
if (event_ == labelMax)
{
WarningIn("objectRegistry::getEvent() const")
<< "Event counter has overflowed. Resetting counter on all"
<< " dependent objects." << endl
<< "This might cause extra evaluations." << endl;
// Reset event counter
curEvent = 1;
event_ = 2;
for (const_iterator iter = begin(); iter != end(); ++iter)
{
const regIOobject& io = *iter();
if (objectRegistry::debug)
{
Pout<< "objectRegistry::getEvent() : "
<< "resetting count on " << iter.key() << endl;
}
if (io.eventNo() != 0)
{
const_cast<regIOobject&>(io).eventNo() = curEvent;
}
}
}
return curEvent;
}
bool Foam::objectRegistry::checkIn(regIOobject& io) const
{
if (objectRegistry::debug)
......
......@@ -64,6 +64,9 @@ class objectRegistry
//- Local directory path of this objectRegistry relative to time
fileName dbDir_;
//- Current event
mutable label event_;
// Private Member Functions
......@@ -151,6 +154,9 @@ public:
template<class Type>
const Type& lookupObject(const word& name) const;
//- Return new event number.
label getEvent() const;
// Edit
......
......@@ -50,6 +50,7 @@ Foam::regIOobject::regIOobject(const IOobject& io)
registered_(false),
ownedByRegistry_(false),
lastModified_(0),
eventNo_(db().getEvent()),
isPtr_(NULL)
{
// Register with objectRegistry if requested
......@@ -67,6 +68,7 @@ Foam::regIOobject::regIOobject(const regIOobject& rio)
registered_(false),
ownedByRegistry_(false),
lastModified_(rio.lastModified_),
eventNo_(db().getEvent()),
isPtr_(NULL)
{
// Do not register copy with objectRegistry
......@@ -81,6 +83,7 @@ Foam::regIOobject::regIOobject(const regIOobject& rio, bool registerCopy)
registered_(false),
ownedByRegistry_(false),
lastModified_(rio.lastModified_),
eventNo_(db().getEvent()),
isPtr_(NULL)
{
if (registerCopy && rio.registered_)
......@@ -158,6 +161,91 @@ void Foam::regIOobject::checkOut()
}
bool Foam::regIOobject::uptodate(const word& a) const
{
if (db().lookupObject<regIOobject>(a).eventNo() >= eventNo_)
{
return false;
}
else
{
return true;
}
}
bool Foam::regIOobject::uptodate(const word& a, const word& b) const
{
if
(
db().lookupObject<regIOobject>(a).eventNo() >= eventNo_
|| db().lookupObject<regIOobject>(b).eventNo() >= eventNo_
)
{
return false;
}
else
{
return true;
}
}
bool Foam::regIOobject::uptodate
(
const word& a,
const word& b,
const word& c
) const
{
if
(
db().lookupObject<regIOobject>(a).eventNo() >= eventNo_
|| db().lookupObject<regIOobject>(b).eventNo() >= eventNo_
|| db().lookupObject<regIOobject>(c).eventNo() >= eventNo_
)
{
return false;
}
else
{
return true;
}
}
bool Foam::regIOobject::uptodate
(
const word& a,
const word& b,
const word& c,
const word& d
) const
{
if
(
db().lookupObject<regIOobject>(a).eventNo() >= eventNo_
|| db().lookupObject<regIOobject>(b).eventNo() >= eventNo_
|| db().lookupObject<regIOobject>(c).eventNo() >= eventNo_
|| db().lookupObject<regIOobject>(d).eventNo() >= eventNo_
)
{
return false;
}
else
{
return true;
}
}
//- Flag me as uptodate
void Foam::regIOobject::setUptodate()
{
eventNo_ = db().getEvent();
}
// Rename object and re-register with objectRegistry under new name
void Foam::regIOobject::rename(const word& newName)
{
......
......@@ -45,6 +45,7 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
......@@ -70,6 +71,9 @@ private:
//- Time of last modification
mutable time_t lastModified_;
//- eventNo of last update
label eventNo_;
//- Istream for reading
Istream* isPtr_;
......@@ -141,6 +145,24 @@ public:
inline void release();
// Dependency checking
//- Event number at last update.
inline label eventNo() const;
//- Event number at last update.
inline label& eventNo();
//- Am I uptodate with respect to other regIOobjects
bool uptodate(const word&) const;
bool uptodate(const word&, const word&) const;
bool uptodate(const word&, const word&, const word&) const;
bool uptodate(const word&, const word&, const word&, const word&)
const;
//- Flag me as uptodate
void setUptodate();
// Edit
//- Rename
......
......@@ -80,4 +80,15 @@ void Foam::regIOobject::release()
}
Foam::label Foam::regIOobject::eventNo() const
{
return eventNo_;
}
Foam::label& Foam::regIOobject::eventNo()
{
return eventNo_;
}
// ************************************************************************* //
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment