IOList.C
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-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
28
29#include "IOList.H"
30
31// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32
33template<class T>
35{
36 if
37 (
38 (
39 readOpt() == IOobject::MUST_READ
40 || readOpt() == IOobject::MUST_READ_IF_MODIFIED
41 )
42 || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
43 )
44 {
45 readStream(typeName) >> *this;
46 close();
47 return true;
48 }
49
50 return false;
51}
52
53
54// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
55
56template<class T>
58:
60{
61 // Check for MUST_READ_IF_MODIFIED
62 warnNoRereading<IOList<T>>();
63
64 readContents();
65}
66
67
68template<class T>
70:
72{
73 // Check for MUST_READ_IF_MODIFIED
74 warnNoRereading<IOList<T>>();
75
76 readContents();
77}
78
80template<class T>
81Foam::IOList<T>::IOList(const IOobject& io, const label len)
84{
85 // Check for MUST_READ_IF_MODIFIED
86 warnNoRereading<IOList<T>>();
87
88 if (!readContents())
89 {
90 List<T>::resize(len);
91 }
92}
93
94
95template<class T>
97:
99{
100 // Check for MUST_READ_IF_MODIFIED
101 warnNoRereading<IOList<T>>();
102
103 if (!readContents())
104 {
105 List<T>::operator=(content);
106 }
108
109
110template<class T>
112:
114{
115 // Check for MUST_READ_IF_MODIFIED
116 warnNoRereading<IOList<T>>();
117
118 List<T>::transfer(content);
119
120 readContents();
121}
122
123
124template<class T>
126(
127 const IOobject& io,
128 const List<T>& content
129)
130:
132 contentRef_(content)
133{}
134
135
136// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
137
138template<class T>
140{
141 os << static_cast<const List<T>&>(*this);
142 return os.good();
143}
144
145
146template<class T>
148{
149 os << contentRef_.cref();
150 return os.good();
151}
152
153
154// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
155
156template<class T>
158{
160}
161
162
163// ************************************************************************* //
virtual bool resize()
Resize the ODE solver.
Definition: Euler.C:53
A IOList wrapper for writing external data.
Definition: IOList.H:123
IOListRef()=delete
No default construct.
A List of objects of type <T> with automated input and output.
Definition: IOList.H:58
void operator=(const IOList< T > &rhs)
Copy assignment of entries.
Definition: IOList.C:157
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:233
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
void operator=(const UList< T > &a)
Assignment to UList operator. Takes linear time.
Definition: List.C:480
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)