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

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