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