OpenFOAM
v2406
The open source CFD toolbox
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-2024 OpenCFD Ltd.
10
-------------------------------------------------------------------------------
11
License
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
33
template
<
class
T>
34
bool
Foam::IOList<T>::readIOcontents
()
35
{
36
if
(isReadRequired() || (isReadOptional() && headerOk()))
37
{
38
readStream(typeName) >> *
this
;
39
close();
40
return
true
;
41
}
42
43
return
false
;
44
}
45
46
47
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
48
49
template
<
class
T>
50
Foam::IOList<T>::IOList
(
const
IOobject
&
io
)
51
:
52
regIOobject
(
io
)
53
{
54
// Check for MUST_READ_IF_MODIFIED
55
warnNoRereading<IOList<T>>();
56
57
readIOcontents();
58
}
59
60
61
template
<
class
T>
62
Foam::IOList<T>::IOList
(
const
IOobject
&
io
,
Foam::zero
)
63
:
64
regIOobject
(
io
)
65
{
66
// Check for MUST_READ_IF_MODIFIED
67
warnNoRereading<IOList<T>>();
68
69
readIOcontents();
70
}
71
72
73
template
<
class
T>
74
Foam::IOList<T>::IOList
(
const
IOobject
&
io
,
const
label len)
75
:
76
regIOobject
(
io
)
77
{
78
// Check for MUST_READ_IF_MODIFIED
79
warnNoRereading<IOList<T>>();
80
81
if
(!readIOcontents())
82
{
83
List<T>::resize
(len);
84
}
85
}
86
87
88
template
<
class
T>
89
Foam::IOList<T>::IOList
(
const
IOobject&
io
,
const
UList<T>& content)
90
:
91
regIOobject(
io
)
92
{
93
// Check for MUST_READ_IF_MODIFIED
94
warnNoRereading<IOList<T>>();
95
96
if
(!readIOcontents())
97
{
98
List<T>::operator=
(content);
99
}
100
}
101
102
103
template
<
class
T>
104
Foam::IOList<T>::IOList
(
const
IOobject&
io
, List<T>&& content)
105
:
106
regIOobject(
io
)
107
{
108
// Check for MUST_READ_IF_MODIFIED
109
warnNoRereading<IOList<T>>();
110
111
List<T>::transfer(content);
112
113
readIOcontents();
114
}
115
116
117
template
<
class
T>
118
Foam::IOListRef<T>::IOListRef
119
(
120
const
IOobject
&
io
,
121
const
List<T>
& content
122
)
123
:
124
regIOobject
(
io
),
125
contentRef_(content)
126
{}
127
128
129
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
130
131
template
<
class
T>
132
Foam::List<T>
Foam::IOList<T>::readContents
(
const
IOobject
&
io
)
133
{
134
IOobject
rio(
io
, IOobjectOption::NO_REGISTER);
135
if
(rio.readOpt() == IOobjectOption::READ_MODIFIED)
136
{
137
rio.readOpt(IOobjectOption::MUST_READ);
138
}
139
140
IOList<T> reader(rio);
141
142
return
List<T>
(std::move(
static_cast<
List<T>
&
>
(reader)));
143
}
144
145
146
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
147
148
template
<
class
T>
149
bool
Foam::IOList<T>::writeData
(
Ostream
&
os
)
const
150
{
151
os << static_cast<const List<T>&>(*this);
152
return
os
.good();
153
}
154
155
156
template
<
class
T>
157
bool
Foam::IOListRef<T>::writeData
(
Ostream
&
os
)
const
158
{
159
os
<< contentRef_.cref();
160
return
os
.good();
161
}
162
163
164
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
165
166
template
<
class
T>
167
void
Foam::IOList<T>::operator=
(
const
IOList<T>
& rhs)
168
{
169
List<T>::operator=
(rhs);
170
}
171
172
173
// ************************************************************************* //
IOList.H
resize
patchWriters resize(patchIds.size())
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition:
BitOps.H:56
Foam::IOListRef::writeData
virtual bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition:
IOList.C:150
Foam::IOList
A List of objects of type <T> with automated input and output.
Definition:
IOList.H:49
Foam::IOList::readContents
static List< T > readContents(const IOobject &io)
Read and return contents. The IOobject is never registered.
Definition:
IOList.C:125
Foam::IOListRef::IOListRef
IOListRef()=delete
No default construct.
Foam::IOList::operator=
void operator=(const IOList< T > &rhs)
Copy assignment of entries.
Definition:
IOList.C:160
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition:
Ostream.H:56
Foam::IOList::writeData
virtual bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition:
IOList.C:142
Foam::IOList::IOList
IOList(const IOList &)=default
Default copy construct.
os
OBJstream os(runTime.globalPath()/outputName)
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition:
regIOobject.H:68
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition:
zero.H:57
io
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition:
IOobject.H:180
src
OpenFOAM
db
IOobjects
IOList
IOList.C
Generated by
1.8.14