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