OpenFOAM: API Guide
v2112
The open source CFD toolbox
CompactIOList.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-2017 OpenFOAM Foundation
9
Copyright (C) 2018-2022 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::CompactIOList
29
30
Description
31
A List of objects of type <T> with automated input and output using
32
a compact storage. Behaves like IOList except when binary output in
33
case it writes a CompactListList.
34
35
Useful for lists of small sublists e.g. faceList, cellList.
36
37
SourceFiles
38
CompactIOList.C
39
40
\*---------------------------------------------------------------------------*/
41
42
#ifndef Foam_CompactIOList_H
43
#define Foam_CompactIOList_H
44
45
#include "
IOList.H
"
46
#include "
regIOobject.H
"
47
48
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50
namespace
Foam
51
{
52
53
// Forward Declarations
54
class
Istream;
55
class
Ostream;
56
template
<
class
T,
class
BaseType>
class
CompactIOList;
57
58
template
<
class
T,
class
BaseType>
Istream
&
operator
>>
59
(
60
Istream
&,
61
CompactIOList<T, BaseType>
&
62
);
63
template
<
class
T,
class
BaseType>
Ostream
&
operator
<<
64
(
65
Ostream
&,
66
const
CompactIOList<T, BaseType>
&
67
);
68
69
/*---------------------------------------------------------------------------*\
70
Class CompactIOList Declaration
71
\*---------------------------------------------------------------------------*/
72
73
template
<
class
T,
class
BaseType>
74
class
CompactIOList
75
:
76
public
regIOobject
,
77
public
List
<T>
78
{
79
// Private Member Functions
80
81
//- Read according to header type
82
void
readFromStream();
83
84
//- Read if IOobject flags set. Return true if read.
85
// Reads according to the header type
86
bool
readContents();
87
88
//- Has too many elements in it?
89
bool
overflows()
const
;
90
91
92
public
:
93
94
//- The underlying content type
95
typedef
List<T>
content_type
;
96
97
//- Runtime type information
98
TypeName
(
"CompactList"
);
99
100
101
// Constructors
102
103
//- Default copy construct
104
CompactIOList
(
const
CompactIOList
&) =
default
;
105
106
//- Construct from IOobject
107
explicit
CompactIOList
(
const
IOobject
&
io
);
108
109
//- Construct from IOobject and zero size (if not read)
110
CompactIOList
(
const
IOobject
&
io
,
Foam::zero
);
111
112
//- Construct from IOobject and default length of CompactIOList
113
CompactIOList
(
const
IOobject
&
io
,
const
label len);
114
115
//- Construct from IOobject and List content
116
CompactIOList
(
const
IOobject
&
io
,
const
UList<T>
& content);
117
118
//- Construct by transferring the List content
119
CompactIOList
(
const
IOobject
&
io
,
List<T>
&& content);
120
121
122
//- Destructor
123
virtual
~CompactIOList
() =
default
;
124
125
126
// Member Functions
127
128
//- Write using stream options. Checks for overflow in binary
129
virtual
bool
writeObject
130
(
131
IOstreamOption
streamOpt,
132
const
bool
valid
133
)
const
;
134
135
virtual
bool
writeData
(
Ostream
&)
const
;
136
137
138
// Member Operators
139
140
//- Copy assignment of entries
141
void
operator=
(
const
CompactIOList<T, BaseType>
& rhs);
142
143
//- Copy or move assignment of entries
144
using
List
<
T
>
::operator
=;
145
146
147
// IOstream operators
148
149
//- Read List from Istream, discarding contents of existing List.
150
friend
Istream
&
operator
>> <
T
, BaseType>
151
(
152
Istream
&,
153
CompactIOList<T, BaseType>
&
154
);
155
156
// Write List to Ostream.
157
friend
Ostream
& operator<< <T, BaseType>
158
(
159
Ostream
&,
160
const
CompactIOList<T, BaseType>
&
161
);
162
};
163
164
165
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166
167
}
// End namespace Foam
168
169
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170
171
#ifdef NoRepository
172
#include "
CompactIOList.C
"
173
#endif
174
175
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176
177
#endif
178
179
// ************************************************************************* //
CompactIOList.C
IOList.H
Foam::CompactIOList
A List of objects of type <T> with automated input and output using a compact storage....
Definition:
CompactIOList.H:77
Foam::CompactIOList::content_type
List< T > content_type
The underlying content type.
Definition:
CompactIOList.H:94
Foam::CompactIOList::TypeName
TypeName("CompactList")
Runtime type information.
Foam::CompactIOList::writeData
virtual bool writeData(Ostream &) const
Pure virtual writeData function.
Definition:
CompactIOList.C:209
Foam::CompactIOList::operator=
void operator=(const CompactIOList< T, BaseType > &rhs)
Copy assignment of entries.
Definition:
CompactIOList.C:219
Foam::CompactIOList::~CompactIOList
virtual ~CompactIOList()=default
Destructor.
Foam::CompactIOList::writeObject
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options. Checks for overflow in binary.
Definition:
CompactIOList.C:170
Foam::CompactIOList::CompactIOList
CompactIOList(const CompactIOList &)=default
Default copy construct.
Foam::CompactIOList::operator
friend Ostream & operator(Ostream &, const CompactIOList< T, BaseType > &)
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition:
IOobject.H:170
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition:
IOstreamOption.H:64
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition:
Istream.H:64
Foam::List
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
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition:
Ostream.H:62
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:
UList.H:94
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition:
regIOobject.H:76
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition:
zero.H:63
T
const volScalarField & T
Definition:
createFieldRefs.H:2
io
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:34
regIOobject.H
TypeName
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition:
typeInfo.H:73
src
OpenFOAM
db
IOobjects
CompactIOList
CompactIOList.H
Generated by
1.9.5
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.