40 bool Foam::objectRegistry::parentNotTime()
const
46 void Foam::objectRegistry::readCacheTemporaryObjects()
const
50 cacheTemporaryObjectsState_ == 0
51 && time_.controlDict().found(
"cacheTemporaryObjects")
54 cacheTemporaryObjectsState_ = 1;
56 const dictionary&
controlDict = time_.controlDict();
65 >> cacheTemporaryObjects;
71 >> cacheTemporaryObjects;
74 forAll(cacheTemporaryObjects, i)
76 cacheTemporaryObjects_.insert
78 cacheTemporaryObjects[i],
86 void Foam::objectRegistry::deleteCachedObject(regIOobject& cachedOb)
const
90 cachedOb.rename(cachedOb.name() +
"Cached");
100 const label nIoObjects
121 cacheTemporaryObjectsState_(0)
129 const label nIoObjects
138 cacheTemporaryObjectsState_(0)
147 const label nIoObjects
158 cacheTemporaryObjects_.clear();
159 cacheTemporaryObjectsState_ = -1;
169 const word& instance,
174 return rootPath()/caseName()/instance/dbDir()/local;
183 for (const_iterator iter = cbegin(); iter != cend(); ++iter)
187 objectNames[
count++] = iter.key();
211 for (const_iterator iter = cbegin(); iter != cend(); ++iter)
214 objectNames[
count].second() = iter()->type();
225 const bool forceCreate
228 if (forceCreate && !foundObject<objectRegistry>(
name))
241 fieldsCachePtr->
store();
243 return lookupObject<objectRegistry>(
name);
249 uint64_t curEvent = event_++;
254 <<
"Event counter has overflowed!"
264 if (objectRegistry::debug)
266 Pout<<
"objectRegistry::checkIn(regIOobject&) : "
267 <<
name() <<
" : checking in " << io.
name()
268 <<
" of type " << io.type()
278 root.cacheTemporaryObjects_.find(io.
name())
280 if (cacheIter != root.cacheTemporaryObjects_.end())
284 if (iter != end() && iter() != &io && iter()->ownedByRegistry())
286 if (objectRegistry::debug)
288 Pout<<
"objectRegistry::checkIn(regIOobject&) : "
289 <<
name() <<
" : deleting cached object " << iter.key()
293 cacheIter().first() =
false;
294 deleteCachedObject(*iter());
308 if (objectRegistry::debug)
310 Pout<<
"objectRegistry::checkOut(regIOobject&) : "
311 <<
name() <<
" : checking out " << iter.key()
317 if (objectRegistry::debug)
320 <<
name() <<
" : attempt to checkOut copy of "
343 if (objectRegistry::debug)
345 Pout<<
"objectRegistry::checkOut(regIOobject&) : "
346 <<
name() <<
" : could not find " << io.
name()
347 <<
" in registry " <<
name()
359 label nMyObjects = 0;
361 for (iterator iter = begin(); iter != end(); ++iter)
363 if (iter()->ownedByRegistry())
365 myObjects[nMyObjects++] = iter();
369 for (
label i=0; i < nMyObjects; i++)
371 checkOut(*myObjects[i]);
380 root.cacheTemporaryObjects_.insert(
name, {
false,
false});
391 return root.cacheTemporaryObjects_.found(
name);
404 cacheTemporaryObjects_.find(ob.
name())
406 if (iter != cacheTemporaryObjects_.
end())
408 iter().first() =
false;
414 time_.resetCacheTemporaryObject(ob);
427 if (orPtr_ && orPtr_ !=
this)
435 if (root.cacheTemporaryObjects_.empty())
445 root.cacheTemporaryObjects_,
452 <<
"Could not find temporary object " << iter.key()
453 <<
" in registry " <<
name() <<
nl
454 <<
"Available temporary objects "
460 cacheTemporaryObjects_.clear();
467 root.cacheTemporaryObjects_,
471 iter().second() =
false;
475 temporaryObjects_.clear();
488 if (i == string::npos)
494 dbDir_.
replace(i+1, string::npos, newName);
503 if (iter()->modified())
515 dependents_.setSize(size());
520 if (iter()->dependenciesModified())
522 dependents_[
count++] = iter();
525 dependents_.setSize(
count);
533 bool modified =
false;
535 for (iterator iter = begin(); iter != end(); ++iter)
537 if (objectRegistry::debug)
539 Pout<<
"objectRegistry::readModifiedObjects() : "
540 <<
name() <<
" : Considering reading object "
541 << iter.key() <<
endl;
544 modified = modified || iter()->readIfModified();
557 dependents_[i]->read();
566 dependenciesModified();
568 const bool modified = readIfModified();
587 os <<
" " <<
setf(ios_base::left)
588 <<
setw(39) << sortedObjects[i].key()
589 <<
' ' << sortedObjects[i]()->
type()
607 if (objectRegistry::debug)
609 Pout<<
"objectRegistry::write() : "
610 <<
name() <<
" : Considering writing object "
612 <<
" of type " << iter()->type()
613 <<
" with writeOpt " << iter()->writeOpt()
614 <<
" to file " << iter()->objectPath()
618 if (iter()->writeOpt() != NO_WRITE)
620 ok = iter()->writeObject(fmt, ver, cmp,
write) && ok;
Istream and Ostream manipulators taking arguments.
graph_traits< Graph >::vertices_size_type size_type
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
An STL-conforming hash table.
List< word > sortedToc() const
Return the table of contents as a sorted list.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
writeOption & writeOpt() const
const word & name() const
Return name.
streamFormat
Enumeration for the format of data in the stream.
compressionType
Enumeration for the format of data in the stream.
void setSize(const label)
Reset size of List.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
T & first()
Return the first element of the list.
A class for handling file names.
Registry of regIOobjects.
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp, const bool write) const
Write the objects.
wordList toc() const
Return the list of names of the IOobjects of given type.
const objectRegistry & subRegistry(const word &name, const bool forceCreate=false) const
Lookup and return a const sub-objectRegistry. Optionally create.
void printToc(Ostream &os) const
Print the list of object names and their type.
bool temporaryObjectCached(const word &name) const
Return true if given name is in the cacheTemporaryObjects set.
virtual bool modified() const
Return true if any of the object's files have been modified.
objectRegistry(const Time &db, const label nIoObjects=128)
Construct the time objectRegistry given an initial estimate.
virtual bool dependenciesModified() const
Cache pointers to objects who's dependencies have been modified.
void cacheTemporary(const word &name) const
Add the given name to the cacheTemporaryObjects set.
virtual ~objectRegistry()
Destructor.
bool checkCacheTemporaryObjects() const
Check that all objects in the cacheTemporaryObjects set.
List< Pair< word > > tocTypes() const
Return the list of names and types of IOobjects.
uint64_t getEvent() const
Return new event number.
virtual bool readIfModified()
Read object if modified.
fileName path() const
Return complete path.
void clear()
Remove all regIOobject owned by the registry.
void resetCacheTemporaryObject(const regIOobject &ob) const
Reset the cache state of the given object.
void readModifiedObjects()
Read the objects that have been modified.
virtual void rename(const word &newName)
Rename.
virtual bool read()
Read dependent objects.
Traits class for primitives.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool ownedByRegistry() const
Is this object owned by the registry?
bool checkOut()
Remove object from registry.
virtual void rename(const word &newName)
Rename.
void store()
Transfer ownership of this object to its registry.
bool checkIn()
Add object to registry.
A class for handling character strings derived from std::string.
string & replace(const string &oldStr, const string &newStr, size_type start=0)
In this string replace first occurrence of sub-string oldStr.
A class for handling words, derived from string.
#define ClassName(TypeNameString)
Add typeName information from argument a TypeNameString to a class.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
List< word > wordList
A List of words.
Smanip< ios_base::fmtflags > setf(const ios_base::fmtflags flags)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Omanip< int > setw(const int i)
errorManip< error > abort(error &err)
labelList second(const UList< labelPair > &p)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
runTime controlDict().lookup("adjustTimeStep") >> adjustTimeStep
thermo validate(args.executable(), "h")
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable