OpenFOAM
v2406
The open source CFD toolbox
IOList.H
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) 2018-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
Class
28
Foam::IOList
29
30
Description
31
A List of objects of type <T> with automated input and output.
32
33
SourceFiles
34
IOList.C
35
36
\*---------------------------------------------------------------------------*/
37
38
#ifndef Foam_IOList_H
39
#define Foam_IOList_H
40
41
#include "
List.H
"
42
#include "
regIOobject.H
"
43
44
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46
namespace
Foam
47
{
48
49
/*---------------------------------------------------------------------------*\
50
Class IOList Declaration
51
\*---------------------------------------------------------------------------*/
52
53
template
<
class
T>
54
class
IOList
55
:
56
public
regIOobject
,
57
public
List
<T>
58
{
59
// Private Member Functions
60
61
//- Read if IOobject flags set. Return true if read.
62
bool
readIOcontents();
63
64
public
:
65
66
//- The underlying content type
67
typedef
List<T>
content_type
;
68
69
//- Runtime type information
70
TypeName
(
"List"
);
71
72
73
// Constructors
74
75
//- Default copy construct
76
IOList
(
const
IOList
&) =
default
;
77
78
//- Construct from IOobject
79
explicit
IOList
(
const
IOobject
&
io
);
80
81
//- Construct from IOobject and zero size (if not read)
82
IOList
(
const
IOobject
&
io
,
Foam::zero
);
83
84
//- Construct from IOobject and list size (if not read)
85
IOList
(
const
IOobject
&
io
,
const
label len);
86
87
//- Construct from IOobject and a copy of content
88
IOList
(
const
IOobject
&
io
,
const
UList<T>
& content);
89
90
//- Construct by transferring the content
91
IOList
(
const
IOobject
&
io
,
List<T>
&& content);
92
93
94
// Factory Methods
95
96
//- Read and return contents. The IOobject is never registered
97
static
List<T>
readContents
(
const
IOobject
&
io
);
98
99
100
//- Destructor
101
virtual
~IOList
() =
default
;
102
103
104
// Member Functions
105
106
//- The writeData method for regIOobject write operation
107
virtual
bool
writeData
(
Ostream
&
os
)
const
;
108
109
110
// Member Operators
111
112
//- Copy assignment of entries
113
void
operator=
(
const
IOList<T>
& rhs);
114
115
//- Copy or move assignment of entries
116
using
List<T>::operator
=;
117
};
118
119
120
/*---------------------------------------------------------------------------*\
121
Class IOListRef Declaration
122
\*---------------------------------------------------------------------------*/
123
124
//- A IOList wrapper for writing external data.
125
template
<
class
T>
126
class
IOListRef
127
:
128
public
regIOobject
129
{
130
// Private Data
131
132
//- Reference to the external content
133
refPtr<List<T>
> contentRef_;
134
135
136
public
:
137
138
//- The underlying content type
139
typedef
List<T>
content_type
;
140
141
142
//- Type is identical to IOList
143
virtual
const
word
&
type
()
const
144
{
145
return
IOList<T>::typeName
;
146
}
147
148
149
// Generated Methods
150
151
//- No default construct
152
IOListRef
() =
delete
;
153
154
//- No copy construct
155
IOListRef
(
const
IOListRef
&) =
delete
;
156
157
//- No copy assignment
158
void
operator=
(
const
IOListRef
&) =
delete
;
159
160
161
// Constructors
162
163
//- Construct from IOobject and const data reference
164
IOListRef
(
const
IOobject
&
io
,
const
List<T>
& content);
165
166
167
//- Destructor
168
virtual
~IOListRef
() =
default
;
169
170
171
// Member Functions
172
173
//- Allow cast to const content
174
// Fatal if content is not set
175
operator
const
List<T>
&()
const
176
{
177
return
contentRef_.
cref
();
178
}
179
180
//- The writeData method for regIOobject write operation
181
// Fatal if content is not set
182
virtual
bool
writeData
(
Ostream
&
os
)
const
;
183
};
184
185
186
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187
188
}
// End namespace Foam
189
190
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191
192
#ifdef NoRepository
193
#include "
IOList.C
"
194
#endif
195
196
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197
198
#endif
199
200
// ************************************************************************* //
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::~IOList
virtual ~IOList()=default
Destructor.
Foam::refPtr::cref
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
Definition:
refPtrI.H:216
Foam::IOList::content_type
List< T > content_type
The underlying content type.
Definition:
IOList.H:66
Foam::refPtr
A class for managing references or pointers (no reference counting)
Definition:
HashPtrTable.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::word
A class for handling words, derived from Foam::string.
Definition:
word.H:63
Foam::IOListRef::IOListRef
IOListRef()=delete
No default construct.
List.H
Foam::IOList::operator=
void operator=(const IOList< T > &rhs)
Copy assignment of entries.
Definition:
IOList.C:160
Foam::IOList::TypeName
TypeName("List")
Runtime type information.
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition:
HashTable.H:105
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::IOListRef::type
virtual const word & type() const
Type is identical to IOList.
Definition:
IOList.H:174
Foam::IOList::IOList
IOList(const IOList &)=default
Default copy construct.
os
OBJstream os(runTime.globalPath()/outputName)
Foam::IOListRef::~IOListRef
virtual ~IOListRef()=default
Destructor.
regIOobject.H
IOList.C
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::IOListRef
A IOList wrapper for writing external data.
Definition:
IOList.H:151
Foam::IOListRef::content_type
List< T > content_type
The underlying content type.
Definition:
IOList.H:168
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition:
IOobject.H:180
Foam::IOListRef::operator=
void operator=(const IOListRef &)=delete
No copy assignment.
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:26
src
OpenFOAM
db
IOobjects
IOList
IOList.H
Generated by
1.8.14