1 /*---------------------------------------------------------------------------* \
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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 "IOPtrList.H"
28 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
32 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const INew& inewt)
39 io.readOpt() == IOobject::MUST_READ
40 || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
42 || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
45 PtrList<T>::read(readStream(typeName), inewt);
52 Foam::IOPtrList<T>::IOPtrList(const IOobject& io)
59 io.readOpt() == IOobject::MUST_READ
60 || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
62 || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
65 PtrList<T>::read(readStream(typeName), INew<T>());
72 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const label s)
77 if (io.readOpt() != IOobject::NO_READ)
79 FatalErrorIn("IOPtrList<T>::IOPtrList(const IOobject&, const label)")
80 << "NO_READ must be set if specifying size" << nl
87 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const PtrList<T>& list)
94 io.readOpt() == IOobject::MUST_READ
95 || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
97 || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
100 PtrList<T>::read(readStream(typeName), INew<T>());
105 PtrList<T>::operator=(list);
111 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const Xfer<PtrList<T> >& list)
115 PtrList<T>::transfer(list());
120 io.readOpt() == IOobject::MUST_READ
121 || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
123 || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
126 PtrList<T>::read(readStream(typeName), INew<T>());
132 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
135 Foam::IOPtrList<T>::~IOPtrList()
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
142 bool Foam::IOPtrList<T>::writeData(Ostream& os) const
144 return (os << *this).good();
148 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
151 void Foam::IOPtrList<T>::operator=(const IOPtrList<T>& rhs)
153 PtrList<T>::operator=(rhs);
156 // ************************************************************************* //