IOList.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) 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 \*---------------------------------------------------------------------------*/
25 
26 #include "IOList.H"
27 
28 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
29 
30 template<class T>
32 :
33  regIOobject(io)
34 {
35  // Check for MUST_READ_IF_MODIFIED
36  warnNoRereading<IOList<T>>();
37 
38  if
39  (
40  (
41  io.readOpt() == IOobject::MUST_READ
42  || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
43  )
44  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
45  )
46  {
47  readStream(typeName) >> *this;
48  close();
49  }
50 }
51 
52 
53 template<class T>
54 Foam::IOList<T>::IOList(const IOobject& io, const label size)
55 :
56  regIOobject(io)
57 {
58  // Check for MUST_READ_IF_MODIFIED
59  warnNoRereading<IOList<T>>();
60 
61  if
62  (
63  (
64  io.readOpt() == IOobject::MUST_READ
65  || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
66  )
67  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
68  )
69  {
70  readStream(typeName) >> *this;
71  close();
72  }
73  else
74  {
75  List<T>::setSize(size);
76  }
77 }
78 
79 
80 template<class T>
81 Foam::IOList<T>::IOList(const IOobject& io, const List<T>& list)
82 :
83  regIOobject(io)
84 {
85  // Check for MUST_READ_IF_MODIFIED
86  warnNoRereading<IOList<T>>();
87 
88  if
89  (
90  (
91  io.readOpt() == IOobject::MUST_READ
92  || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
93  )
94  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
95  )
96  {
97  readStream(typeName) >> *this;
98  close();
99  }
100  else
101  {
102  List<T>::operator=(list);
103  }
104 }
105 
106 
107 template<class T>
109 :
110  regIOobject(io),
111  List<T>(move(list))
112 {
113  // Check for MUST_READ_IF_MODIFIED
114  warnNoRereading<IOList<T>>();
115 
116  if
117  (
118  (
119  io.readOpt() == IOobject::MUST_READ
120  || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
121  )
122  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
123  )
124  {
125  readStream(typeName) >> *this;
126  close();
127  }
128 }
129 
130 
131 template<class T>
133 :
134  regIOobject(f),
135  List<T>(f)
136 {}
137 
138 
139 template<class T>
141 :
142  regIOobject(move(f)),
143  List<T>(move(f))
144 {}
145 
146 
147 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
148 
149 template<class T>
151 {}
152 
153 
154 
155 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
156 
157 template<class T>
159 {
160  return (os << *this).good();
161 }
162 
163 
164 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
165 
166 template<class T>
168 {
169  List<T>::operator=(rhs);
170 }
171 
172 
173 template<class T>
175 {
176  List<T>::operator=(move(rhs));
177 }
178 
179 
180 template<class T>
182 {
183  List<T>::operator=(rhs);
184 }
185 
186 
187 template<class T>
189 {
190  List<T>::operator=(move(rhs));
191 }
192 
193 
194 // ************************************************************************* //
virtual ~IOList()
Destructor.
Definition: IOList.C:150
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 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
A List of objects of type <T> with automated input and output.
Definition: IOList.H:50
void operator=(const IOList< T > &)
Definition: IOList.C:167
points setSize(newPointi)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
labelList f(nPoints)
const volScalarField & T
IOList(const IOobject &)
Construct from IOobject.
Definition: IOList.C:31
bool writeData(Ostream &) const
Pure virtual writaData function.
Definition: IOList.C:158
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
readOption readOpt() const
Definition: IOobject.H:345
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92