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

IOMap.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 "IOMap.H"
00028 
00029 // * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * //
00030 
00031 template<class T>
00032 Foam::IOMap<T>::IOMap(const IOobject& io)
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         readStream(typeName) >> *this;
00043         close();
00044     }
00045 }
00046 
00047 template<class T>
00048 Foam::IOMap<T>::IOMap(const IOobject& io, const label size)
00049 :
00050     regIOobject(io)
00051 {
00052     if
00053     (
00054         io.readOpt() == IOobject::MUST_READ
00055      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00056     )
00057     {
00058         readStream(typeName) >> *this;
00059         close();
00060     }
00061     else
00062     {
00063         Map<T>::setSize(size);
00064     }
00065 }
00066 
00067 
00068 template<class T>
00069 Foam::IOMap<T>::IOMap(const IOobject& io, const Map<T>& map)
00070 :
00071     regIOobject(io)
00072 {
00073     if
00074     (
00075         io.readOpt() == IOobject::MUST_READ
00076      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00077     )
00078     {
00079         readStream(typeName) >> *this;
00080         close();
00081     }
00082     else
00083     {
00084         Map<T>::operator=(map);
00085     }
00086 }
00087 
00088 
00089 template<class T>
00090 Foam::IOMap<T>::IOMap(const IOobject& io, const Xfer<Map<T> >& map)
00091 :
00092     regIOobject(io)
00093 {
00094     Map<T>::transfer(map());
00095 
00096     if
00097     (
00098         io.readOpt() == IOobject::MUST_READ
00099      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
00100     )
00101     {
00102         readStream(typeName) >> *this;
00103         close();
00104     }
00105 }
00106 
00107 
00108 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
00109 
00110 template<class T>
00111 Foam::IOMap<T>::~IOMap()
00112 {}
00113 
00114 
00115 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00116 
00117 template<class T>
00118 bool Foam::IOMap<T>::writeData(Ostream& os) const
00119 {
00120     return (os << *this).good();
00121 }
00122 
00123 
00124 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00125 
00126 template<class T>
00127 void Foam::IOMap<T>::operator=(const IOMap<T>& rhs)
00128 {
00129     Map<T>::operator=(rhs);
00130 }
00131 
00132 
00133 template<class T>
00134 void Foam::IOMap<T>::operator=(const Map<T>& rhs)
00135 {
00136     Map<T>::operator=(rhs);
00137 }
00138 
00139 
00140 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd