Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
db
IOobjects
IOPtrList
IOPtrList.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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 <
OpenFOAM/IOPtrList.H
>
27
28
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
29
30
template
<
class
T>
31
template
<
class
INew>
32
Foam::IOPtrList<T>::IOPtrList
(
const
IOobject
& io,
const
INew
& inewt)
33
:
34
regIOobject
(io)
35
{
36
if
37
(
38
io.
readOpt
() ==
IOobject::MUST_READ
39
|| (io.
readOpt
() ==
IOobject::READ_IF_PRESENT
&&
headerOk
())
40
)
41
{
42
PtrList<T>::read
(
readStream
(typeName), inewt);
43
close
();
44
}
45
}
46
47
48
template
<
class
T>
49
Foam::IOPtrList<T>::IOPtrList
(
const
IOobject
& io)
50
:
51
regIOobject
(io)
52
{
53
if
54
(
55
io.
readOpt
() ==
IOobject::MUST_READ
56
|| (io.
readOpt
() ==
IOobject::READ_IF_PRESENT
&&
headerOk
())
57
)
58
{
59
PtrList<T>::read
(
readStream
(typeName),
INew<T>
());
60
close
();
61
}
62
}
63
64
65
template
<
class
T>
66
Foam::IOPtrList<T>::IOPtrList
(
const
IOobject
& io,
const
label s)
67
:
68
regIOobject
(io),
69
PtrList
<
T
>(s)
70
{
71
if
(io.
readOpt
() !=
IOobject::NO_READ
)
72
{
73
FatalErrorIn
(
"IOPtrList<T>::IOPtrList(const IOobject&, const label)"
)
74
<<
"NO_READ must be set if specifying size"
<<
nl
75
<<
exit
(
FatalError
);
76
}
77
}
78
79
80
template
<
class
T>
81
Foam::IOPtrList<T>::IOPtrList
(
const
IOobject
& io,
const
PtrList<T>
& list)
82
:
83
regIOobject
(io)
84
{
85
if
86
(
87
io.
readOpt
() ==
IOobject::MUST_READ
88
|| (io.
readOpt
() ==
IOobject::READ_IF_PRESENT
&&
headerOk
())
89
)
90
{
91
PtrList<T>::read
(
readStream
(typeName),
INew<T>
());
92
close
();
93
}
94
else
95
{
96
PtrList<T>::operator=
(list);
97
}
98
}
99
100
101
template
<
class
T>
102
Foam::IOPtrList<T>::IOPtrList
(
const
IOobject
& io,
const
Xfer
<
PtrList<T>
>& list)
103
:
104
regIOobject
(io)
105
{
106
PtrList<T>::transfer
(list());
107
108
if
109
(
110
io.
readOpt
() ==
IOobject::MUST_READ
111
|| (io.
readOpt
() ==
IOobject::READ_IF_PRESENT
&&
headerOk
())
112
)
113
{
114
PtrList<T>::read
(
readStream
(typeName),
INew<T>
());
115
close
();
116
}
117
}
118
119
120
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
121
122
template
<
class
T>
123
Foam::IOPtrList<T>::~IOPtrList
()
124
{}
125
126
127
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
128
129
template
<
class
T>
130
bool
Foam::IOPtrList<T>::writeData
(
Ostream
& os)
const
131
{
132
return
(os << *
this
).
good
();
133
}
134
135
136
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
137
138
template
<
class
T>
139
void
Foam::IOPtrList<T>::operator=
(
const
IOPtrList<T>
& rhs)
140
{
141
PtrList<T>::operator=
(rhs);
142
}
143
144
// ************************ vim: set sw=4 sts=4 et: ************************ //