39 #ifndef Foam_objectRegistry_H 40 #define Foam_objectRegistry_H 78 mutable bool cacheTemporaryObjectsActive_;
96 void readCacheTemporaryObjects()
const;
104 template<
class MatchPredicate1,
class MatchPredicate2>
105 static label countImpl
108 const MatchPredicate1& matchClass,
109 const MatchPredicate2& matchName
114 template<
class Type,
class MatchPredicate>
115 static label countTypeImpl
118 const MatchPredicate& matchName
122 template<
class MatchPredicate>
126 const MatchPredicate& matchName
130 template<
class MatchPredicate1,
class MatchPredicate2>
134 const MatchPredicate1& matchClass,
135 const MatchPredicate2& matchName,
140 template<
class Type,
class MatchPredicate>
144 const MatchPredicate& matchName,
150 template<
class Type,
class MatchPredicate>
155 const MatchPredicate& matchName,
189 const label initialCapacity = 128
197 const label initialCapacity = 128
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>
319 return csorted<regIOobject>();
326 return sorted<regIOobject>();
332 template<
class Type,
class MatchPredicate>
333 UPtrList<const Type>
csorted(
const MatchPredicate& matchName)
const;
338 template<
class Type,
class MatchPredicate>
339 UPtrList<Type>
sorted(
const MatchPredicate& matchName);
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>
466 const bool forceCreate =
false,
467 const bool recursive =
false 473 template<
class Type,
bool Strict=false>
478 template<
class Type,
bool Strict=false>
501 const bool recursive =
false 517 const bool recursive =
false 529 const bool recursive =
false 541 const bool recursive =
false 553 const bool recursive =
false 567 const bool recursive =
false 578 const bool recursive =
false 589 const bool recursive =
false 629 bool erase(
const iterator& iter);
639 label
erase(std::initializer_list<word>
keys);
706 const bool writeOnProc
715 return this->
contains(name, recursive);
725 bool recursive = false
728 return this->cfindObject<Type>(
name, recursive);
738 bool recursive = false
741 return this->getObjectPtr<Type>(
name, recursive);
748 UPtrList<const Type>
sorted()
const 750 return csorted<Type>();
758 return csorted<regIOobject>();
763 template<
class Type,
class MatchPredicate>
765 UPtrList<const Type>
sorted(const MatchPredicate& matchName)
const 767 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).
writeOption
Enumeration defining write preferences.
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.
Ignore writing from objectRegistry::writeObject()
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 object from registry, and remove all file watches.
TypeName("objectRegistry")
Declare type name for this IOobject.
void clearStorage()
Clear all entries from the registry and the table itself.
registerOption
Enumeration for use with registerObject(). Values map to bool (false/true)
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) ...
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
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)
IOobject newIOobject(const word &name, IOobjectOption ioOpt) const
Create an IOobject at the current time instance (timeName) with the specified options.
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.
Do not request registration (bool: false)
virtual void rename(const word &newName)
Rename.
HashTable< wordHashSet > classes() const
A summary hash of classes used and their associated object names.
readOption
Enumeration defining read preferences.