IOMap.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2018-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "IOMap.H"
30
31// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32
33template<class T>
35{
36 if
37 (
38 (
39 readOpt() == IOobject::MUST_READ
40 || readOpt() == IOobject::MUST_READ_IF_MODIFIED
41 )
42 || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
43 )
44 {
45 // For if MUST_READ_IF_MODIFIED
46 addWatch();
47
48 readStream(typeName) >> *this;
49 close();
50
51 return true;
52 }
53
54 return false;
55}
56
57
58// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
59
60template<class T>
62:
64{
65 readContents();
66}
67
68
69template<class T>
70Foam::IOMap<T>::IOMap(const IOobject& io, const label size)
71:
73{
74 if (!readContents())
75 {
77 }
78}
79
80
81template<class T>
82Foam::IOMap<T>::IOMap(const IOobject& io, const Map<T>& content)
83:
85{
86 if (!readContents())
87 {
88 Map<T>::operator=(content);
89 }
90}
91
92
93template<class T>
95:
97{
98 Map<T>::transfer(content);
99
100 readContents();
101}
102
103
104// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105
106template<class T>
108{
109 os << *this;
110 return os.good();
111}
112
113
114// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
115
116template<class T>
118{
120}
121
122
123// ************************************************************************* //
virtual bool resize()
Resize the ODE solver.
Definition: Euler.C:53
label size() const noexcept
The number of elements in table.
Definition: HashTableI.H:52
A Map of objects of type <T> with automated input and output. Is a global object; i....
Definition: IOMap.H:58
void operator=(const IOMap< T > &rhs)
Copy assignment of entries.
Definition: IOMap.C:117
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:233
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
void operator=(const this_type &rhs)
Copy assignment.
Definition: Map.H:117
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)