39 #ifndef Foam_objectRegistry_H 40 #define Foam_objectRegistry_H 83 mutable bool cacheTemporaryObjectsActive_;
101 void readCacheTemporaryObjects()
const;
109 template<
class MatchPredicate1,
class MatchPredicate2>
110 static label countImpl
113 const MatchPredicate1& matchClass,
114 const MatchPredicate2& matchName
119 template<
class Type,
class MatchPredicate>
120 static label countTypeImpl
123 const MatchPredicate& matchName
127 template<
class MatchPredicate>
131 const MatchPredicate& matchName
135 template<
class MatchPredicate1,
class MatchPredicate2>
139 const MatchPredicate1& matchClass,
140 const MatchPredicate2& matchName,
145 template<
class Type,
class MatchPredicate>
149 const MatchPredicate& matchName,
155 template<
class Type,
class MatchPredicate>
160 const MatchPredicate& matchName,
194 const label initialCapacity = 128
202 const label initialCapacity = 128
250 template<
class MatchPredicate>
259 template<
class Type,
bool Strict=false>
265 template<
class Type,
bool Strict=false>
271 template<
class Type,
class MatchPredicate>
277 template<
class Type,
class MatchPredicate>
286 template<
class Type,
bool Strict=false>
292 template<
class Type,
bool Strict=false>
299 return csorted<regIOobject>();
306 return sorted<regIOobject>();
312 template<
class Type,
class MatchPredicate>
313 UPtrList<const Type>
csorted(
const MatchPredicate& matchName)
const;
318 template<
class Type,
class MatchPredicate>
319 UPtrList<Type>
sorted(
const MatchPredicate& matchName);
326 label
count(
const char* clsName)
const;
330 template<
class MatchPredicate>
331 label
count(
const MatchPredicate& matchClass)
const;
335 template<
class MatchPredicate1,
class MatchPredicate2>
338 const MatchPredicate1& matchClass,
339 const MatchPredicate2& matchName
351 label
count(
const bool strict =
false)
const;
357 template<
class Type,
class MatchPredicate>
358 label
count(
const MatchPredicate& matchName)
const;
372 template<
class MatchPredicate>
378 template<
class MatchPredicate1,
class MatchPredicate2>
381 const MatchPredicate1& matchClass,
382 const MatchPredicate2& matchName
395 template<
class Type,
class MatchPredicate>
410 template<
class MatchPredicate>
416 template<
class MatchPredicate1,
class MatchPredicate2>
419 const MatchPredicate1& matchClass,
420 const MatchPredicate2& matchName
433 template<
class Type,
class MatchPredicate>
446 const bool forceCreate =
false,
447 const bool recursive =
false 453 template<
class Type,
bool Strict=false>
458 template<
class Type,
bool Strict=false>
481 const bool recursive =
false 497 const bool recursive =
false 509 const bool recursive =
false 521 const bool recursive =
false 533 const bool recursive =
false 547 const bool recursive =
false 558 const bool recursive =
false 569 const bool recursive =
false 609 bool erase(
const iterator& iter);
619 label
erase(std::initializer_list<word>
keys);
686 const bool writeOnProc
695 return this->
contains(name, recursive);
705 bool recursive = false
708 return this->cfindObject<Type>(
name, recursive);
718 bool recursive = false
721 return this->getObjectPtr<Type>(
name, recursive);
728 UPtrList<const Type>
sorted()
const 730 return csorted<Type>();
738 return csorted<regIOobject>();
743 template<
class Type,
class MatchPredicate>
745 UPtrList<const Type>
sorted(const MatchPredicate& matchName)
const 747 return csorted<Type>(matchName);
bool cacheTemporaryObject(Type &obj) const
Cache the given object. Moves content and stores.
bool contains(const word &name, const bool recursive=false) const
Does the registry contain the regIOobject object (by name).
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...
A class for handling file names.
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...
const word & name() const noexcept
Return the object name.
bool erase(const iterator &iter)
Erase an entry specified by the given iterator.
UPtrList< const Type > csorted() const
Return sorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict) ...
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...
wordList names() const
The unsorted names of all objects.
virtual bool modified() const
Return true if any of the object's files have been modified.
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
A simple container for options an IOstream can normally have.
Operations on lists of strings.
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
const objectRegistry & subRegistry(const word &name, const bool forceCreate=false, const bool recursive=false) const
Lookup and return a const sub-objectRegistry.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
HashTable< const Type * > lookupClass() const
Return all objects with a class satisfying isA<Type> or isType<Type> (with Strict) ...
UPtrList< Type > sorted()
Return sorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict) ...
bool is_cacheTemporaryObject(const word &name) const
True if given name is in the cacheTemporaryObjects set.
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write the objects using stream options.
label count(const char *clsName) const
The number of objects of the given class name.
A class for handling words, derived from Foam::string.
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...
virtual bool writeData(Ostream &) const
The writeData function is required by regIOobject but not used.
const Time & time() const noexcept
Return time registry.
wordList sortedNames() const
The sorted names of all objects.
virtual ~objectRegistry()
Destructor, with checkOut() for all objects that are ownedByRegistry.
label getEvent() const
Return new event number.
const objectRegistry & db() const noexcept
Return the local objectRegistry.
virtual bool readIfModified()
Read object if modified.
A HashTable similar to std::unordered_map.
bool checkCacheTemporaryObjects() const
Check that all objects specified in the cacheTemporaryObjects were also cached.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Type * lookupObjectRefPtr(const word &name, bool recursive=false) const
Deprecated(2018-10) get object pointer, ignoring constness.
bool isTimeDb() const noexcept
True if the registry is Time.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void resetCacheTemporaryObject(const regIOobject *io) const
Reset the cache state of the given object (nullptr is ignored)
bool checkOut()
Remove all file watches and remove object from registry.
TypeName("objectRegistry")
Declare type name for this IOobject.
void clearStorage()
Clear all entries from the registry and the table itself.
UPtrList< const Type > cobjects() const
Return unsorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict) ...
List< word > wordList
List of word.
const Type * lookupObjectPtr(const word &name, bool recursive=false) const
Deprecated(2018-10) find object.
const objectRegistry & parent() const noexcept
Return the parent objectRegistry.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
UPtrList< Type > objects()
Return unsorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict) ...
void clear()
Clear all entries from the registry.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool found(const word &name, bool recursive=false) const
Same as contains()
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Registry of regIOobjects.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Defines the attributes of an object for which implicit objectRegistry management is supported...
const objectRegistry & thisDb() const noexcept
Return the object registry.
const_iterator_pair< const_key_iterator, this_type > keys() const
A const iterator begin/end pair for iterating over keys.
bool checkIn()
Add object to registry, if not already registered.
const regIOobject * cfindIOobject(const word &name, const bool recursive=false) const
Return const pointer to the regIOobject.
virtual void rename(const word &newName)
Rename.
HashTable< wordHashSet > classes() const
A summary hash of classes used and their associated object names.