IOMap.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-2019 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 "IOMap.H"
27 
28 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
29 
30 template<class T>
32 :
33  regIOobject(io)
34 {
35  if
36  (
37  (
40  )
42  )
43  {
44  // For if MUST_READ_IF_MODIFIED
45  addWatch();
46 
47  readStream(typeName) >> *this;
48  close();
49  }
50 }
51 
52 template<class T>
54 :
55  regIOobject(io)
56 {
57  if
58  (
59  (
62  )
64  )
65  {
66  // For if MUST_READ_IF_MODIFIED
67  addWatch();
68 
69  readStream(typeName) >> *this;
70  close();
71  }
72  else
73  {
74  Map<T>::setSize(size);
75  }
76 }
77 
78 
79 template<class T>
80 Foam::IOMap<T>::IOMap(const IOobject& io, const Map<T>& map)
81 :
82  regIOobject(io)
83 {
84  if
85  (
86  (
89  )
91  )
92  {
93  // For if MUST_READ_IF_MODIFIED
94  addWatch();
95 
96  readStream(typeName) >> *this;
97  close();
98  }
99  else
100  {
101  Map<T>::operator=(map);
102  }
103 }
104 
105 
106 template<class T>
108 :
109  regIOobject(io),
110  Map<T>(move(map))
111 {
112  if
113  (
114  (
117  )
118  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
119  )
120  {
121  // For if MUST_READ_IF_MODIFIED
122  addWatch();
123 
124  readStream(typeName) >> *this;
125  close();
126  }
127 }
128 
129 
130 template<class T>
132 :
133  regIOobject(move(map)),
134  Map<T>(move(map))
135 {}
136 
137 
138 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
139 
140 template<class T>
142 {}
143 
144 
145 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
146 
147 template<class T>
149 {
150  return (os << *this).good();
151 }
152 
153 
154 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
155 
156 template<class T>
158 {
159  Map<T>::operator=(rhs);
160 }
161 
162 
163 template<class T>
165 {
166  Map<T>::operator=(move(rhs));
167 }
168 
169 
170 template<class T>
172 {
173  Map<T>::operator=(rhs);
174 }
175 
176 
177 template<class T>
179 {
180  Map<T>::operator=(move(rhs));
181 }
182 
183 
184 // ************************************************************************* //
IOMap(const IOobject &)
Construct from IOobject.
Definition: IOMap.C:31
bool headerOk()
Read and check header info.
Definition: regIOobject.C:443
A Map of objects of type <T> with automated input and output. Is a global object; i...
Definition: IOMap.H:51
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
points setSize(newPointi)
void close()
Close Istream.
bool writeData(Ostream &) const
Pure virtual writaData function.
Definition: IOMap.C:148
Istream & readStream(const word &, const bool read=true)
Return Istream and check object type against that given.
virtual ~IOMap()
Destructor.
Definition: IOMap.C:141
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void addWatch()
Add file watch on object (if registered and READ_IF_MODIFIED)
Definition: regIOobject.C:259
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void operator=(const IOMap< T > &)
Assignment of other IOMap&#39;s entries to this IOMap.
Definition: IOMap.C:157
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:52
readOption readOpt() const
Definition: IOobject.H:365
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
void operator=(const Map< T > &map)
Definition: Map.H:102
A HashTable to objects of type <T> with a label key.
Definition: Map.H:49