48template<
class InputIter>
55 const label nTotal = obr.
size();
56 changed < nTotal && first != last;
60 if (obr.
erase(*first))
74bool Foam::objectRegistry::parentNotTime() const noexcept
76 return (&parent_ !=
static_cast<const objectRegistry*
>(&time_));
111 dbDir_(parent_.dbDir()/local()/
name()),
143 return count(
static_cast<word>(clsName));
183 return names(
static_cast<word>(clsName));
190 return sortedNames(
static_cast<word>(clsName));
197 const bool forceCreate,
201 if (forceCreate && !foundObject<objectRegistry>(
name, recursive))
217 return lookupObject<objectRegistry>(
name, recursive);
223 label curEvent = event_++;
227 if (objectRegistry::debug)
230 <<
"Event counter has overflowed. "
231 <<
"Resetting counter on all dependent objects." <<
nl
232 <<
"This might cause extra evaluations." <<
endl;
249 if (!
io)
return false;
251 if (objectRegistry::debug)
253 Pout<<
"objectRegistry::checkIn : "
255 <<
" of type " <<
io->type()
263 if (!ok && objectRegistry::debug)
266 <<
name() <<
" : Attempt to checkIn object with name "
267 <<
io->
name() <<
" which was already checked in"
277 if (!
io)
return false;
285 if (objectRegistry::debug)
287 Pout<<
"objectRegistry::checkOut : "
289 <<
" of type " <<
io->type()
293 if (iter.val() !=
io)
295 if (objectRegistry::debug)
298 <<
name() <<
" : Attempt to checkOut copy of "
306 return obr.
erase(iter);
310 if (objectRegistry::debug)
312 Pout<<
"objectRegistry::checkOut : "
313 <<
name() <<
" : could not find " <<
io->
name() <<
" in registry"
329 return checkOut(&
io);
345 for (iterator iter = begin(); iter != end(); ++iter)
351 if (objectRegistry::debug)
353 Pout<<
"objectRegistry::clear : " << ptr->
name() <<
nl;
378 regIOobject* ptr =
const_cast<iterator&
>(iter).val();
397 return erase(find(key));
403 return eraseImpl(*
this, keys.begin(), keys.end());
418 const auto i = dbDir_.rfind(
'/');
437 const_iterator iter = cfind(
name);
443 else if (recursive && this->parentNotTime())
445 return parent_.cfindIOobject(
name, recursive);
458 return cfindIOobject(
name, recursive);
464 for (const_iterator iter = cbegin(); iter != cend(); ++iter)
466 if (iter.val()->modified())
478 for (iterator iter = begin(); iter != end(); ++iter)
480 if (objectRegistry::debug)
482 Pout<<
"objectRegistry::readModifiedObjects() : "
483 <<
name() <<
" : Considering reading object "
484 << iter.key() <<
endl;
487 iter.val()->readIfModified();
494 readModifiedObjects();
507 for (const_iterator iter = cbegin(); iter != cend(); ++iter)
509 if (objectRegistry::debug)
513 Pout<<
"objectRegistry::write() : "
514 <<
name() <<
" : Considering writing object "
515 << iter.key() <<
" of type "
516 << obj.type() <<
" with writeOpt "
521 if (iter.val()->writeOpt() != NO_WRITE)
523 ok = iter.val()->writeObject(streamOpt, valid) && ok;
bool checkOut()
Check-out Callback from CallbackRegistry.
bool checkIn()
Register Callback with CallbackRegistry.
A HashTable similar to std::unordered_map.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
void clearStorage()
Clear the table entries and the table itself.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
void clear()
Clear all entries from table.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
fileName objectRelPath() const
The object path relative to the root.
writeOption writeOpt() const noexcept
The write option.
The IOstreamOption is a simple container for options an IOstream can normally have.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
iterator begin() noexcept
Return an iterator to begin traversing the UList.
iterator end() noexcept
Return an iterator to end traversing the UList.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Registry of regIOobjects.
UPtrList< const regIOobject > sorted() const
Return sorted list of objects.
wordList sortedNames() const
The sorted names of all objects.
virtual bool modified() const
Return true if any of the object's files have been modified.
bool isTimeDb() const noexcept
True if the registry is Time.
HashTable< wordHashSet > classes() const
A summary hash of classes used and their associated object names.
virtual ~objectRegistry()
Destructor, with checkOut() for all objects that are ownedByRegistry.
void clearStorage()
Clear all entries from the registry and the table itself.
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write the objects using stream options.
const regIOobject * cfindIOobject(const word &name, const bool recursive=false) const
Return const pointer to the regIOobject.
virtual bool readIfModified()
Read object if modified.
bool erase(const iterator &iter)
Erase an entry specified by the given iterator.
const objectRegistry & subRegistry(const word &name, const bool forceCreate=false, const bool recursive=false) const
Lookup and return a const sub-objectRegistry.
void clear()
Clear all entries from the registry.
UPtrList< const regIOobject > csorted() const
Return sorted list of objects.
void readModifiedObjects()
Read the objects that have been modified.
wordList names() const
The unsorted names of all objects.
virtual void rename(const word &newName)
Rename.
label getEvent() const
Return new event number.
constant condensation/saturation model.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool ownedByRegistry() const noexcept
Is this object owned by the registry?
void release(const bool unregister=false) noexcept
Set object as not ownedByRegistry.
virtual void rename(const word &newName)
Rename.
string & replace(const std::string &s1, const std::string &s2, size_type pos=0)
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define WarningInFunction
Report a warning using Foam::Warning.
static label eraseImpl(objectRegistry &obr, InputIter first, InputIter last)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
constexpr char nl
The newline '\n' character (0x0a)
thermo validate(args.executable(), "h")
Unary and binary predicates that always return true, useful for templating.