IOobjectList.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-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2022 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::IOobjectList
29 
30 Description
31  List of IOobjects with searching and retrieving facilities.
32  Implemented as a HashTable, so the various sorted methods should
33  be used if traversing in parallel.
34 
35 SourceFiles
36  IOobjectList.C
37  IOobjectListI.H
38  IOobjectListTemplates.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef Foam_IOobjectList_H
43 #define Foam_IOobjectList_H
44 
45 #include "HashPtrTable.H"
46 #include "HashSet.H"
47 #include "IOobject.H"
48 #include "UPtrList.H"
49 #include "wordRes.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class IOobjectList Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class IOobjectList
61 :
62  public HashPtrTable<IOobject>
63 {
64  // Private Member Functions
65 
66  //- Check consistency of names and their order on all processors
67  //- (the input list is assumed to be pre-sorted).
68  //
69  // With syncPar = true, check that object names are identical
70  // (content and order) on all processors. FatalError if not.
71  static void checkNameOrder(const wordList& objectNames, bool syncPar);
72 
73  //- Check consistency of object names/order on all processors
74  //- (the input list is assumed to be pre-sorted).
75  //
76  // With syncPar = true, check that object names are identical
77  // (content and order) on all processors. FatalError if not.
78  static void checkObjectOrder
79  (
80  const UPtrList<const IOobject>& objs,
81  bool syncPar
82  );
83 
84  //- Combine names from all processors and sort
85  static void syncNames(wordList& objNames);
86 
87  //- Templated implementation for classes()
88  template<class MatchPredicate>
89  static HashTable<wordHashSet> classesImpl
90  (
91  const IOobjectList& list,
92  const MatchPredicate& matchName
93  );
94 
95  //- Templated implementation for count()
96  // The number of items with a matching class
97  template<class MatchPredicate1, class MatchPredicate2>
98  static label countImpl
99  (
100  const IOobjectList& list,
101  const MatchPredicate1& matchClass,
102  const MatchPredicate2& matchName
103  );
104 
105  //- Templated implementation for count()
106  template<class Type, class MatchPredicate>
107  static label countTypeImpl
108  (
109  const IOobjectList& list,
110  const MatchPredicate& matchName
111  );
112 
113  //- Templated implementation for names(), sortedNames()
114  template<class MatchPredicate1, class MatchPredicate2>
115  static wordList namesImpl
116  (
117  const IOobjectList& list,
118  const MatchPredicate1& matchClass,
119  const MatchPredicate2& matchName,
120  const bool doSort
121  );
122 
123  //- Templated implementation for names(), sortedNames()
124  template<class Type, class MatchPredicate>
125  static wordList namesTypeImpl
126  (
127  const IOobjectList& list,
128  const MatchPredicate& matchName,
129  const bool doSort
130  );
131 
132  //- Templated implementation for sorted()
133  template<class Type, class MatchPredicate>
134  static UPtrList<const IOobject> objectsTypeImpl
135  (
136  const IOobjectList& list,
137  const MatchPredicate& matchName
138  );
139 
140  //- Templated implementation for lookup()
141  template<class MatchPredicate>
142  static IOobjectList lookupImpl
143  (
144  const IOobjectList& list,
145  const MatchPredicate& matchName
146  );
147 
148  //- Templated implementation for lookupClass()
149  template<class MatchPredicate1, class MatchPredicate2>
150  static IOobjectList lookupClassImpl
151  (
152  const IOobjectList& list,
153  const MatchPredicate1& matchClass,
154  const MatchPredicate2& matchName
155  );
156 
157  //- Templated implementation for lookupClass()
158  template<class Type, class MatchPredicate>
159  static IOobjectList lookupClassTypeImpl
160  (
161  const IOobjectList& list,
162  const MatchPredicate& matchName
163  );
164 
165 
166 public:
167 
168  // Constructors
169 
170  //- Default construct (empty) with default (128) table capacity
171  inline IOobjectList();
172 
173  //- Construct given initial table capacity
174  inline explicit IOobjectList(const label nObjects);
175 
176  //- Copy construct
177  inline IOobjectList(const IOobjectList& list);
178 
179  //- Move construct
180  inline IOobjectList(IOobjectList&& list);
181 
182  //- Construct from registry, instance, io options
183  inline IOobjectList
184  (
185  const objectRegistry& db,
186  const fileName& instance,
187  IOobjectOption ioOpt
188  );
189 
190  //- Construct from registry, instance, local, io options
192  (
193  const objectRegistry& db,
194  const fileName& instance,
195  const fileName& local,
196  IOobjectOption ioOpt
197  );
198 
199  //- Construct from registry, instance, registration option
200  //- with MUST_READ, NO_WRITE
201  inline IOobjectList
202  (
203  const objectRegistry& db,
204  const fileName& instance,
206  );
207 
208  //- Construct from registry, instance, local, registration option
209  //- with MUST_READ, NO_WRITE
210  inline IOobjectList
211  (
212  const objectRegistry& db,
213  const fileName& instance,
214  const fileName& local,
216  );
217 
218 
219  //- Destructor
220  ~IOobjectList() = default;
221 
222 
223  // Member Functions
224 
225  // Basic methods
226 
227  //- Move insert IOobject into the list
228  inline bool add(autoPtr<IOobject>& objectPtr);
229 
230  //- Move insert IOobject into the list
231  inline bool add(autoPtr<IOobject>&& objectPtr);
232 
233  //- Remove object from the list, by name or by iterator.
234  //
235  // \return autoPtr<IOobject>
237 
238  //- Remove object from the list by its IOobject::name().
239  //
240  // \return autoPtr<IOobject>
241  autoPtr<IOobject> remove(const IOobject& io)
242  {
243  return remove(io.name());
244  }
245 
246 
247  // Lookup single item
248 
249  //- Return const pointer to the object found by name
250  // \return IOobject ptr if found else nullptr
251  const IOobject* cfindObject(const word& objName) const;
252 
253  //- Return const pointer to the object found by name that also
254  //- has headerClassName == Type::typeName
255  // \return IOobject ptr if found and the correct type, else nullptr
256  //
257  // \note If \a Type is \c void, no headerClassName check is used
258  // (always true).
259  template<class Type>
260  const IOobject* cfindObject(const word& objName) const;
261 
262  //- Return const pointer to the object found by name
263  // \return IOobject ptr if found else nullptr
264  const IOobject* findObject(const word& objName) const;
265 
266  //- Return const pointer to the object found by name that also
267  //- has headerClassName == Type::typeName
268  // \return IOobject ptr if found and the correct type, else nullptr
269  //
270  // \note If \a Type is \c void, no headerClassName check is used
271  // (always true).
272  template<class Type>
273  const IOobject* findObject(const word& objName) const;
274 
275  //- Return non-const pointer to the object found by name
276  // \return IOobject ptr if found else nullptr
277  IOobject* findObject(const word& objName);
278 
279  //- Return non-const pointer to the object found by name that also
280  //- has headerClassName == Type::typeName
281  // \return IOobject ptr if found and the correct type, else nullptr
282  //
283  // \note If \a Type is \c void, no headerClassName check is used
284  // (always true).
285  template<class Type>
286  IOobject* findObject(const word& objName);
287 
288  //- Return non-const pointer to the object found by name,
289  //- using a const-cast to have it behave like a mutable.
290  // Exercise caution when using.
291  // \return IOobject ptr if found else nullptr
292  IOobject* getObject(const word& objName) const;
293 
294  //- Return non-const pointer to the object found by name that also
295  //- has headerClassName == Type::typeName,
296  //- using a const-cast to have it behave like a mutable.
297  // Exercise caution when using.
298  // \return IOobject ptr if found and the correct type, else nullptr
299  //
300  // \note If \a Type is \c void, no headerClassName check is used
301  // (always true).
302  template<class Type>
303  IOobject* getObject(const word& objName) const;
304 
305 
306  // Lookup multiple items
307 
308  //- The list of IOobjects that have a matching object name.
309  template<class MatchPredicate>
310  IOobjectList lookup(const MatchPredicate& matchName) const;
311 
312  //- The list of IOobjects with the given headerClassName
313  IOobjectList lookupClass(const char* clsName) const;
314 
315  //- The list of IOobjects with matching headerClassName
316  template<class MatchPredicate>
317  IOobjectList lookupClass(const MatchPredicate& matchClass) const;
318 
319  //- The list of IOobjects with matching headerClassName
320  //- that also have a matching object name.
321  template<class MatchPredicate1, class MatchPredicate2>
323  (
324  const MatchPredicate1& matchClass,
325  const MatchPredicate2& matchName
326  ) const;
327 
328  //- The list of IOobjects with headerClassName == Type::typeName
329  //
330  // \note If \a Type is \c void, no headerClassName check is used
331  // (always true).
332  template<class Type>
333  IOobjectList lookupClass() const;
334 
335  //- The list of IOobjects with headerClassName == Type::typeName
336  //- that also have a matching object name.
337  template<class Type, class MatchPredicate>
338  IOobjectList lookupClass(const MatchPredicate& matchName) const;
339 
340 
341  // Summary of classes
342 
343  //- A summary hash of classes used and their associated object names.
344  // The HashTable representation allows us to leverage various
345  // HashTable methods.
346  // This hashed summary view can be useful when querying particular
347  // aspects. For example,
348  //
349  // \code
350  // IOobjectList objects(runTime, runTime.timeName());
351  // HashTable<wordHashSet> classes = objects.classes();
352  //
353  // // How many volScalarField?
354  // word checkType = volScalarField::typeName;
355  //
356  // Info<< checkType << "="
357  // << (classes.contains(checkType) ? classes[checkType].size() : 0)
358  // << nl;
359  // \endcode
360  // Using the two-parameter HashTable::lookup method lets us avoid
361  // the \c '?' ternary, but still looks fairly ugly:
362  // \code
363  // Info<< checkType << "="
364  // << classes.lookup(checkType, wordHashSet()).size() << nl;
365  // \endcode
366  //
367  // If we have non-const access to the hash table, and don't mind
368  // incidentally creating empty entries,
369  // we can use the HashTable::operator() directly:
370  // \code
371  // Info<< checkType << "=" << classes(checkType).size() << nl;
372  // \endcode
373  //
374  // Of course, for a single query it would have been easier
375  // and simpler to have used a direct query of the names:
376  // \code
377  // Info<< checkType << "=" << objects.names(checkType).size() << nl;
378  // \endcode
379  //
380  // The summary hash, however, becomes most useful when reducing
381  // the objects in consideration to a particular subset. For example,
382  // \code
383  // const wordHashSet interestingTypes
384  // {
385  // volScalarField::typeName,
386  // volVectorField::typeName
387  // };
388  //
389  // classes.retain(interestingTypes);
390  // \endcode
391  // Or do just the opposite:
392  // \code
393  // classes.erase(unsupportedTypes);
394  // \endcode
395  // This also works with a hashedWordList, since it provides the
396  // expected '()' operator. But in this case the more general
397  // HashTable::filterKeys is required:
398  // \code
399  // const hashedWordList interestingTypes
400  // {
401  // volScalarField::typeName,
402  // volVectorField::typeName
403  // };
404  //
405  // classes.filterKeys(interestingTypes);
406  // \endcode
407  //
408  // Of course, there are many other ways to use and manipulate the
409  // summary information.
410  //
411  // \return HashTable of class-names for keys and wordHashSet of
412  // of object-names for the values.
414 
415  //- A summary hash of classes used and their associated object names,
416  //- restricted to objects that have a matching object name.
417  template<class MatchPredicate>
418  HashTable<wordHashSet> classes(const MatchPredicate& matchName) const;
419 
420 
421  // Sorted access
422 
423  //- The sorted list of IOobjects
424  // The lifetime of the returned content cannot exceed the parent!
426 
427  //- The sorted list of IOobjects with optional check for
428  //- parallel consistency.
429  // FatalError if syncPar = true and names are not consistent on all
430  // processors.
431  // The lifetime of the returned content cannot exceed the parent!
432  UPtrList<const IOobject> sorted(const bool syncPar) const;
433 
434  //- The sorted list of IOobjects with headerClassName == Type::typeName
435  //
436  // \note If \a Type is \c void, no headerClassName check is used
437  // (always true).
438  // The lifetime of the returned content cannot exceed the parent!
439  template<class Type>
441 
442  //- The sorted names of the IOobjects with optional check for
443  //- parallel consistency.
444  // FatalError if syncPar = true and names are not consistent on all
445  // processors.
446  // The lifetime of the returned content cannot exceed the parent!
447  template<class Type>
448  UPtrList<const IOobject> sorted(const bool syncPar) const;
449 
450  //- The sorted list of IOobjects with headerClassName == Type::typeName
451  //- that also have a matching object name.
452  // The lifetime of the returned content cannot exceed the parent!
453  template<class Type, class MatchPredicate>
454  UPtrList<const IOobject> sorted(const MatchPredicate& matchName) const;
455 
456  //- The sorted list of IOobjects with headerClassName == Type::typeName
457  //- that also have a matching object name.
458  // FatalError if syncPar = true and names are not consistent on all
459  // processors.
460  // The lifetime of the returned content cannot exceed the parent!
461  template<class Type, class MatchPredicate>
463  (
464  const MatchPredicate& matchName,
465  const bool syncPar
466  ) const;
467 
468 
469  // Number of items
470 
471  //- The number of objects of the given headerClassName
472  // \note uses the class type() method
473  label count(const char* clsName) const;
474 
475  //- The number of objects of the given headerClassName
476  template<class MatchPredicate>
477  label count
478  (
479  const MatchPredicate& matchClass
480  ) const;
481 
482  //- The number of objects of the given headerClassName
483  //- that also have a matching object name.
484  template<class MatchPredicate1, class MatchPredicate2>
485  label count
486  (
487  const MatchPredicate1& matchClass,
488  const MatchPredicate2& matchName
489  ) const;
490 
491  //- The number of objects with headerClassName == Type::typeName
492  template<class Type>
493  label count() const;
494 
495  //- The number of objects with headerClassName == Type::typeName
496  //- that also have a matching object name.
497  //
498  // \note If \a Type is \c void, no headerClassName check is used
499  // (always true).
500  template<class Type, class MatchPredicate>
501  label count(const MatchPredicate& matchName) const;
502 
503 
504  // Summary of names
505 
506  //- The unsorted names of the IOobjects
507  wordList names() const;
508 
509  //- The sorted names of the IOobjects with optional check for
510  //- parallel consistency.
511  // FatalError if syncPar = true and names are not consistent on all
512  // processors.
513  // \note Output is always sorted - for consistent serial/parallel
514  // behaviour.
515  wordList names(const bool syncPar) const;
516 
517  //- The unsorted names of IOobjects with the given headerClassName
518  wordList names(const char* clsName) const;
519 
520  //- The sorted names of the IOobjects with the given headerClassName
521  // FatalError if syncPar = true and names are not consistent on all
522  // processors.
523  // \note Output is always sorted - for consistent serial/parallel
524  // behaviour.
525  wordList names(const char* clsName, const bool syncPar) const;
526 
527  //- The unsorted names of IOobjects with the given headerClassName
528  template<class MatchPredicate>
529  wordList names(const MatchPredicate& matchClass) const;
530 
531  //- The sorted names of the IOobjects with the given headerClassName
532  // FatalError if syncPar = true and names are not consistent on all
533  // processors.
534  // \note Output is always sorted - for consistent serial/parallel
535  // behaviour.
536  template<class MatchPredicate>
538  (
539  const MatchPredicate& matchClass,
540  const bool syncPar
541  ) const;
542 
543  //- The unsorted names of IOobjects with the given headerClassName
544  //- that also have a matching object name.
545  template<class MatchPredicate1, class MatchPredicate2>
547  (
548  const MatchPredicate1& matchClass,
549  const MatchPredicate2& matchName
550  ) const;
551 
552  //- The sorted names of the IOobjects with the given headerClassName
553  //- that also have a matching object name.
554  // FatalError if syncPar = true and names are not consistent on all
555  // processors.
556  // \note Output is always sorted - for consistent serial/parallel
557  // behaviour.
558  template<class MatchPredicate1, class MatchPredicate2>
560  (
561  const MatchPredicate1& matchClass,
562  const MatchPredicate2& matchName,
563  const bool syncPar
564  ) const;
565 
566 
567  //- The unsorted names of objects with
568  //- headerClassName == Type::typeName
569  template<class Type>
570  wordList names() const;
571 
572  //- The sorted names of objects with
573  //- headerClassName == Type::typeName.
574  // FatalError if syncPar = true and names are not consistent on all
575  // processors.
576  // \note Output is always sorted - for consistent serial/parallel
577  // behaviour.
578  template<class Type>
579  wordList names(bool syncPar) const;
580 
581  //- The unsorted names of objects with
582  //- headerClassName == Type::typeName and a matching object name.
583  template<class Type, class MatchPredicate>
584  wordList names(const MatchPredicate& matchName) const;
585 
586  //- The sorted names of objects with
587  //- headerClassName == Type::typeName and a matching object name.
588  // FatalError if syncPar = true and names are not consistent on all
589  // processors.
590  // \note Output is always sorted - for consistent serial/parallel
591  // behaviour.
592  template<class Type, class MatchPredicate>
594  (
595  const MatchPredicate& matchName,
596  const bool syncPar
597  ) const;
598 
599 
600  // Summary of names (sorted)
601 
602  //- The sorted names of the IOobjects
603  wordList sortedNames() const;
604 
605  //- The sorted names of the IOobjects with optional check for
606  //- parallel consistency.
607  // FatalError if syncPar = true and names are not consistent on all
608  // processors.
609  wordList sortedNames(const bool syncPar) const;
610 
611  //- The sorted names of IOobjects with the given headerClassName
612  wordList sortedNames(const char* clsName) const;
613 
614  //- The sorted names of the IOobjects with the given headerClassName
615  // FatalError if syncPar = true and names are not consistent on all
616  // processors.
617  wordList sortedNames(const char* clsName, const bool syncPar) const;
618 
619  //- The sorted names of IOobjects with the given headerClassName
620  template<class MatchPredicate>
621  wordList sortedNames(const MatchPredicate& matchClass) const;
622 
623  //- The sorted names of the IOobjects with the given headerClassName
624  // FatalError if syncPar = true and names are not consistent on all
625  // processors.
626  template<class MatchPredicate>
628  (
629  const MatchPredicate& matchClass,
630  const bool syncPar
631  ) const;
632 
633  //- The sorted names of IOobjects with the given headerClassName
634  //- that also have a matching object name.
635  template<class MatchPredicate1, class MatchPredicate2>
637  (
638  const MatchPredicate1& matchClass,
639  const MatchPredicate2& matchName
640  ) const;
641 
642  //- The sorted names of the IOobjects with the given headerClassName
643  //- that also have a matching object name.
644  // FatalError if syncPar = true and names are not consistent on all
645  // processors.
646  template<class MatchPredicate1, class MatchPredicate2>
648  (
649  const MatchPredicate1& matchClass,
650  const MatchPredicate2& matchName,
651  const bool syncPar
652  ) const;
653 
654 
655  //- The sorted names of objects with headerClassName == Type::typeName
656  template<class Type>
657  wordList sortedNames() const;
658 
659  //- The sorted names of objects with headerClassName == Type::typeName
660  // FatalError if syncPar = true and names are not consistent on all
661  // processors.
662  template<class Type>
663  wordList sortedNames(bool syncPar) const;
664 
665  //- The sorted names of objects with headerClassName == Type::typeName
666  //- that also have a matching object name.
667  template<class Type, class MatchPredicate>
668  wordList sortedNames(const MatchPredicate& matchName) const;
669 
670  //- The sorted names of objects with headerClassName == Type::typeName
671  //- that also have a matching object name.
672  // FatalError if syncPar = true and names are not consistent on all
673  // processors.
674  template<class Type, class MatchPredicate>
676  (
677  const MatchPredicate& matchName,
678  const bool syncPar
679  ) const;
680 
681 
682  // Edit
683 
684  //- Filter to retain or prune given classes
685  // \return The number of items changed (removed)
686  template<class UnaryPredicate>
687  label filterClasses
688  (
689  const UnaryPredicate& pred,
690  const bool pruning = false
691  );
692 
693  //- Filter to retain or prune given object names
694  // \return The number of items changed (removed)
695  template<class UnaryPredicate>
696  label filterObjects
697  (
698  const UnaryPredicate& pred,
699  const bool pruning = false
700  );
701 
702  //- Remove objects with names ending with "_0" (restart fields)
703  // \return The number of items changed (removed)
704  label prune_0();
705 
706 
707  // Parallel
708 
709  //- The sorted names of all objects (synchronised across processors)
710  wordList allNames() const;
711 
712  //- The sorted names of all objects (synchronised across processors)
713  //- with headerClassName == Type::typeName
714  template<class Type>
715  wordList allNames() const;
716 
717  //- Verify that object names are synchronised across processors
718  // FatalError if the names are not consistent on all processors.
719  void checkNames(const bool syncPar = true) const;
720 
721 
722  // Member Operators
723 
724  //- No copy assignment
725  void operator=(const IOobjectList&) = delete;
726 
727  //- Move assignment
728  inline void operator=(IOobjectList&& list);
729 
730 
731  // Housekeeping
732 
733  //- Construct from registry, instance, local, io options
734  // \deprecated(2022-11) prefer IOobjectOption or registerOption
736  (
737  const objectRegistry& db,
738  const fileName& instance,
739  const fileName& local,
742  bool registerObject = true
743  )
744  :
746  (
747  db,
748  instance,
749  local,
750  IOobjectOption(rOpt, wOpt, registerObject)
751  )
752  {}
753 
754  //- Deprecated(2018-11) Locate an object by name (c-string).
755  //- Disambiguated from multiple-lookup version by calling parameter.
756  // \deprecated(2018-11) use findObject() for non-ambiguous resolution
757  IOobject* lookup(const char* objName) const
758  {
759  return getObject(objName);
760  }
761 
762  //- Deprecated(2018-11) Locate an object by name (const word&).
763  //- Disambiguated from multiple-lookup version by calling parameter.
764  // \deprecated(2018-11) use findObject() for non-ambiguous resolution
765  IOobject* lookup(const word& objName) const
766  {
767  return getObject(objName);
768  }
769 };
770 
771 
772 // Ostream operator
773 Ostream& operator<<(Ostream& os, const IOobjectList& list);
774 
775 
776 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
777 
778 } // End namespace Foam
779 
780 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
781 
782 #include "IOobjectListI.H"
783 
784 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
785 
786 #ifdef NoRepository
787  #include "IOobjectListTemplates.C"
788 #endif
789 
790 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
791 
792 #endif
793 
794 // ************************************************************************* //
IOobjectList()
Default construct (empty) with default (128) table capacity.
Definition: IOobjectListI.H:23
label filterClasses(const UnaryPredicate &pred, const bool pruning=false)
Filter to retain or prune given classes.
writeOption
Enumeration defining write preferences.
label prune_0()
Remove objects with names ending with "_0" (restart fields)
Definition: IOobjectList.C:305
A class for handling file names.
Definition: fileName.H:71
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
UPtrList< const IOobject > sorted() const
The sorted list of IOobjects.
Definition: IOobjectList.C:223
IOobjectList lookupClass() const
The list of IOobjects with headerClassName == Type::typeName.
bool add(autoPtr< IOobject > &objectPtr)
Move insert IOobject into the list.
wordList sortedNames() const
The sorted names of the IOobjects.
Definition: IOobjectList.C:270
wordList names() const
The unsorted names of the IOobjects.
Definition: IOobjectList.C:238
IOobjectList lookup(const MatchPredicate &matchName) const
The list of IOobjects that have a matching object name.
Ignore writing from objectRegistry::writeObject()
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers...
Definition: HashPtrTable.H:51
A class for handling words, derived from Foam::string.
Definition: word.H:63
const IOobject * findObject(const word &objName) const
Return const pointer to the object found by name.
Definition: IOobjectList.C:180
bool local
Definition: EEqn.H:20
wordList allNames() const
The sorted names of all objects (synchronised across processors)
Definition: IOobjectList.C:316
A HashTable similar to std::unordered_map.
Definition: HashTable.H:102
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:100
OBJstream os(runTime.globalPath()/outputName)
~IOobjectList()=default
Destructor.
IOobject * getObject(const word &objName) const
Return non-const pointer to the object found by name, using a const-cast to have it behave like a mut...
Definition: IOobjectList.C:194
registerOption
Enumeration for use with registerObject(). Values map to bool (false/true)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:76
void checkNames(const bool syncPar=true) const
Verify that object names are synchronised across processors.
Definition: IOobjectList.C:325
label count() const
The number of objects with headerClassName == Type::typeName.
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
void operator=(const IOobjectList &)=delete
No copy assignment.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
label filterObjects(const UnaryPredicate &pred, const bool pruning=false)
Filter to retain or prune given object names.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Registry of regIOobjects.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:171
Request registration (bool: true)
Namespace for OpenFOAM.
HashTable< wordHashSet > classes() const
A summary hash of classes used and their associated object names.
Definition: IOobjectList.C:207
const IOobject * cfindObject(const word &objName) const
Return const pointer to the object found by name.
Definition: IOobjectList.C:150
readOption
Enumeration defining read preferences.