IOList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
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 "IOList.H"
27 
28 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
29 
30 template<class T>
32 :
33  regIOobject(io)
34 {
35  // Check for MUST_READ_IF_MODIFIED
36  warnNoRereading<IOList<T>>();
37 
38  if
39  (
40  (
41  io.readOpt() == IOobject::MUST_READ
42  || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
43  )
44  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
45  )
46  {
47  readStream(typeName) >> *this;
48  close();
49  }
50 }
51 
52 
53 template<class T>
54 Foam::IOList<T>::IOList(const IOobject& io, const label size)
55 :
56  regIOobject(io)
57 {
58  // Check for MUST_READ_IF_MODIFIED
59  warnNoRereading<IOList<T>>();
60 
61  if
62  (
63  (
64  io.readOpt() == IOobject::MUST_READ
65  || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
66  )
67  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
68  )
69  {
70  readStream(typeName) >> *this;
71  close();
72  }
73  else
74  {
75  List<T>::setSize(size);
76  }
77 }
78 
79 
80 template<class T>
81 Foam::IOList<T>::IOList(const IOobject& io, const List<T>& list)
82 :
83  regIOobject(io)
84 {
85  // Check for MUST_READ_IF_MODIFIED
86  warnNoRereading<IOList<T>>();
87 
88  if
89  (
90  (
91  io.readOpt() == IOobject::MUST_READ
92  || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
93  )
94  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
95  )
96  {
97  readStream(typeName) >> *this;
98  close();
99  }
100  else
101  {
102  List<T>::operator=(list);
103  }
104 }
105 
106 
107 template<class T>
109 :
110  regIOobject(io)
111 {
112  // Check for MUST_READ_IF_MODIFIED
113  warnNoRereading<IOList<T>>();
114 
115  List<T>::transfer(list());
116 
117  if
118  (
119  (
120  io.readOpt() == IOobject::MUST_READ
121  || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
122  )
123  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
124  )
125  {
126  readStream(typeName) >> *this;
127  close();
128  }
129 }
130 
131 
132 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
133 
134 template<class T>
136 {}
137 
138 
139 
140 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 
142 template<class T>
144 {
145  return (os << *this).good();
146 }
147 
148 
149 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
150 
151 template<class T>
153 {
154  List<T>::operator=(rhs);
155 }
156 
157 
158 template<class T>
160 {
161  List<T>::operator=(rhs);
162 }
163 
164 
165 // ************************************************************************* //
virtual ~IOList()
Destructor.
Definition: IOList.C:135
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
A List of objects of type <T> with automated input and output.
Definition: IOList.H:50
void operator=(const IOList< T > &)
Definition: IOList.C:152
points setSize(newPointi)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
IOList(const IOobject &)
Construct from IOobject.
Definition: IOList.C:31
bool writeData(Ostream &) const
Pure virtual writaData function.
Definition: IOList.C:143
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:65
readOption readOpt() const
Definition: IOobject.H:359
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92