IOobjectList.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::IOobjectList
26 
27 Description
28  List of IOobjects with searching and retrieving facilities.
29 
30 SourceFiles
31  IOobjectList.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef IOobjectList_H
36 #define IOobjectList_H
37 
38 #include "HashPtrTable.H"
39 #include "IOobject.H"
40 #include "wordReList.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class IOobjectList Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class IOobjectList
52 :
53  public HashPtrTable<IOobject>
54 {
55 
56 public:
57 
58  // Constructors
59 
60  //- Construct given an initial estimate for the number of entries
61  explicit IOobjectList(const label nIoObjects = 128);
62 
63  //- Construct from objectRegistry and instance path
65  (
66  const objectRegistry& db,
67  const fileName& instance,
68  const fileName& local = "",
71  bool registerObject = true
72  );
73 
74  //- Copy constructor
75  IOobjectList(const IOobjectList&);
76 
77 
78  //- Destructor
79  ~IOobjectList();
80 
81 
82  // Member Functions
83 
84  //- Add an IOobject to the list
85  bool add(IOobject&);
86 
87  //- Remove an IOobject from the list
88  bool remove(IOobject&);
89 
90  //- Lookup a given name and return IOobject ptr if found else nullptr
91  IOobject* lookup(const word& name) const;
92 
93  //- Return the list for all IOobects whose name matches name
94  IOobjectList lookup(const wordRe& name) const;
95 
96  //- Return the list for all IOobects whose name matches name
97  IOobjectList lookup(const wordReList& patterns) const;
98 
99  //- Return the list for all IOobjects of a given class
100  IOobjectList lookupClass(const word& className) const;
101 
102  //- Return the list of names of the IOobjects
103  wordList names() const;
104 
105  //- Return the sorted list of names of the IOobjects
106  wordList sortedNames() const;
107 
108  //- Return the list of names of the IOobjects of given class
109  wordList names(const word& className) const;
110 
111  //- Return the sorted list of names of the IOobjects of given class
112  wordList sortedNames(const word& className) const;
113 
114 
115  // Member Operators
116 
117  //- Disallow default bitwise assignment
118  void operator=(const IOobjectList&) = delete;
119 };
120 
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 } // End namespace Foam
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 #endif
129 
130 // ************************************************************************* //
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:67
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:53
~IOobjectList()
Destructor.
Definition: IOobjectList.C:93
IOobjectList(const label nIoObjects=128)
Construct given an initial estimate for the number of entries.
Definition: IOobjectList.C:32
wordList sortedNames() const
Return the sorted list of names of the IOobjects.
Definition: IOobjectList.C:217
bool add(IOobject &)
Add an IOobject to the list.
Definition: IOobjectList.C:99
void operator=(const IOobjectList &)=delete
Disallow default bitwise assignment.
IOobjectList lookupClass(const word &className) const
Return the list for all IOobjects of a given class.
Definition: IOobjectList.C:190
IOobject * lookup(const word &name) const
Lookup a given name and return IOobject ptr if found else nullptr.
Definition: IOobjectList.C:121
bool remove(IOobject &)
Remove an IOobject from the list.
Definition: IOobjectList.C:105
wordList names() const
Return the list of names of the IOobjects.
Definition: IOobjectList.C:211
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
readOption
Enumeration defining the read options.
Definition: IOobject.H:117
writeOption
Enumeration defining the write options.
Definition: IOobject.H:126
A class for handling file names.
Definition: fileName.H:82
Registry of regIOobjects.
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:77
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39