CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums

runTime.write()

Register Blogs Community New Posts Updated Threads Search

Rate this Entry

runTime.write()

Posted April 4, 2017 at 09:42 by kindle

Code:
for (const_iterator iter = begin(); iter != end(); ++iter)


is replaced by

Code:
forAllConstIter(HashTable<regIOobject*>, *this, iter)


iterator is a built-in pointer of containers, here class objectRegistry inherates from regIOobject and more importantly has access to a table of IOobject.

In the above iteration, iteration is done for all object registried.

In the quoted code, iter() is a pointer pointing to IOobject and it calls writeOpt() using the ->.

Quote:
Originally Posted by hjasak View Post
Not too difficult. runTime is class type Time:

db/Time/Time.H

which is derived from objectRegistry, which is in turn derived from regIOobject:

db/objectRegistry/objectRegistry.H
db/regIOobject/regIOobject.H

regIOobject has got a fiunction called write() and a virtual function writeObject:

//- Write using given format, version and compression
virtual bool writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const;

//- Write using setting from DB
virtual bool write() const;


Clearly, write is just a wrapper around writeData. This one is over-ridden for objectRegistry and reads:

bool objectRegistry::writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const
{
bool ok = true;

for (const_iterator iter = begin(); iter != end(); ++iter)
{
if (objectRegistry::debug)
{
Pout<< "objectRegistry::write() : "
<< "Considering writing object "
<<>name()
<<>writeOpt()
<< endl;


if (iter()->writeOpt() != NO_WRITE)
{
ok = iter()->writeObject(fmt, ver, cmp) && ok;
}
}

return ok;
}}

Thus: loop over all objects registred in the object registry and offer them to write themselves. Each object will decide if it wants to do so, based on the settings, eg. NO_WRITE or AUTO_WRITE.

Clear?

Hrv
Posted in programming
Views 986 Comments 0 Edit Tags Email Blog Entry
« Prev     Main     Next »
Total Comments 0

Comments

 

All times are GMT -4. The time now is 23:48.