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-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::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 csorted()/sorted()
133  template<class Type, class MatchPredicate>
134  static UPtrList<const IOobject> objectsTypeImpl
135  (
136  const IOobjectList& list,
137  const MatchPredicate& matchName,
138  const bool doSort
139  );
140 
141  //- Templated implementation for lookup()
142  template<class MatchPredicate>
143  static IOobjectList lookupImpl
144  (
145  const IOobjectList& list,
146  const MatchPredicate& matchName
147  );
148 
149  //- Templated implementation for lookupClass()
150  template<class MatchPredicate1, class MatchPredicate2>
151  static IOobjectList lookupClassImpl
152  (
153  const IOobjectList& list,
154  const MatchPredicate1& matchClass,
155  const MatchPredicate2& matchName
156  );
157 
158  //- Templated implementation for lookupClass()
159  template<class Type, class MatchPredicate>
160  static IOobjectList lookupClassTypeImpl
161  (
162  const IOobjectList& list,
163  const MatchPredicate& matchName
164  );
165 
166 
167 public:
168 
169  // Constructors
170 
171  //- Default construct: empty without allocation (capacity=0).
172  IOobjectList() noexcept = default;
173 
174  //- Construct empty without allocation (capacity=0)
175  inline explicit IOobjectList(const Foam::zero) noexcept;
176 
177  //- Construct empty with initial table capacity
178  inline explicit IOobjectList(const label initialCapacity);
179 
180  //- Copy construct
181  inline IOobjectList(const IOobjectList& list);
182 
183  //- Move construct
184  inline IOobjectList(IOobjectList&& list);
185 
186  //- Construct from registry, instance, io options
187  inline IOobjectList
188  (
189  const objectRegistry& db,
190  const fileName& instance,
191  IOobjectOption ioOpt
192  );
193 
194  //- Construct from registry, instance, local, io options
196  (
197  const objectRegistry& db,
198  const fileName& instance,
199  const fileName& local,
200  IOobjectOption ioOpt
201  );
202 
203  //- Construct from registry, instance, registration option
204  //- with MUST_READ, NO_WRITE
205  inline IOobjectList
206  (
207  const objectRegistry& db,
208  const fileName& instance,
210  );
211 
212  //- Construct from registry, instance, local, registration option
213  //- with MUST_READ, NO_WRITE
214  inline IOobjectList
215  (
216  const objectRegistry& db,
217  const fileName& instance,
218  const fileName& local,
220  );
221 
222 
223  //- Destructor
224  ~IOobjectList() = default;
225 
226 
227  // Member Functions
228 
229  // Basic methods
230 
231  //- Move insert IOobject into the list
232  inline bool add(autoPtr<IOobject>& objectPtr);
233 
234  //- Move insert IOobject into the list
235  inline bool add(autoPtr<IOobject>&& objectPtr);
236 
237  //- Remove object from the list, by name or by iterator.
238  //
239  // \return autoPtr<IOobject>
241 
242  //- Remove object from the list by its IOobject::name().
243  //
244  // \return autoPtr<IOobject>
245  autoPtr<IOobject> remove(const IOobject& io)
246  {
247  return remove(io.name());
248  }
249 
250 
251  // Lookup single item
252 
253  //- Return const pointer to the object found by name
254  // \return IOobject ptr if found else nullptr
255  const IOobject* cfindObject(const word& objName) const;
256 
257  //- Return const pointer to the object found by name that also
258  //- has headerClassName == Type::typeName
259  // \return IOobject ptr if found and the correct type, else nullptr
260  //
261  // \note If \a Type is \c void, no headerClassName check is used
262  // (always true).
263  template<class Type>
264  const IOobject* cfindObject(const word& objName) const;
265 
266  //- Return const pointer to the object found by name
267  // \return IOobject ptr if found else nullptr
268  const IOobject* findObject(const word& objName) const;
269 
270  //- Return const pointer to the object found by name that also
271  //- has headerClassName == Type::typeName
272  // \return IOobject ptr if found and the correct type, else nullptr
273  //
274  // \note If \a Type is \c void, no headerClassName check is used
275  // (always true).
276  template<class Type>
277  const IOobject* findObject(const word& objName) const;
278 
279  //- Return non-const pointer to the object found by name
280  // \return IOobject ptr if found else nullptr
281  IOobject* findObject(const word& objName);
282 
283  //- Return non-const pointer to the object found by name that also
284  //- has headerClassName == Type::typeName
285  // \return IOobject ptr if found and the correct type, else nullptr
286  //
287  // \note If \a Type is \c void, no headerClassName check is used
288  // (always true).
289  template<class Type>
290  IOobject* findObject(const word& objName);
291 
292  //- Return non-const pointer to the object found by name,
293  //- using a const-cast to have it behave like a mutable.
294  // Exercise caution when using.
295  // \return IOobject ptr if found else nullptr
296  IOobject* getObject(const word& objName) const;
298  //- Return non-const pointer to the object found by name that also
299  //- has headerClassName == Type::typeName,
300  //- using a const-cast to have it behave like a mutable.
301  // Exercise caution when using.
302  // \return IOobject ptr if found and the correct type, else nullptr
303  //
304  // \note If \a Type is \c void, no headerClassName check is used
305  // (always true).
306  template<class Type>
307  IOobject* getObject(const word& objName) const;
308 
309 
310  // Lookup multiple items
311 
312  //- The list of IOobjects that have a matching object name.
313  template<class MatchPredicate>
314  IOobjectList lookup(const MatchPredicate& matchName) const;
315 
316  //- The list of IOobjects with the given headerClassName
317  IOobjectList lookupClass(const char* clsName) const;
318 
319  //- The list of IOobjects with matching headerClassName
320  template<class MatchPredicate>
321  IOobjectList lookupClass(const MatchPredicate& matchClass) const;
322 
323  //- The list of IOobjects with matching headerClassName
324  //- that also have a matching object name.
325  template<class MatchPredicate1, class MatchPredicate2>
327  (
328  const MatchPredicate1& matchClass,
329  const MatchPredicate2& matchName
330  ) const;
331 
332  //- The list of IOobjects with headerClassName == Type::typeName
333  //
334  // \note If \a Type is \c void, no headerClassName check is used
335  // (always true).
336  template<class Type>
337  IOobjectList lookupClass() const;
338 
339  //- The list of IOobjects with headerClassName == Type::typeName
340  //- that also have a matching object name.
341  template<class Type, class MatchPredicate>
342  IOobjectList lookupClass(const MatchPredicate& matchName) const;
343 
344 
345  // Summary of classes
346 
347  //- A summary hash of classes used and their associated object names.
348  // The HashTable representation allows us to leverage various
349  // HashTable methods.
350  // This hashed summary view can be useful when querying particular
351  // aspects. For example,
352  //
353  // \code
354  // IOobjectList objects(runTime, runTime.timeName());
355  // HashTable<wordHashSet> classes = objects.classes();
356  //
357  // // How many volScalarField?
358  // word checkType = volScalarField::typeName;
359  //
360  // Info<< checkType << "="
361  // << (classes.contains(checkType) ? classes[checkType].size() : 0)
362  // << nl;
363  // \endcode
364  // Using the two-parameter HashTable::lookup method lets us avoid
365  // the \c '?' ternary, but still looks fairly ugly:
366  // \code
367  // Info<< checkType << "="
368  // << classes.lookup(checkType, wordHashSet()).size() << nl;
369  // \endcode
370  //
371  // If we have non-const access to the hash table, and don't mind
372  // incidentally creating empty entries,
373  // we can use the HashTable::operator() directly:
374  // \code
375  // Info<< checkType << "=" << classes(checkType).size() << nl;
376  // \endcode
377  //
378  // Of course, for a single query it would have been easier
379  // and simpler to have used a direct query of the names:
380  // \code
381  // Info<< checkType << "=" << objects.names(checkType).size() << nl;
382  // \endcode
383  //
384  // The summary hash, however, becomes most useful when reducing
385  // the objects in consideration to a particular subset. For example,
386  // \code
387  // const wordHashSet interestingTypes
388  // {
389  // volScalarField::typeName,
390  // volVectorField::typeName
391  // };
392  //
393  // classes.retain(interestingTypes);
394  // \endcode
395  // Or do just the opposite:
396  // \code
397  // classes.erase(unsupportedTypes);
398  // \endcode
399  // This also works with a hashedWordList, since it provides the
400  // expected '()' operator. But in this case the more general
401  // HashTable::filterKeys is required:
402  // \code
403  // const hashedWordList interestingTypes
404  // {
405  // volScalarField::typeName,
406  // volVectorField::typeName
407  // };
408  //
409  // classes.filterKeys(interestingTypes);
410  // \endcode
411  //
412  // Of course, there are many other ways to use and manipulate the
413  // summary information.
414  //
415  // \return HashTable of class-names for keys and wordHashSet of
416  // of object-names for the values.
418 
419  //- A summary hash of classes used and their associated object names,
420  //- restricted to objects that have a matching object name.
421  template<class MatchPredicate>
422  HashTable<wordHashSet> classes(const MatchPredicate& matchName) const;
423 
424 
425  // List-wise access (unsorted)
426 
427  //- The unsorted list of IOobjects with
428  //- headerClassName == Type::typeName
429  //
430  // \note If \a Type is \c void, no headerClassName check is used
431  // (always true).
432  // The lifetime of the returned content cannot exceed the parent!
433  template<class Type>
435 
436  //- The unsorted list of IOobjects with
437  //- headerClassName == Type::typeName
438  //- that also have a matching object name.
439  // The lifetime of the returned content cannot exceed the parent!
440  template<class Type, class MatchPredicate>
442  (
443  const MatchPredicate& matchName
444  ) const;
445 
446  // List-wise access (sorted)
447 
448  //- The sorted list of IOobjects with
449  //- headerClassName == Type::typeName
450  //
451  // \note If \a Type is \c void, no headerClassName check is used
452  // (always true).
453  // The lifetime of the returned content cannot exceed the parent!
454  template<class Type>
456 
457  //- The sorted names of the IOobjects with optional check for
458  //- parallel consistency.
459  // FatalError if syncPar = true and names are not consistent on all
460  // processors.
461  // The lifetime of the returned content cannot exceed the parent!
462  template<class Type>
463  UPtrList<const IOobject> csorted(const bool syncPar) const;
464 
465  //- The sorted list of IOobjects
466  // The lifetime of the returned content cannot exceed the parent!
468  {
469  return csorted<void>();
470  }
471 
472  //- The sorted list of IOobjects with optional check for
473  //- parallel consistency.
474  // FatalError if syncPar = true and names are not consistent on all
475  // processors.
476  // The lifetime of the returned content cannot exceed the parent!
477  UPtrList<const IOobject> csorted(const bool syncPar) const
478  {
479  return csorted<void>(syncPar);
480  }
481 
482  //- The sorted list of IOobjects with headerClassName == Type::typeName
483  //- that also have a matching object name.
484  // The lifetime of the returned content cannot exceed the parent!
485  template<class Type, class MatchPredicate>
486  UPtrList<const IOobject> csorted(const MatchPredicate& matchName) const;
487 
488  //- The sorted list of IOobjects with headerClassName == Type::typeName
489  //- that also have a matching object name.
490  // FatalError if syncPar = true and names are not consistent on all
491  // processors.
492  // The lifetime of the returned content cannot exceed the parent!
493  template<class Type, class MatchPredicate>
494  UPtrList<const IOobject> csorted
495  (
496  const MatchPredicate& matchName,
497  const bool syncPar
498  ) const;
499 
500 
501  // Number of items
502 
503  //- The number of objects of the given headerClassName
504  // \note uses the class type() method
505  label count(const char* clsName) const;
506 
507  //- The number of objects of the given headerClassName
508  template<class MatchPredicate>
509  label count
510  (
511  const MatchPredicate& matchClass
512  ) const;
513 
514  //- The number of objects of the given headerClassName
515  //- that also have a matching object name.
516  template<class MatchPredicate1, class MatchPredicate2>
517  label count
518  (
519  const MatchPredicate1& matchClass,
520  const MatchPredicate2& matchName
521  ) const;
522 
523  //- The number of objects with headerClassName == Type::typeName
524  template<class Type>
525  label count() const;
526 
527  //- The number of objects with headerClassName == Type::typeName
528  //- that also have a matching object name.
529  //
530  // \note If \a Type is \c void, no headerClassName check is used
531  // (always true).
532  template<class Type, class MatchPredicate>
533  label count(const MatchPredicate& matchName) const;
534 
535 
536  // Summary of names
537 
538  //- The unsorted names of the IOobjects
539  wordList names() const;
540 
541  //- The sorted names of the IOobjects with optional check for
542  //- parallel consistency.
543  // FatalError if syncPar = true and names are not consistent on all
544  // processors.
545  // \note Output is always sorted - for consistent serial/parallel
546  // behaviour.
547  wordList names(const bool syncPar) const;
548 
549  //- The unsorted names of IOobjects with the given headerClassName
550  wordList names(const char* clsName) const;
551 
552  //- The sorted names of the IOobjects with the given headerClassName
553  // FatalError if syncPar = true and names are not consistent on all
554  // processors.
555  // \note Output is always sorted - for consistent serial/parallel
556  // behaviour.
557  wordList names(const char* clsName, const bool syncPar) const;
558 
559  //- The unsorted names of IOobjects with the given headerClassName
560  template<class MatchPredicate>
561  wordList names(const MatchPredicate& matchClass) const;
562 
563  //- The sorted names of the IOobjects with the given headerClassName
564  // FatalError if syncPar = true and names are not consistent on all
565  // processors.
566  // \note Output is always sorted - for consistent serial/parallel
567  // behaviour.
568  template<class MatchPredicate>
570  (
571  const MatchPredicate& matchClass,
572  const bool syncPar
573  ) const;
574 
575  //- The unsorted names of IOobjects with the given headerClassName
576  //- that also have a matching object name.
577  template<class MatchPredicate1, class MatchPredicate2>
579  (
580  const MatchPredicate1& matchClass,
581  const MatchPredicate2& matchName
582  ) const;
583 
584  //- The sorted names of the IOobjects with the given headerClassName
585  //- that also have a matching object name.
586  // FatalError if syncPar = true and names are not consistent on all
587  // processors.
588  // \note Output is always sorted - for consistent serial/parallel
589  // behaviour.
590  template<class MatchPredicate1, class MatchPredicate2>
592  (
593  const MatchPredicate1& matchClass,
594  const MatchPredicate2& matchName,
595  const bool syncPar
596  ) const;
597 
598 
599  //- The unsorted names of objects with
600  //- headerClassName == Type::typeName
601  template<class Type>
602  wordList names() const;
603 
604  //- The sorted names of objects with
605  //- headerClassName == Type::typeName.
606  // FatalError if syncPar = true and names are not consistent on all
607  // processors.
608  // \note Output is always sorted - for consistent serial/parallel
609  // behaviour.
610  template<class Type>
611  wordList names(bool syncPar) const;
612 
613  //- The unsorted names of objects with
614  //- headerClassName == Type::typeName and a matching object name.
615  template<class Type, class MatchPredicate>
616  wordList names(const MatchPredicate& matchName) const;
617 
618  //- The sorted names of objects with
619  //- headerClassName == Type::typeName and a matching object name.
620  // FatalError if syncPar = true and names are not consistent on all
621  // processors.
622  // \note Output is always sorted - for consistent serial/parallel
623  // behaviour.
624  template<class Type, class MatchPredicate>
626  (
627  const MatchPredicate& matchName,
628  const bool syncPar
629  ) const;
630 
631 
632  // Summary of names (sorted)
633 
634  //- The sorted names of the IOobjects
635  wordList sortedNames() const;
636 
637  //- The sorted names of the IOobjects with optional check for
638  //- parallel consistency.
639  // FatalError if syncPar = true and names are not consistent on all
640  // processors.
641  wordList sortedNames(const bool syncPar) const;
642 
643  //- The sorted names of IOobjects with the given headerClassName
644  wordList sortedNames(const char* clsName) const;
645 
646  //- The sorted names of the IOobjects with the given headerClassName
647  // FatalError if syncPar = true and names are not consistent on all
648  // processors.
649  wordList sortedNames(const char* clsName, const bool syncPar) const;
650 
651  //- The sorted names of IOobjects with the given headerClassName
652  template<class MatchPredicate>
653  wordList sortedNames(const MatchPredicate& matchClass) const;
654 
655  //- The sorted names of the IOobjects with the given headerClassName
656  // FatalError if syncPar = true and names are not consistent on all
657  // processors.
658  template<class MatchPredicate>
660  (
661  const MatchPredicate& matchClass,
662  const bool syncPar
663  ) const;
664 
665  //- The sorted names of IOobjects with the given headerClassName
666  //- that also have a matching object name.
667  template<class MatchPredicate1, class MatchPredicate2>
669  (
670  const MatchPredicate1& matchClass,
671  const MatchPredicate2& matchName
672  ) const;
673 
674  //- The sorted names of the IOobjects with the given headerClassName
675  //- that also have a matching object name.
676  // FatalError if syncPar = true and names are not consistent on all
677  // processors.
678  template<class MatchPredicate1, class MatchPredicate2>
680  (
681  const MatchPredicate1& matchClass,
682  const MatchPredicate2& matchName,
683  const bool syncPar
684  ) const;
685 
686 
687  //- The sorted names of objects with headerClassName == Type::typeName
688  template<class Type>
689  wordList sortedNames() const;
690 
691  //- The sorted names of objects with headerClassName == Type::typeName
692  // FatalError if syncPar = true and names are not consistent on all
693  // processors.
694  template<class Type>
695  wordList sortedNames(bool syncPar) const;
696 
697  //- The sorted names of objects with headerClassName == Type::typeName
698  //- that also have a matching object name.
699  template<class Type, class MatchPredicate>
700  wordList sortedNames(const MatchPredicate& matchName) const;
701 
702  //- The sorted names of objects with headerClassName == Type::typeName
703  //- that also have a matching object name.
704  // FatalError if syncPar = true and names are not consistent on all
705  // processors.
706  template<class Type, class MatchPredicate>
708  (
709  const MatchPredicate& matchName,
710  const bool syncPar
711  ) const;
712 
713 
714  // Edit
715 
716  //- Filter to retain or prune given classes
717  // \return The number of items changed (removed)
718  template<class UnaryPredicate>
719  label filterClasses
720  (
721  const UnaryPredicate& pred,
722  const bool pruning = false
723  );
724 
725  //- Filter to retain or prune given object names
726  // \return The number of items changed (removed)
727  template<class UnaryPredicate>
728  label filterObjects
729  (
730  const UnaryPredicate& pred,
731  const bool pruning = false
732  );
733 
734  //- Remove objects with names ending with "_0" (restart fields)
735  // \return The number of items changed (removed)
736  label prune_0();
737 
738 
739  // Parallel
740 
741  //- The sorted names of all objects (synchronised across processors)
742  wordList allNames() const;
743 
744  //- The sorted names of all objects (synchronised across processors)
745  //- with headerClassName == Type::typeName
746  template<class Type>
747  wordList allNames() const;
748 
749  //- Verify that object names are synchronised across processors
750  // FatalError if the names are not consistent on all processors.
751  void checkNames(const bool syncPar = true) const;
752 
753 
754  // Member Operators
755 
756  //- No copy assignment
757  void operator=(const IOobjectList&) = delete;
758 
759  //- Move assignment
760  inline void operator=(IOobjectList&& list);
761 
762 
763  // Housekeeping
764 
765  //- Construct from registry, instance, local, io options
766  // \deprecated(2022-11) prefer IOobjectOption or registerOption
768  (
769  const objectRegistry& db,
770  const fileName& instance,
771  const fileName& local,
774  bool registerObject = true
775  )
776  :
778  (
779  db,
780  instance,
781  local,
782  IOobjectOption(rOpt, wOpt, registerObject)
783  )
784  {}
785 
786  //- Deprecated(2018-11) Locate an object by name (c-string).
787  //- Disambiguated from multiple-lookup version by calling parameter.
788  // \deprecated(2018-11) use findObject() for non-ambiguous resolution
789  IOobject* lookup(const char* objName) const
790  {
791  return getObject(objName);
792  }
793 
794  //- Deprecated(2018-11) Locate an object by name (const word&).
795  //- Disambiguated from multiple-lookup version by calling parameter.
796  // \deprecated(2018-11) use findObject() for non-ambiguous resolution
797  IOobject* lookup(const word& objName) const
798  {
799  return getObject(objName);
800  }
801 
802 
803  //- Deprecated(2023-07) use csorted() method
804  // \deprecated(2023-07) - use csorted() method
805  template<class Type>
806  FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
807  UPtrList<const IOobject> sorted() const
808  {
809  return csorted<Type>();
810  }
811 
812  //- Deprecated(2023-07) use csorted() method
813  // \deprecated(2023-07) - use csorted() method
814  template<class Type>
815  FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
816  UPtrList<const IOobject> sorted(const bool syncPar) const
817  {
818  return csorted<Type>(syncPar);
819  }
820 
821  //- Deprecated(2023-07) use csorted() method
822  // \deprecated(2023-07) - use csorted() method
823  FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
824  UPtrList<const IOobject> sorted() const
825  {
826  return csorted<void>();
827  }
828 
829  //- Deprecated(2023-07) use csorted() method
830  // \deprecated(2023-07) - use csorted() method
831  FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
832  UPtrList<const IOobject> sorted(const bool syncPar) const
833  {
834  return csorted<void>(syncPar);
835  }
836 
837  //- Deprecated(2023-07) use csorted() method
838  // \deprecated(2023-07) - use csorted() method
839  template<class Type, class MatchPredicate>
840  FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
841  UPtrList<const IOobject> sorted(const MatchPredicate& matchName) const
842  {
843  return csorted<Type>(matchName);
844  }
845 
846  //- Deprecated(2023-07) use csorted() method
847  // \deprecated(2023-07) - use csorted() method
848  template<class Type, class MatchPredicate>
849  FOAM_DEPRECATED_FOR(2023-07, "csorted() method")
850  UPtrList<const IOobject> sorted
851  (
852  const MatchPredicate& matchName,
853  const bool syncPar
854  ) const
855  {
856  return csorted<Type>(matchName, syncPar);
857  }
858 };
859 
860 
861 // Ostream Operator
862 Ostream& operator<<(Ostream& os, const IOobjectList& list);
863 
864 
865 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
866 
867 } // End namespace Foam
868 
869 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
870 
871 #include "IOobjectListI.H"
872 
873 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
874 
875 #ifdef NoRepository
876  #include "IOobjectListTemplates.C"
877 #endif
878 
879 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
880 
881 #endif
882 
883 // ************************************************************************* //
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:285
A class for handling file names.
Definition: fileName.H:72
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
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:250
wordList names() const
The unsorted names of the IOobjects.
Definition: IOobjectList.C:218
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
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Definition: NamedEnum.H:65
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:176
bool local
Definition: EEqn.H:20
wordList allNames() const
The sorted names of all objects (synchronised across processors)
Definition: IOobjectList.C:296
A HashTable similar to std::unordered_map.
Definition: HashTable.H:108
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
UPtrList< const IOobject > cobjects() const
The unsorted list of IOobjects with headerClassName == Type::typeName.
const direction noexcept
Definition: Scalar.H:258
UPtrList< const IOobject > sorted() const
Deprecated(2023-07) use csorted() method.
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:190
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:77
List< word > wordList
List of word.
Definition: fileName.H:59
void checkNames(const bool syncPar=true) const
Verify that object names are synchronised across processors.
Definition: IOobjectList.C:305
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.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
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.
IOobjectList() noexcept=default
Default construct: empty without allocation (capacity=0).
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:172
UPtrList< const IOobject > csorted() const
The sorted list of IOobjects with headerClassName == Type::typeName.
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:203
const IOobject * cfindObject(const word &objName) const
Return const pointer to the object found by name.
Definition: IOobjectList.C:146
readOption
Enumeration defining read preferences.