FreeFOAM The Cross-Platform CFD Toolkit
IOPtrList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------* \
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include <OpenFOAM/IOPtrList.H>
27 
28 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
29 
30 template<class T>
31 template<class INew>
33 :
34  regIOobject(io)
35 {
36  if
37  (
40  )
41  {
42  PtrList<T>::read(readStream(typeName), inewt);
43  close();
44  }
45 }
46 
47 
48 template<class T>
50 :
51  regIOobject(io)
52 {
53  if
54  (
57  )
58  {
59  PtrList<T>::read(readStream(typeName), INew<T>());
60  close();
61  }
62 }
63 
64 
65 template<class T>
66 Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const label s)
67 :
68  regIOobject(io),
69  PtrList<T>(s)
70 {
71  if (io.readOpt() != IOobject::NO_READ)
72  {
73  FatalErrorIn("IOPtrList<T>::IOPtrList(const IOobject&, const label)")
74  << "NO_READ must be set if specifying size" << nl
75  << exit(FatalError);
76  }
77 }
78 
79 
80 template<class T>
82 :
83  regIOobject(io)
84 {
85  if
86  (
89  )
90  {
91  PtrList<T>::read(readStream(typeName), INew<T>());
92  close();
93  }
94  else
95  {
97  }
98 }
99 
100 
101 template<class T>
103 :
104  regIOobject(io)
105 {
106  PtrList<T>::transfer(list());
107 
108  if
109  (
111  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
112  )
113  {
114  PtrList<T>::read(readStream(typeName), INew<T>());
115  close();
116  }
117 }
118 
119 
120 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
121 
122 template<class T>
124 {}
125 
126 
127 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
128 
129 template<class T>
131 {
132  return (os << *this).good();
133 }
134 
135 
136 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
137 
138 template<class T>
140 {
142 }
143 
144 // ************************ vim: set sw=4 sts=4 et: ************************ //