FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <OpenFOAM/IOPtrList.H>
00027 
00028 // * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * //
00029 
00030 template<class T>
00031 template<class INew>
00032 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const INew& inewt)
00033 :
00034     regIOobject(io)
00035 {
00036     if
00037     (
00038         io.readOpt() == IOobject::MUST_READ
00039      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00040     )
00041     {
00042         PtrList<T>::read(readStream(typeName), inewt);
00043         close();
00044     }
00045 }
00046 
00047 
00048 template<class T>
00049 Foam::IOPtrList<T>::IOPtrList(const IOobject& io)
00050 :
00051     regIOobject(io)
00052 {
00053     if
00054     (
00055         io.readOpt() == IOobject::MUST_READ
00056      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00057     )
00058     {
00059         PtrList<T>::read(readStream(typeName), INew<T>());
00060         close();
00061     }
00062 }
00063 
00064 
00065 template<class T>
00066 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const label s)
00067 :
00068     regIOobject(io),
00069     PtrList<T>(s)
00070 {
00071     if (io.readOpt() != IOobject::NO_READ)
00072     {
00073         FatalErrorIn("IOPtrList<T>::IOPtrList(const IOobject&, const label)")
00074             << "NO_READ must be set if specifying size" << nl
00075             << exit(FatalError);
00076     }
00077 }
00078 
00079 
00080 template<class T>
00081 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const PtrList<T>& list)
00082 :
00083     regIOobject(io)
00084 {
00085     if
00086     (
00087         io.readOpt() == IOobject::MUST_READ
00088      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00089     )
00090     {
00091         PtrList<T>::read(readStream(typeName), INew<T>());
00092         close();
00093     }
00094     else
00095     {
00096         PtrList<T>::operator=(list);
00097     }
00098 }
00099 
00100 
00101 template<class T>
00102 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const Xfer<PtrList<T> >& list)
00103 :
00104     regIOobject(io)
00105 {
00106     PtrList<T>::transfer(list());
00107 
00108     if
00109     (
00110         io.readOpt() == IOobject::MUST_READ
00111      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00112     )
00113     {
00114         PtrList<T>::read(readStream(typeName), INew<T>());
00115         close();
00116     }
00117 }
00118 
00119 
00120 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
00121 
00122 template<class T>
00123 Foam::IOPtrList<T>::~IOPtrList()
00124 {}
00125 
00126 
00127 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00128 
00129 template<class T>
00130 bool Foam::IOPtrList<T>::writeData(Ostream& os) const
00131 {
00132     return (os << *this).good();
00133 }
00134 
00135 
00136 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00137 
00138 template<class T>
00139 void Foam::IOPtrList<T>::operator=(const IOPtrList<T>& rhs)
00140 {
00141     PtrList<T>::operator=(rhs);
00142 }
00143 
00144 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines