GlobalIOList.C
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) 2015-2022 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 \*---------------------------------------------------------------------------*/
25 
26 #include "GlobalIOList.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template
31 <
32  template<class> class Container,
33  template<class> class IOContainer,
34  class Type
35 >
37 (
38  const IOobject& io
39 )
40 :
41  regIOobject(io)
42 {
43  // Check for MUST_READ_IF_MODIFIED
44  warnNoRereading<IOContainer<Type>>();
45 
46  readHeaderOk(IOstream::BINARY, IOContainer<Type>::typeName);
47 }
48 
49 
50 template
51 <
52  template<class> class Container,
53  template<class> class IOContainer,
54  class Type
55 >
57 (
58  const IOobject& io,
59  const label size
60 )
61 :
62  regIOobject(io)
63 {
64  // Check for MUST_READ_IF_MODIFIED
65  warnNoRereading<IOContainer<Type>>();
66 
67  if (!readHeaderOk(IOstream::BINARY, IOContainer<Type>::typeName))
68  {
70  }
71 }
72 
73 
74 template
75 <
76  template<class> class Container,
77  template<class> class IOContainer,
78  class Type
79 >
81 (
82  const IOobject& io,
83  const Container<Type>& f
84 )
85 :
86  regIOobject(io)
87 {
88  // Check for MUST_READ_IF_MODIFIED
89  warnNoRereading<IOContainer<Type>>();
90 
91  if (!readHeaderOk(IOstream::BINARY, IOContainer<Type>::typeName))
92  {
93  Container<Type>::operator=(f);
94  }
95 }
96 
97 
98 template
99 <
100  template<class> class Container,
101  template<class> class IOContainer,
102  class Type
103 >
105 (
106  const IOobject& io,
107  Container<Type>&& f
108 )
109 :
110  regIOobject(io),
111  Container<Type>(move(f))
112 
113 {
114  // Check for MUST_READ_IF_MODIFIED
115  warnNoRereading<IOContainer<Type>>();
116 
117  readHeaderOk(IOstream::BINARY, IOContainer<Type>::typeName);
118 }
119 
120 
121 template
122 <
123  template<class> class Container,
124  template<class> class IOContainer,
125  class Type
126 >
128 (
130 )
131 :
132  regIOobject(field),
133  Container<Type>(field)
134 {}
135 
136 
137 template
138 <
139  template<class> class Container,
140  template<class> class IOContainer,
141  class Type
142 >
144 (
146 )
147 :
148  regIOobject(move(field)),
149  Container<Type>(move(field))
150 {}
151 
152 
153 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
154 
155 template
156 <
157  template<class> class Container,
158  template<class> class IOContainer,
159  class Type
160 >
162 {}
163 
164 
165 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
166 
167 template
168 <
169  template<class> class Container,
170  template<class> class IOContainer,
171  class Type
172 >
174 (
175  Istream& is
176 )
177 {
178  is >> *this;
179  return is.good();
180 }
181 
182 
183 template
184 <
185  template<class> class Container,
186  template<class> class IOContainer,
187  class Type
188 >
190 (
191  Ostream& os
192 ) const
193 {
194  return (os << *this).good();
195 }
196 
197 
198 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
199 
200 template
201 <
202  template<class> class Container,
203  template<class> class IOContainer,
204  class Type
205 >
207 (
209 )
210 {
211  Container<Type>::operator=(rhs);
212 }
213 
214 
215 template
216 <
217  template<class> class Container,
218  template<class> class IOContainer,
219  class Type
220 >
222 (
224 )
225 {
226  Container<Type>::operator=(move(rhs));
227 }
228 
229 
230 // ************************************************************************* //
virtual ~GlobalIOListBase()
Destructor.
Definition: GlobalIOList.C:161
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
Definition: GlobalIOList.C:190
GlobalIOListBase(const IOobject &)
Construct from IOobject.
Definition: GlobalIOList.C:37
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
Definition: GlobalIOList.C:174
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:330
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
bool readHeaderOk(const IOstream::streamFormat defaultFormat, const word &typeName)
Read header, check readOpt flags and read data if necessary.
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
points setSize(newPointi)
labelList f(nPoints)