objectRegistry.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2019 OpenFOAM Foundation
9  Copyright (C) 2016-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::objectRegistry
29 
30 Description
31  Registry of regIOobjects
32 
33 SourceFiles
34  objectRegistry.C
35  objectRegistryTemplates.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_objectRegistry_H
40 #define Foam_objectRegistry_H
41 
42 #include "HashTable.H"
43 #include "HashSet.H"
44 #include "UPtrList.H"
45 #include "regIOobject.H"
46 #include "wordRes.H"
47 #include "Pair.H"
48 
49 // Historically included by objectRegistryTemplates (until NOV-2018),
50 // but not used by objectRegistry directly.
51 // Leave here for now to avoid a missing include in other bits of code.
52 #include "stringListOps.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class objectRegistry Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class objectRegistry
64 :
65  public regIOobject,
66  public HashTable<regIOobject*>
67 {
68  // Private Data
69 
70  //- Master time objectRegistry
71  const Time& time_;
72 
73  //- Parent objectRegistry
74  const objectRegistry& parent_;
75 
76  //- Local directory path of this objectRegistry relative to time
77  fileName dbDir_;
78 
79  //- Current event
80  mutable label event_;
81 
82  //- State of cacheTemporaryObjects_, set true after reading
83  mutable bool cacheTemporaryObjectsActive_;
84 
85  //- Names of temporary object with current state
86  mutable HashTable<Pair<bool>> cacheTemporaryObjects_;
87 
88  //- Accumulated list of temporary objects available to cache
89  // Used to provide diagnostics in case the requested object is not
90  // available
91  mutable wordHashSet temporaryObjects_;
92 
93 
94  // Private Member Functions
95 
96  //- Is the objectRegistry parent_ different from time_
97  // Used to terminate searching within the ancestors
98  bool parentNotTime() const noexcept;
99 
100  //- Read the cacheTemporaryObjects list from Time controlDict
101  void readCacheTemporaryObjects() const;
102 
103  //- Delete the cached object. Eg, before caching a new object
104  //- A nullptr is ignored.
105  void deleteCachedObject(regIOobject* io) const;
106 
107  //- Templated implementation for count()
108  // The number of items with a matching class
109  template<class MatchPredicate1, class MatchPredicate2>
110  static label countImpl
111  (
112  const objectRegistry& list,
113  const MatchPredicate1& matchClass,
114  const MatchPredicate2& matchName
115  );
116 
117  //- Templated implementation for count()
118  // The number of items with a matching class
119  template<class Type, class MatchPredicate>
120  static label countTypeImpl
121  (
122  const objectRegistry& list,
123  const MatchPredicate& matchName
124  );
125 
126  //- Templated implementation for classes()
127  template<class MatchPredicate>
128  static HashTable<wordHashSet> classesImpl
129  (
130  const objectRegistry& list,
131  const MatchPredicate& matchName
132  );
133 
134  //- Templated implementation for names(), sortedNames()
135  template<class MatchPredicate1, class MatchPredicate2>
136  static wordList namesImpl
137  (
138  const objectRegistry& list,
139  const MatchPredicate1& matchClass,
140  const MatchPredicate2& matchName,
141  const bool doSort
142  );
143 
144  //- Templated implementation for names(), sortedNames()
145  template<class Type, class MatchPredicate>
146  static wordList namesTypeImpl
147  (
148  const objectRegistry& list,
149  const MatchPredicate& matchName,
150  const bool doSort
151  );
152 
153  //- Templated implementation for csorted()/sorted()
154  // Called with 'Type' or 'const Type'
155  template<class Type, class MatchPredicate>
156  static UPtrList<Type> objectsTypeImpl
157  (
158  const bool strict, // Check with isType<Type>
159  const objectRegistry& list,
160  const MatchPredicate& matchName,
161  const bool doSort // Sort the list by name
162  );
163 
164  //- Templated implementation for lookupClass()
165  // Called with 'Type' or 'const Type'
166  template<class Type>
167  static HashTable<Type*> lookupClassTypeImpl
168  (
169  const bool strict, // Check with isType<Type>
170  const objectRegistry& list
171  );
172 
173 
174  //- No copy construct
175  objectRegistry(const objectRegistry&) = delete;
176 
177  //- No copy assignment
178  void operator=(const objectRegistry&) = delete;
179 
180 
181 public:
182 
183  //- Declare type name for this IOobject
184  TypeName("objectRegistry");
185 
186 
187  // Constructors
188 
189  //- Construct the time objectRegistry,
190  //- with estimated table capacity (default: 128)
191  explicit objectRegistry
192  (
193  const Time& db,
194  const label initialCapacity = 128
195  );
196 
197  //- Construct sub-registry given an IObject to describe the registry,
198  //- with estimated table capacity (default: 128)
199  explicit objectRegistry
200  (
201  const IOobject& io,
202  const label initialCapacity = 128
203  );
204 
205 
206  //- Destructor, with checkOut() for all objects that are ownedByRegistry
207  virtual ~objectRegistry();
208 
209 
210  // Member Functions
211 
212  // Access
213 
214  //- Return the object registry
215  const objectRegistry& thisDb() const noexcept
216  {
217  return *this;
218  }
219 
220  //- Return the parent objectRegistry
221  const objectRegistry& parent() const noexcept
222  {
223  return parent_;
224  }
225 
226  //- Return time registry
227  const Time& time() const noexcept
228  {
229  return time_;
230  }
231 
232  //- True if the registry is Time
233  bool isTimeDb() const noexcept;
234 
235  //- Local directory path of this objectRegistry relative to the time
236  virtual const fileName& dbDir() const
237  {
238  return dbDir_;
239  }
240 
241 
242  // Summary of classes
243 
244  //- A summary hash of classes used and their associated object names.
245  // Behaviour and usage as per IOobjectList::classes
247 
248  //- A summary hash of classes used and their associated object names,
249  //- restricted to objects that have a matching object name.
250  template<class MatchPredicate>
251  HashTable<wordHashSet> classes(const MatchPredicate& matchName) const;
252 
253 
254  // List-wise access (unsorted)
255 
256  //- Return unsorted list of objects with a class satisfying
257  //- \c isA<Type> or \c isType<Type> (with Strict)
258  // The lifetime of the returned content cannot exceed the parent!
259  template<class Type, bool Strict=false>
261 
262  //- Return unsorted list of objects with a class satisfying
263  //- \c isA<Type> or \c isType<Type> (with Strict)
264  // The lifetime of the returned content cannot exceed the parent!
265  template<class Type, bool Strict=false>
267 
268  //- Return unsorted list of objects with a class satisfying
269  //- \c isA<Type> that also have a matching object name.
270  // The lifetime of the returned content cannot exceed the parent!
271  template<class Type, class MatchPredicate>
272  UPtrList<const Type> cobjects(const MatchPredicate& matchName) const;
273 
274  //- Return sorted list of objects with a class satisfying \c isA<Type>
275  //- that also have a matching object name.
276  // The lifetime of the returned content cannot exceed the parent!
277  template<class Type, class MatchPredicate>
278  UPtrList<Type> objects(const MatchPredicate& matchName);
279 
281  // List-wise access (sorted)
282 
283  //- Return sorted list of objects with a class satisfying
284  //- \c isA<Type> or \c isType<Type> (with Strict)
285  // The lifetime of the returned content cannot exceed the parent!
286  template<class Type, bool Strict=false>
288 
289  //- Return sorted list of objects with a class satisfying
290  //- \c isA<Type> or \c isType<Type> (with Strict)
291  // The lifetime of the returned content cannot exceed the parent!
292  template<class Type, bool Strict=false>
294 
295  //- Return sorted list of objects
296  // The lifetime of the returned content cannot exceed the parent!
298  {
299  return csorted<regIOobject>();
300  }
301 
302  //- Return sorted list of objects
303  // The lifetime of the returned content cannot exceed the parent!
305  {
306  return sorted<regIOobject>();
307  }
308 
309  //- Return sorted list of objects with a class satisfying
310  //- \c isA<Type> that also have a matching object name.
311  // The lifetime of the returned content cannot exceed the parent!
312  template<class Type, class MatchPredicate>
313  UPtrList<const Type> csorted(const MatchPredicate& matchName) const;
314 
315  //- Return sorted list of objects with a class satisfying
316  //- \c isA<Type> that also have a matching object name.
317  // The lifetime of the returned content cannot exceed the parent!
318  template<class Type, class MatchPredicate>
319  UPtrList<Type> sorted(const MatchPredicate& matchName);
320 
321 
322  // Number of items
323 
324  //- The number of objects of the given class name
325  // \note uses the class type() method
326  label count(const char* clsName) const;
327 
328  //- The number of objects of the given class name
329  // \note uses the class type() method
330  template<class MatchPredicate>
331  label count(const MatchPredicate& matchClass) const;
332 
333  //- The number of objects of the given class name
334  // \note uses the class type() method
335  template<class MatchPredicate1, class MatchPredicate2>
336  label count
337  (
338  const MatchPredicate1& matchClass,
339  const MatchPredicate2& matchName
340  ) const;
341 
342  //- The names of objects with a class satisfying \c isA<Type>
343  //
344  // \param strict use \c isType<Type> instead of \c isA<Type>
345  //
346  // \note The values of \c count<Type>() and \c count(Type::typeName)
347  // may be inconsistent, since they use different mechanisms for
348  // testing the class type.
349  // \note If \a Type is \c void, no isA check is used (always true).
350  template<class Type>
351  label count(const bool strict = false) const;
352 
353  //- The names of objects with a class satisfying \c isA<Type>
354  //- that also have a matching object name.
355  //
356  // \note If \a Type is \c void, no isA check is used (always true).
357  template<class Type, class MatchPredicate>
358  label count(const MatchPredicate& matchName) const;
359 
360 
361  // Summary of names
362 
363  //- The unsorted names of all objects
364  wordList names() const;
365 
366  //- The unsorted names of objects with the given class name.
367  // \note uses the class type() method
368  wordList names(const char* clsName) const;
369 
370  //- The unsorted names of objects with a matching class name
371  // \note uses the class type() method
372  template<class MatchPredicate>
373  wordList names(const MatchPredicate& matchClass) const;
374 
375  //- The unsorted names of objects with a matching class name
376  //- that also have a matching object name.
377  // \note uses the class type() method
378  template<class MatchPredicate1, class MatchPredicate2>
380  (
381  const MatchPredicate1& matchClass,
382  const MatchPredicate2& matchName
383  ) const;
384 
385  //- The unsorted names of objects with a class satisfying \c isA<Type>
386  //
387  // \note If \a Type is \c void, no isA check is used (always true).
388  template<class Type>
389  wordList names() const;
391  //- The unsorted names of objects with a class satisfying \c isA<Type>
392  //- that also have a matching object name.
393  //
394  // \note If \a Type is \c void, no isA check is used (always true).
395  template<class Type, class MatchPredicate>
396  wordList names(const MatchPredicate& matchName) const;
397 
398 
399  // Summary of names (sorted)
400 
401  //- The sorted names of all objects
402  wordList sortedNames() const;
403 
404  //- The sorted names of objects with the given class name.
405  // \note uses the class type() method
406  wordList sortedNames(const char* clsName) const;
407 
408  //- The sorted names objects with a matching class name
409  // \note uses the class type() method
410  template<class MatchPredicate>
411  wordList sortedNames(const MatchPredicate& matchClass) const;
412 
413  //- The sorted names of objects with a matching class name
414  //- that also have a matching object name.
415  // \note uses the class type() method
416  template<class MatchPredicate1, class MatchPredicate2>
418  (
419  const MatchPredicate1& matchClass,
420  const MatchPredicate2& matchName
421  ) const;
422 
423  //- The sorted names of objects with a class satisfying \c isA<Type>
424  //
425  // \note If \a Type is \c void, no isA check is used (always true).
426  template<class Type>
427  wordList sortedNames() const;
428 
429  //- The sorted names of objects with a class satisfying \c isA<Type>
430  //- that also have a matching object name.
431  //
432  // \note If \a Type is \c void, no isA check is used (always true).
433  template<class Type, class MatchPredicate>
434  wordList sortedNames(const MatchPredicate& matchName) const;
435 
436 
437  // Lookup
438 
439  //- Lookup and return a const sub-objectRegistry.
440  //
441  // \param forceCreate create it if it does not exist.
442  // \param recursive search parent registries.
444  (
445  const word& name,
446  const bool forceCreate = false,
447  const bool recursive = false
448  ) const;
449 
450 
451  //- Return all objects with a class satisfying
452  //- \c isA<Type> or \c isType<Type> (with Strict)
453  template<class Type, bool Strict=false>
455 
456  //- Return all objects with a class satisfying
457  //- \c isA<Type> or \c isType<Type> (with Strict)
458  template<class Type, bool Strict=false>
460 
461  //- Return all objects with a class satisfying \c isA<Type>
462  //
463  // \param strict use \c isType<Type> instead of \c isA<Type>
464  template<class Type>
465  HashTable<const Type*> lookupClass(const bool strict) const;
466 
467  //- Return all objects with a class satisfying \c isA<Type>
468  //
469  // \param strict use \c isType<Type> instead of \c isA<Type>
470  template<class Type>
471  HashTable<Type*> lookupClass(const bool strict);
472 
473  //- Return const pointer to the regIOobject.
474  //
475  // \param recursive search parent registries
476  //
477  // \return nullptr if the object was not found.
479  (
480  const word& name,
481  const bool recursive = false
482  ) const;
483 
484  //- Does the registry contain the regIOobject object (by name).
485  //
486  // \param name the object name
487  // \param recursive search parent registries
488  bool contains(const word& name, const bool recursive = false) const;
489 
490  //- Is the named Type found?
491  //
492  // \param recursive search parent registries
493  template<class Type>
494  bool foundObject
495  (
496  const word& name,
497  const bool recursive = false
498  ) const;
499 
500  //- Return const pointer to the object of the given Type.
501  //
502  // \param recursive search parent registries
503  //
504  // \return nullptr if the object was not found or had incorrect type.
505  template<class Type>
506  const Type* cfindObject
507  (
508  const word& name,
509  const bool recursive = false
510  ) const;
511 
512  //- Return const pointer to the object of the given Type.
513  //
514  // \param recursive search parent registries
515  //
516  // \return nullptr if the object was not found or had incorrect type.
517  template<class Type>
518  const Type* findObject
519  (
520  const word& name,
521  const bool recursive = false
522  ) const;
523 
524  //- Return non-const pointer to the object of the given Type.
525  //
526  // \param recursive search parent registries
527  //
528  // \return nullptr if the object was not found or had incorrect type.
529  template<class Type>
530  Type* findObject
531  (
532  const word& name,
533  const bool recursive = false
534  );
535 
536  //- Return non-const pointer to the object of the given Type,
537  //- using a const-cast to have it behave like a mutable.
538  // Exercise caution when using.
539  //
540  // \param recursive search parent registries.
541  //
542  // \return nullptr if the object was not found or had incorrect type.
543  template<class Type>
544  Type* getObjectPtr
545  (
546  const word& name,
547  const bool recursive = false
548  ) const;
549 
550  //- Lookup and return const reference to the object
551  //- of the given Type. Fatal if not found or the wrong type.
552  //
553  // \param recursive search parent registries.
554  template<class Type>
555  const Type& lookupObject
556  (
557  const word& name,
558  const bool recursive = false
559  ) const;
560 
561  //- Lookup and return non-const reference to the object
562  //- of the given Type. Fatal if not found or the wrong type.
563  //
564  // \param recursive search parent registries.
565  template<class Type>
566  Type& lookupObjectRef
567  (
568  const word& name,
569  const bool recursive = false
570  ) const;
571 
572 
573  // Events
574 
575  //- Return new event number.
576  label getEvent() const;
577 
578 
579  // Edit
580 
581  //- Add a regIOobject to registry. A nullptr is ignored.
582  bool checkIn(regIOobject* io) const;
583 
584  //- Add a regIOobject to registry
585  bool checkIn(regIOobject& io) const;
586 
587  //- Remove a regIOobject from registry and free memory if the
588  //- object is ownedByRegistry. A nullptr is ignored.
589  bool checkOut(regIOobject* io) const;
590 
591  //- Remove a regIOobject from registry and free memory if the
592  //- object is ownedByRegistry.
593  bool checkOut(regIOobject& io) const;
594 
595  //- Remove a regIOobject by name from registry and free memory if the
596  //- object is ownedByRegistry
597  bool checkOut(const word& key) const;
598 
599  //- Clear all entries from the registry
600  // Performs a checkOut() for all objects that are ownedByRegistry
601  void clear();
602 
603  //- Clear all entries from the registry and the table itself.
604  void clearStorage();
605 
606  //- Erase an entry specified by the given iterator.
607  // Performs a checkOut() if the object was ownedByRegistry.
608  // \return True if the entry existed and was removed
609  bool erase(const iterator& iter);
610 
611  //- Erase an entry specified by the given key
612  // Performs a checkOut() if the object was ownedByRegistry.
613  // \return True if the entry existed and was removed
614  bool erase(const word& key);
615 
616  //- Remove entries given by the listed keys
617  // Performs a checkOut() for all objects that are ownedByRegistry.
618  // \return The number of items removed
619  label erase(std::initializer_list<word> keys);
620 
621  //- Remove entries given by the listed keys
622  // Performs a checkOut() for all objects that are ownedByRegistry.
623  // \return The number of items removed
624  label erase(const UList<word>& keys);
625 
626  //- Rename
627  virtual void rename(const word& newName);
628 
629 
630  // Temporaries
631 
632  //FUTURE //- Add given name to the set of temporary objects to cache
633  //FUTURE void addTemporaryObject(const word& name) const;
634 
635  //- True if given name is in the cacheTemporaryObjects set
636  bool is_cacheTemporaryObject(const word& name) const;
637 
638  //- True if name of object is in the cacheTemporaryObjects set
639  bool is_cacheTemporaryObject(const regIOobject* io) const;
640 
641  //- True if name of object is in the cacheTemporaryObjects set
642  bool is_cacheTemporaryObject(const regIOobject& io) const;
643 
644  //- Cache the given object. Moves content and stores
645  template<class Type>
646  bool cacheTemporaryObject(Type& obj) const;
647 
648  //- Reset the cache state of the given object (nullptr is ignored)
649  void resetCacheTemporaryObject(const regIOobject* io) const;
650 
651  //- Reset the cache state of the given object
652  //- in the cacheTemporaryObjects set
653  void resetCacheTemporaryObject(const regIOobject& io) const;
654 
655  //- Check that all objects specified in the cacheTemporaryObjects
656  //- were also cached
657  bool checkCacheTemporaryObjects() const;
658 
659 
660  // Reading
661 
662  //- Return true if any of the object's files have been modified
663  virtual bool modified() const;
664 
665  //- Read the objects that have been modified
666  void readModifiedObjects();
667 
668  //- Read object if modified
669  virtual bool readIfModified();
670 
671 
672  // Writing
673 
674  //- The writeData function is required by regIOobject but not used.
675  // For this class, write is used instead
676  virtual bool writeData(Ostream&) const
677  {
679  return false;
680  }
681 
682  //- Write the objects using stream options
683  virtual bool writeObject
684  (
685  IOstreamOption streamOpt,
686  const bool writeOnProc
687  ) const;
688 
689 
690  // Housekeeping
691 
692  //- Same as contains()
693  bool found(const word& name, bool recursive = false) const
694  {
695  return this->contains(name, recursive);
696  }
697 
698  //- Deprecated(2018-10) find object
699  // \deprecated(2018-10) - use findObject() method
700  template<class Type>
701  FOAM_DEPRECATED_FOR(2018-10, "findObject / cfindObject() methods")
702  const Type* lookupObjectPtr
703  (
704  const word& name,
705  bool recursive = false
706  ) const
707  {
708  return this->cfindObject<Type>(name, recursive);
709  }
710 
711  //- Deprecated(2018-10) get object pointer, ignoring constness
712  // \deprecated(2018-10) - use getObjectPtr() method
713  template<class Type>
714  FOAM_DEPRECATED_FOR(2018-10, "getObjectPtr() method")
715  Type* lookupObjectRefPtr
716  (
717  const word& name,
718  bool recursive = false
719  ) const
720  {
721  return this->getObjectPtr<Type>(name, recursive);
722  }
723 
724  //- Deprecated(2023-07) use csorted() method
725  // \deprecated(2023-07) - use csorted() method
726  template<class Type>
727  FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
728  UPtrList<const Type> sorted() const
729  {
730  return csorted<Type>();
731  }
732 
733  //- Deprecated(2023-07) use csorted() method
734  // \deprecated(2023-07) - use csorted() method
735  FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
736  UPtrList<const regIOobject> sorted() const
737  {
738  return csorted<regIOobject>();
739  }
740 
741  //- Deprecated(2023-07) use csorted() method
742  // \deprecated(2023-07) - use csorted() method
743  template<class Type, class MatchPredicate>
744  FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
745  UPtrList<const Type> sorted(const MatchPredicate& matchName) const
746  {
747  return csorted<Type>(matchName);
748  }
749 };
750 
751 
752 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
753 
754 } // End namespace Foam
755 
756 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
757 
758 #ifdef NoRepository
759  #include "objectRegistryTemplates.C"
760 #endif
761 
762 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
763 
764 #endif
765 
766 // ************************************************************************* //
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.
Definition: fileName.H:72
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.
Definition: IOobjectI.H:195
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...
Definition: regIOobject.C:43
wordList names() const
The unsorted names of all objects.
virtual bool modified() const
Return true if any of the object&#39;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.
Definition: Time.H:69
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
Definition: NamedEnum.H:65
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.
Definition: word.H:63
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.
Definition: IOobject.C:450
virtual bool readIfModified()
Read object if modified.
A HashTable similar to std::unordered_map.
Definition: HashTable.H:108
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...
Definition: HashTable.H:105
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...
Definition: Ostream.H:56
void resetCacheTemporaryObject(const regIOobject *io) const
Reset the cache state of the given object (nullptr is ignored)
const direction noexcept
Definition: Scalar.H:258
bool checkOut()
Remove all file watches and remove object from registry.
Definition: regIOobject.C:221
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.
Definition: fileName.H:59
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
Definition: foamGltfBase.H:103
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...
Definition: regIOobject.H:66
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.
Definition: error.H:686
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
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.
Definition: HashTable.H:1279
bool checkIn()
Add object to registry, if not already registered.
Definition: regIOobject.C:184
const regIOobject * cfindIOobject(const word &name, const bool recursive=false) const
Return const pointer to the regIOobject.
virtual void rename(const word &newName)
Rename.
Namespace for OpenFOAM.
HashTable< wordHashSet > classes() const
A summary hash of classes used and their associated object names.