OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

IOPtrList.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------* \
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "IOPtrList.H"
00028 
00029 // * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * //
00030 
00031 template<class T>
00032 template<class INew>
00033 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const INew& inewt)
00034 :
00035     regIOobject(io)
00036 {
00037     if
00038     (
00039         io.readOpt() == IOobject::MUST_READ
00040      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00041     )
00042     {
00043         PtrList<T>::read(readStream(typeName), inewt);
00044         close();
00045     }
00046 }
00047 
00048 
00049 template<class T>
00050 Foam::IOPtrList<T>::IOPtrList(const IOobject& io)
00051 :
00052     regIOobject(io)
00053 {
00054     if
00055     (
00056         io.readOpt() == IOobject::MUST_READ
00057      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00058     )
00059     {
00060         PtrList<T>::read(readStream(typeName), INew<T>());
00061         close();
00062     }
00063 }
00064 
00065 
00066 template<class T>
00067 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const label s)
00068 :
00069     regIOobject(io),
00070     PtrList<T>(s)
00071 {
00072     if (io.readOpt() != IOobject::NO_READ)
00073     {
00074         FatalErrorIn("IOPtrList<T>::IOPtrList(const IOobject&, const label)")
00075             << "NO_READ must be set if specifying size" << nl
00076             << exit(FatalError);
00077     }
00078 }
00079 
00080 
00081 template<class T>
00082 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const PtrList<T>& list)
00083 :
00084     regIOobject(io)
00085 {
00086     if
00087     (
00088         io.readOpt() == IOobject::MUST_READ
00089      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00090     )
00091     {
00092         PtrList<T>::read(readStream(typeName), INew<T>());
00093         close();
00094     }
00095     else
00096     {
00097         PtrList<T>::operator=(list);
00098     }
00099 }
00100 
00101 
00102 template<class T>
00103 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const Xfer<PtrList<T> >& list)
00104 :
00105     regIOobject(io)
00106 {
00107     PtrList<T>::transfer(list());
00108 
00109     if
00110     (
00111         io.readOpt() == IOobject::MUST_READ
00112      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00113     )
00114     {
00115         PtrList<T>::read(readStream(typeName), INew<T>());
00116         close();
00117     }
00118 }
00119 
00120 
00121 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
00122 
00123 template<class T>
00124 Foam::IOPtrList<T>::~IOPtrList()
00125 {}
00126 
00127 
00128 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00129 
00130 template<class T>
00131 bool Foam::IOPtrList<T>::writeData(Ostream& os) const
00132 {
00133     return (os << *this).good();
00134 }
00135 
00136 
00137 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00138 
00139 template<class T>
00140 void Foam::IOPtrList<T>::operator=(const IOPtrList<T>& rhs)
00141 {
00142     PtrList<T>::operator=(rhs);
00143 }
00144 
00145 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd