Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / OpenFOAM / db / IOobjects / IOList / IOList.C
blob0fbd7d90c650c59db9f58fc900d764e6bc7d2cc7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "IOList.H"
28 // * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * //
30 template<class T>
31 Foam::IOList<T>::IOList(const IOobject& io)
33     regIOobject(io)
35     // Temporary warning
36     if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
37     {
38         WarningIn("IOList::IOList(const IOobject&)")
39             << "IOList " << name()
40             << " constructed with IOobject::MUST_READ_IF_MODIFIED"
41             " but IOList does not support automatic rereading."
42             << endl;
43     }
44     if
45     (
46         (
47             io.readOpt() == IOobject::MUST_READ
48          || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
49         )
50      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
51     )
52     {
53         readStream(typeName) >> *this;
54         close();
55     }
59 template<class T>
60 Foam::IOList<T>::IOList(const IOobject& io, const label size)
62     regIOobject(io)
64     // Temporary warning
65     if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
66     {
67         WarningIn("IOList::IOList(const IOobject&, const label)")
68             << "IOList " << name()
69             << " constructed with IOobject::MUST_READ_IF_MODIFIED"
70             " but IOList does not support automatic rereading."
71             << endl;
72     }
73     if
74     (
75         (
76             io.readOpt() == IOobject::MUST_READ
77          || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
78         )
79      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
80     )
81     {
82         readStream(typeName) >> *this;
83         close();
84     }
85     else
86     {
87         List<T>::setSize(size);
88     }
92 template<class T>
93 Foam::IOList<T>::IOList(const IOobject& io, const List<T>& list)
95     regIOobject(io)
97     // Temporary warning
98     if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
99     {
100         WarningIn("IOList::IOList(const IOobject&, const List<T>&)")
101             << "IOList " << name()
102             << " constructed with IOobject::MUST_READ_IF_MODIFIED"
103             " but IOList does not support automatic rereading."
104             << endl;
105     }
107     if
108     (
109         (
110             io.readOpt() == IOobject::MUST_READ
111          || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
112         )
113      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
114     )
115     {
116         readStream(typeName) >> *this;
117         close();
118     }
119     else
120     {
121         List<T>::operator=(list);
122     }
126 template<class T>
127 Foam::IOList<T>::IOList(const IOobject& io, const Xfer<List<T> >& list)
129     regIOobject(io)
131     // Temporary warning
132     if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
133     {
134         WarningIn
135         (
136             "IOList::IOList(const IOobject&, const Xfer<List<T> >&)"
137         )   << "IOList " << name()
138             << " constructed with IOobject::MUST_READ_IF_MODIFIED"
139             " but IOList does not support automatic rereading."
140             << endl;
141     }
143     List<T>::transfer(list());
145     if
146     (
147         (
148             io.readOpt() == IOobject::MUST_READ
149          || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
150         )
151      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
152     )
153     {
154         readStream(typeName) >> *this;
155         close();
156     }
160 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
162 template<class T>
163 Foam::IOList<T>::~IOList()
168 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
170 template<class T>
171 bool Foam::IOList<T>::writeData(Ostream& os) const
173     return (os << *this).good();
177 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
179 template<class T>
180 void Foam::IOList<T>::operator=(const IOList<T>& rhs)
182     List<T>::operator=(rhs);
186 template<class T>
187 void Foam::IOList<T>::operator=(const List<T>& rhs)
189     List<T>::operator=(rhs);
193 // ************************************************************************* //