initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / db / IOobjects / IOMap / IOMap.C
blob42b1d1134792396e2cc75fd8cb4cbc512d4e6459
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "IOMap.H"
29 // * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * //
31 template<class T>
32 Foam::IOMap<T>::IOMap(const IOobject& io)
34     regIOobject(io)
36     if
37     (
38         io.readOpt() == IOobject::MUST_READ
39      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
40     )
41     {
42         readStream(typeName) >> *this;
43         close();
44     }
47 template<class T>
48 Foam::IOMap<T>::IOMap(const IOobject& io, const label size)
50     regIOobject(io)
52     if
53     (
54         io.readOpt() == IOobject::MUST_READ
55      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
56     )
57     {
58         readStream(typeName) >> *this;
59         close();
60     }
61     else
62     {
63         Map<T>::setSize(size);
64     }
68 template<class T>
69 Foam::IOMap<T>::IOMap(const IOobject& io, const Map<T>& map)
71     regIOobject(io)
73     if
74     (
75         io.readOpt() == IOobject::MUST_READ
76      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
77     )
78     {
79         readStream(typeName) >> *this;
80         close();
81     }
82     else
83     {
84         Map<T>::operator=(map);
85     }
89 template<class T>
90 Foam::IOMap<T>::IOMap(const IOobject& io, const Xfer<Map<T> >& map)
92     regIOobject(io)
94     Map<T>::transfer(map());
96     if
97     (
98         io.readOpt() == IOobject::MUST_READ
99      || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
100     )
101     {
102         readStream(typeName) >> *this;
103         close();
104     }
108 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
110 template<class T>
111 Foam::IOMap<T>::~IOMap()
115 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
117 template<class T>
118 bool Foam::IOMap<T>::writeData(Ostream& os) const
120     return (os << *this).good();
124 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
126 template<class T>
127 void Foam::IOMap<T>::operator=(const IOMap<T>& rhs)
129     Map<T>::operator=(rhs);
133 template<class T>
134 void Foam::IOMap<T>::operator=(const Map<T>& rhs)
136     Map<T>::operator=(rhs);
140 // ************************************************************************* //