Go to the documentation of this file.
48 template<
class InputIter>
55 const label nTotal = obr.
size();
56 changed < nTotal && first != last;
60 if (obr.
erase(*first))
74 bool Foam::objectRegistry::parentNotTime()
const
76 return (&parent_ !=
dynamic_cast<const objectRegistry*
>(&time_));
88 const_iterator iter = cfind(
name);
94 else if (recursive && this->parentNotTime())
96 return parent_.cfindIOobject(
name, recursive);
105 Foam::objectRegistry::objectRegistry(
const Time& t,
const label nObjects)
128 Foam::objectRegistry::objectRegistry(
const IOobject& io,
const label nObjects)
134 dbDir_(parent_.dbDir()/local()/
name()),
160 return count(
static_cast<word>(clsName));
179 return names(
static_cast<word>(clsName));
186 return sortedNames(
static_cast<word>(clsName));
193 const bool forceCreate,
197 if (forceCreate && !foundObject<objectRegistry>(
name, recursive))
213 return lookupObject<objectRegistry>(
name, recursive);
219 label curEvent = event_++;
226 <<
"Event counter has overflowed. "
227 <<
"Resetting counter on all dependent objects." <<
nl
228 <<
"This might cause extra evaluations." <<
endl;
245 if (!io)
return false;
249 Pout<<
"objectRegistry::checkIn : "
250 <<
name() <<
" : checking in " << io->
name()
251 <<
" of type " << io->type()
262 <<
name() <<
" : Attempt to checkIn object with name "
263 << io->
name() <<
" which was already checked in"
273 if (!io)
return false;
277 iterator iter = obr.
find(io->
name());
283 Pout<<
"objectRegistry::checkOut : "
284 <<
name() <<
" : checking out " << io->
name()
285 <<
" of type " << io->type()
289 if (iter.val() != io)
294 <<
name() <<
" : Attempt to checkOut copy of "
302 return obr.
erase(iter);
308 Pout<<
"objectRegistry::checkOut : "
309 <<
name() <<
" : could not find " << io->
name() <<
" in registry"
325 return checkOut(&io);
341 for (iterator iter =
begin(); iter !=
end(); ++iter)
349 Pout<<
"objectRegistry::clear : " << ptr->
name() <<
nl;
374 regIOobject* ptr =
const_cast<iterator&
>(iter).val();
399 return eraseImpl(*
this, keys.begin(), keys.end());
414 const auto i = dbDir_.rfind(
'/');
416 if (i == string::npos)
422 dbDir_.
replace(i+1, string::npos, newName);
433 return cfindIOobject(
name, recursive);
439 for (const_iterator iter =
cbegin(); iter !=
cend(); ++iter)
441 if ((*iter)->modified())
453 for (iterator iter =
begin(); iter !=
end(); ++iter)
457 Pout<<
"objectRegistry::readModifiedObjects() : "
458 <<
name() <<
" : Considering reading object "
459 << iter.key() <<
endl;
462 (*iter)->readIfModified();
469 readModifiedObjects();
482 for (const_iterator iter =
cbegin(); iter !=
cend(); ++iter)
486 Pout<<
"objectRegistry::write() : "
487 <<
name() <<
" : Considering writing object "
489 <<
" of type " << (*iter)->type()
490 <<
" with writeOpt " <<
static_cast<int>((*iter)->writeOpt())
491 <<
" to file " << (*iter)->objectPath()
495 if ((*iter)->writeOpt() != NO_WRITE)
497 ok = (*iter)->writeObject(streamOpt, valid) && ok;
string & replace(const std::string &s1, const std::string &s2, size_type pos=0)
int debug
Static debugging option.
label size() const noexcept
The number of elements in table.
virtual bool readIfModified()
Read object if modified.
wordList sortedNames() const
The sorted names of all objects.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual ~objectRegistry()
Destructor, with checkOut() for all objects that are ownedByRegistry.
label getEvent() const
Return new event number.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
const word & name() const
Return name.
A class for handling words, derived from Foam::string.
constexpr auto begin(C &c) -> decltype(c.begin())
Return iterator to the beginning of the container c.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
void release(const bool unregister=false)
Release ownership of this object from its registry.
void clearStorage()
Clear all entries from the registry and the table itself.
thermo validate(args.executable(), "h")
bool checkIn()
Add object to registry, if not already registered.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
void clear()
Clear all entries from the registry.
Ostream & endl(Ostream &os)
Add newline and flush stream.
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
iterator begin()
Return an iterator to begin traversing the UList.
Unary and binary predicates that always return true, useful for templating.
Registry of regIOobjects.
virtual void rename(const word &newName)
Rename.
writeOption writeOpt() const
The write option.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
word name(const complex &c)
Return string representation of complex.
HashTable< wordHashSet > classes() const
A summary hash of classes used and their associated object names.
The IOstreamOption is a simple container for options an IOstream can normally have.
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write the objects using stream options.
bool found(const word &name, const bool recursive=false) const
Can the regIOobject object be found (by name).
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Find index of the first occurrence that satisfies the predicate.
bool ownedByRegistry() const
Is this object owned by the registry?
static label eraseImpl(objectRegistry &obr, InputIter first, InputIter last)
constexpr auto cend(const C &c) -> decltype(c.end())
Return const_iterator to the end of the container c.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
A HashTable similar to std::unordered_map.
virtual bool modified() const
Return true if any of the object's files have been modified.
void readModifiedObjects()
Read the objects that have been modified.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool erase(const iterator &iter)
Erase an entry specified by the given iterator.
void clearStorage()
Clear the table entries and the table itself.
bool checkOut()
Remove all file watches and remove object from registry.
constexpr auto cbegin(const C &c) -> decltype(c.begin())
Return const_iterator to the beginning of the container c.
void clear()
Clear all entries from table.
wordList names() const
The names of all objects.
const objectRegistry & subRegistry(const word &name, const bool forceCreate=false, const bool recursive=false) const
Lookup and return a const sub-objectRegistry.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
virtual void rename(const word &newName)
Rename.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
iterator end()
Return an iterator to end traversing the UList.
label count(const char *clsName) const
The number of objects of the given class name.
constant condensation/saturation model.
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.