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/IOList.H> 00027 00028 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // 00029 00030 template<class T> 00031 Foam::IOList<T>::IOList(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 00047 template<class T> 00048 Foam::IOList<T>::IOList(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 List<T>::setSize(size); 00064 } 00065 } 00066 00067 00068 template<class T> 00069 Foam::IOList<T>::IOList(const IOobject& io, const List<T>& list) 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 List<T>::operator=(list); 00085 } 00086 } 00087 00088 00089 template<class T> 00090 Foam::IOList<T>::IOList(const IOobject& io, const Xfer<List<T> >& list) 00091 : 00092 regIOobject(io) 00093 { 00094 List<T>::transfer(list()); 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::IOList<T>::~IOList() 00112 {} 00113 00114 00115 00116 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 00117 00118 template<class T> 00119 bool Foam::IOList<T>::writeData(Ostream& os) const 00120 { 00121 return (os << *this).good(); 00122 } 00123 00124 00125 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // 00126 00127 template<class T> 00128 void Foam::IOList<T>::operator=(const IOList<T>& rhs) 00129 { 00130 List<T>::operator=(rhs); 00131 } 00132 00133 00134 template<class T> 00135 void Foam::IOList<T>::operator=(const List<T>& rhs) 00136 { 00137 List<T>::operator=(rhs); 00138 } 00139 00140 00141 // ************************ vim: set sw=4 sts=4 et: ************************ //