IODynList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh 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 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25  An IODynList of a given type is a List of that type which supports automated
26  input and output.
27 
28 \*---------------------------------------------------------------------------*/
29 
30 #include "IODynList.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 template<class T, class IndexType>
41 :
42  regIOobject(io),
43  DynList<T, IndexType>()
44 {
45  if
46  (
49  )
50  {
51  readStream(typeName) >> *this;
52  close();
53  }
54 }
55 
56 
57 template<class T, class IndexType>
59 (
60  const IOobject& io,
61  const IndexType size
62 )
63 :
64  regIOobject(io),
66 {}
67 
68 
69 template<class T, class IndexType>
71 (
72  const IOobject& io,
73  const DynList<T, IndexType>& list
74 )
75 :
76  regIOobject(io),
78 {
79  if (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
80  {
81  readStream(typeName) >> *this;
82  close();
83  }
84 
86 }
87 
88 
89 template<class T, class IndexType>
91 (
92  const IODynList<T, IndexType>& rhs
93 )
94 {
96 }
97 
98 
99 template<class T, class IndexType>
101 (
102  const DynList<T, IndexType>& rhs
103 )
104 {
106 }
107 
108 
109 template<class T, class IndexType>
111 {
112  return (os << *this).good();
113 }
114 
115 
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 
118 } // End namespace Foam
119 
120 // ************************************************************************* //
Foam::IODynList::writeData
bool writeData(Ostream &) const
Pure virtual writaData function.
Definition: IODynList.C:110
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
Foam::IODynList::IODynList
IODynList(const IOobject &)
Construct from IOobject.
Definition: IODynList.C:40
Foam::IOobject::headerOk
bool headerOk()
Read and check header info.
Definition: IOobject.C:439
Foam::IOobject::readOpt
readOption readOpt() const
Definition: IOobject.H:317
IODynList.H
Foam::DynList::operator=
void operator=(const T &)
Assignment of all entries to the given value.
Definition: DynListI.H:525
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::DynList
Definition: DynList.H:53
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
Foam::regIOobject::readStream
Istream & readStream()
Return Istream.
Definition: regIOobjectRead.C:34
Foam::regIOobject::close
void close()
Close Istream.
Definition: regIOobjectRead.C:148
Foam::IODynList
Definition: IODynList.H:51
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::IOobject::READ_IF_PRESENT
@ READ_IF_PRESENT
Definition: IOobject.H:110