39#ifndef Foam_objectRegistry_H
40#define Foam_objectRegistry_H
69 const objectRegistry& parent_;
78 mutable bool cacheTemporaryObjectsActive_;
93 bool parentNotTime()
const noexcept;
96 void readCacheTemporaryObjects()
const;
104 template<
class MatchPredicate1,
class MatchPredicate2>
105 static label countImpl
107 const objectRegistry& list,
108 const MatchPredicate1& matchClass,
109 const MatchPredicate2& matchName
114 template<
class Type,
class MatchPredicate>
115 static label countTypeImpl
117 const objectRegistry& list,
118 const MatchPredicate& matchName
122 template<
class MatchPredicate>
125 const objectRegistry& list,
126 const MatchPredicate& matchName
130 template<
class MatchPredicate1,
class MatchPredicate2>
133 const objectRegistry& list,
134 const MatchPredicate1& matchClass,
135 const MatchPredicate2& matchName,
140 template<
class Type,
class MatchPredicate>
143 const objectRegistry& list,
144 const MatchPredicate& matchName,
150 template<
class Type,
class MatchPredicate>
154 const objectRegistry& list,
155 const MatchPredicate& matchName,
165 const objectRegistry& list
170 objectRegistry(
const objectRegistry&) =
delete;
173 void operator=(
const objectRegistry&) =
delete;
186 explicit objectRegistry
189 const label initialCapacity = 128
194 explicit objectRegistry
197 const label initialCapacity = 128
210 const objectRegistry&
thisDb()
const noexcept
216 const objectRegistry&
parent()
const noexcept
270 template<
class MatchPredicate>
279 template<
class Type,
bool Strict=false>
285 template<
class Type,
bool Strict=false>
291 template<
class Type,
class MatchPredicate>
297 template<
class Type,
class MatchPredicate>
306 template<
class Type,
bool Strict=false>
312 template<
class Type,
bool Strict=false>
332 template<
class Type,
class MatchPredicate>
333 UPtrList<const Type>
csorted(
const MatchPredicate& matchName)
const;
338 template<
class Type,
class MatchPredicate>
346 label
count(
const char* clsName)
const;
350 template<
class MatchPredicate>
351 label
count(
const MatchPredicate& matchClass)
const;
355 template<
class MatchPredicate1,
class MatchPredicate2>
358 const MatchPredicate1& matchClass,
359 const MatchPredicate2& matchName
371 label
count(
const bool strict =
false)
const;
377 template<
class Type,
class MatchPredicate>
378 label
count(
const MatchPredicate& matchName)
const;
392 template<
class MatchPredicate>
398 template<
class MatchPredicate1,
class MatchPredicate2>
401 const MatchPredicate1& matchClass,
402 const MatchPredicate2& matchName
415 template<
class Type,
class MatchPredicate>
430 template<
class MatchPredicate>
436 template<
class MatchPredicate1,
class MatchPredicate2>
439 const MatchPredicate1& matchClass,
440 const MatchPredicate2& matchName
453 template<
class Type,
class MatchPredicate>
463 const bool forceCreate =
false,
464 const bool recursive =
false
470 template<
class Type,
bool Strict=false>
475 template<
class Type,
bool Strict=false>
496 const bool recursive =
false
504 const bool recursive =
false
515 const bool recursive =
false
525 const bool recursive =
false
535 const bool recursive =
false
545 const bool recursive =
false
557 const bool recursive =
false
566 const bool recursive =
false
575 const bool recursive =
false
615 bool erase(
const iterator& iter);
625 label
erase(std::initializer_list<word>
keys);
692 const bool writeOnProc
701 return this->
contains(name, recursive);
711 bool recursive = false
724 bool recursive = false
734 UPtrList<const Type>
sorted()
const
749 template<
class Type,
class MatchPredicate>
751 UPtrList<const Type>
sorted(const MatchPredicate& matchName)
const
A HashTable similar to std::unordered_map.
const_iterator_pair< const_key_iterator, this_type > keys() const
constexpr HashTable() noexcept
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
registerOption
Enumeration for use with registerObject(). Values map to bool (false/true).
@ NO_REGISTER
Do not request registration (bool: false).
constexpr IOobjectOption(readOption rOpt=readOption::NO_READ, writeOption wOpt=writeOption::NO_WRITE, registerOption registerObject=registerOption::REGISTER, bool globalObject=false) noexcept
Default construct (NO_READ, NO_WRITE, REGISTER, non-global) or construct with specified options.
readOption
Enumeration defining read preferences.
@ NO_READ
Nothing to be read.
writeOption
Enumeration defining write preferences.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
const objectRegistry & db() const noexcept
Return the local objectRegistry.
A simple container for options an IOstream can normally have.
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.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
A class for handling file names.
label count(const MatchPredicate &matchClass) const
The number of objects of the given class name.
UPtrList< Type > objects(const MatchPredicate &matchName)
Return sorted list of objects with a class satisfying isA<Type> that also have a matching object name...
wordList sortedNames(const MatchPredicate1 &matchClass, const MatchPredicate2 &matchName) const
The sorted names of objects with a matching class name that also have a matching object name.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write the objects using stream options.
bool contains(const word &name, const bool recursive=false) const
Does the registry contain the regIOobject object (by name).
label count(const MatchPredicate &matchName) const
The names of objects with a class satisfying isA<Type> that also have a matching object name.
const Type * lookupObjectPtr(const word &name, bool recursive=false) const
Deprecated(2018-10) find object.
UPtrList< const Type > cobjects(const MatchPredicate &matchName) const
Return unsorted list of objects with a class satisfying isA<Type> that also have a matching object na...
bool foundObject(const word &name, const bool recursive=false) const
Contains the named Type?
void resetCacheTemporaryObject(const regIOobject *io) const
Reset the cache state of the given object (nullptr is ignored).
wordList sortedNames() const
The sorted names of all objects.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
const objectRegistry & parent() const noexcept
Return the parent objectRegistry.
UPtrList< const Type > csorted() const
Return sorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict).
wordList names(const MatchPredicate &matchClass) const
The unsorted names of objects with a matching class name.
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.
UPtrList< const Type > csorted(const MatchPredicate &matchName) const
Return sorted list of objects with a class satisfying isA<Type> that also have a matching object name...
HashTable< wordHashSet > classes() const
A summary hash of classes used and their associated object names.
UPtrList< Type > sorted(const MatchPredicate &matchName)
Return sorted list of objects with a class satisfying isA<Type> that also have a matching object name...
UPtrList< Type > objects()
Return unsorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict).
virtual ~objectRegistry()
Destructor, with checkOut() for all objects that are ownedByRegistry.
TypeName("objectRegistry")
Declare type name for this IOobject.
HashTable< Type * > lookupClass()
Return all objects with a class satisfying isA<Type> or isType<Type> (with Strict).
const Time & time() const noexcept
Return time registry.
bool cacheTemporaryObject(Type &obj) const
Cache the given object. Moves content and stores.
void clearStorage()
Clear all entries from the registry and the table itself.
UPtrList< regIOobject > sorted()
Return sorted list of objects.
label count(const bool strict=false) const
The names of objects with a class satisfying isA<Type>.
wordList names(const MatchPredicate1 &matchClass, const MatchPredicate2 &matchName) const
The unsorted names of objects with a matching class name that also have a matching object name.
wordList names(const MatchPredicate &matchName) const
The unsorted names of objects with a class satisfying isA<Type> that also have a matching object name...
wordList names() const
The unsorted names of objects with a class satisfying isA<Type>.
UPtrList< const regIOobject > csorted() const
Return sorted list of objects.
HashTable< Type * > lookupClass(const bool strict)
Return all objects with a class satisfying isA<Type>.
bool checkCacheTemporaryObjects() const
Check that all objects specified in the cacheTemporaryObjects were also cached.
Type * lookupObjectRefPtr(const word &name, bool recursive=false) const
Deprecated(2018-10) get object pointer, ignoring constness.
HashTable< wordHashSet > classes(const MatchPredicate &matchName) const
A summary hash of classes used and their associated object names, restricted to objects that have a m...
wordList sortedNames(const MatchPredicate &matchName) const
The sorted names of objects with a class satisfying isA<Type> that also have a matching object name.
IOobject newIOobject(const word &name, IOobjectOption ioOpt) const
Create an IOobject at the current time instance (timeName) with the specified options.
wordList sortedNames() const
The sorted names of objects with a class satisfying isA<Type>.
const regIOobject * cfindIOobject(const word &name, const bool recursive=false) const
Return const pointer to the regIOobject.
virtual bool readIfModified()
Read object if modified.
virtual bool writeData(Ostream &) const
The writeData function is required by regIOobject but not used.
const objectRegistry & thisDb() const noexcept
Return the object registry.
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.
HashTable< const Type * > lookupClass() const
Return all objects with a class satisfying isA<Type> or isType<Type> (with Strict).
bool found(const word &name, bool recursive=false) const
Same as contains().
wordList sortedNames(const MatchPredicate &matchClass) const
The sorted names objects with a matching class name.
void clear()
Clear all entries from the registry.
UPtrList< Type > sorted()
Return sorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict).
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
void readModifiedObjects()
Read the objects that have been modified.
Type & lookupObjectRef(const word &name, const bool recursive=false) const
Lookup and return non-const reference to the object of the given Type. Fatal if not found or the wron...
wordList names() const
The unsorted names of all objects.
label count(const MatchPredicate1 &matchClass, const MatchPredicate2 &matchName) const
The number of objects of the given class name.
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
UPtrList< const Type > cobjects() const
Return unsorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict).
label count(const char *clsName) const
The number of objects of the given class name.
bool is_cacheTemporaryObject(const word &name) const
True if given name is in the cacheTemporaryObjects set.
HashTable< const Type * > lookupClass(const bool strict) const
Return all objects with a class satisfying isA<Type>.
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
virtual void rename(const word &newName)
Rename.
label getEvent() const
Return new event number.
Type * getObjectPtr(const word &name, const bool recursive=false) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
bool checkOut()
Remove object from registry, and remove all file watches.
bool checkIn()
Add object to registry, if not already registered.
A class for handling words, derived from Foam::string.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
List< word > wordList
List of word.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
#define FOAM_DEPRECATED_FOR(since, replacement)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.