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