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-2018 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  // Private Member Functions
56 
57  //- Disallow default bitwise assignment
58  void operator=(const IOobjectList&);
59 
60 
61 public:
62 
63  // Constructors
64 
65  //- Construct given an initial estimate for the number of entries
66  explicit IOobjectList(const label nIoObjects = 128);
67 
68  //- Construct from objectRegistry and instance path
70  (
71  const objectRegistry& db,
72  const fileName& instance,
73  const fileName& local = "",
76  bool registerObject = true
77  );
78 
79  //- Construct as copy
80  IOobjectList(const IOobjectList&);
81 
82 
83  //- Destructor
84  ~IOobjectList();
85 
86 
87  // Member functions
88 
89  //- Add an IOobject to the list
90  bool add(IOobject&);
91 
92  //- Remove an IOobject from the list
93  bool remove(IOobject&);
94 
95  //- Lookup a given name and return IOobject ptr if found else nullptr
96  IOobject* lookup(const word& name) const;
97 
98  //- Return the list for all IOobects whose name matches name
99  IOobjectList lookup(const wordRe& name) const;
100 
101  //- Return the list for all IOobects whose name matches name
102  IOobjectList lookup(const wordReList& patterns) const;
103 
104  //- Return the list for all IOobjects of a given class
105  IOobjectList lookupClass(const word& className) const;
106 
107  //- Return the list of names of the IOobjects
108  wordList names() const;
109 
110  //- Return the sorted list of names of the IOobjects
111  wordList sortedNames() const;
112 
113  //- Return the list of names of the IOobjects of given class
114  wordList names(const word& className) const;
115 
116  //- Return the sorted list of names of the IOobjects of given class
117  wordList sortedNames(const word& className) const;
118 };
119 
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 } // End namespace Foam
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 #endif
128 
129 // ************************************************************************* //
writeOption
Enumeration defining the write options.
Definition: IOobject.H:116
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
A class for handling file names.
Definition: fileName.H:69
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
wordList sortedNames() const
Return the sorted list of names of the IOobjects.
Definition: IOobjectList.C:219
wordList names() const
Return the list of names of the IOobjects.
Definition: IOobjectList.C:213
A HashTable specialization for hashing pointers.
Definition: HashPtrTable.H:50
readOption
Enumeration defining the read options.
Definition: IOobject.H:107
bool add(IOobject &)
Add an IOobject to the list.
Definition: IOobjectList.C:101
A class for handling words, derived from string.
Definition: word.H:59
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:74
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
IOobjectList lookupClass(const word &className) const
Return the list for all IOobjects of a given class.
Definition: IOobjectList.C:192
~IOobjectList()
Destructor.
Definition: IOobjectList.C:95
Registry of regIOobjects.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
IOobjectList(const label nIoObjects=128)
Construct given an initial estimate for the number of entries.
Definition: IOobjectList.C:33
Namespace for OpenFOAM.
IOobject * lookup(const word &name) const
Lookup a given name and return IOobject ptr if found else nullptr.
Definition: IOobjectList.C:123