IOdictionary.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-2021 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 "IOdictionary.H"
27 #include "objectRegistry.H"
28 #include "Pstream.H"
29 #include "Time.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
36 
38  (
39  debug::infoSwitch("writeDictionaries", 0)
40  );
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 (
48  const IOobject& io,
49  const word& wantedType
50 )
51 :
52  regIOobject(io)
53 {
55 
56  // Reading performed by derived type
57 }
58 
59 
61 :
62  regIOobject(io)
63 {
65 
66  readHeaderOk(IOstream::ASCII, typeName);
67 
68  // For if MUST_READ_IF_MODIFIED
69  addWatch();
70 }
71 
72 
74 (
75  const IOobject& io,
76  const dictionary& dict
77 )
78 :
79  regIOobject(io)
80 {
82 
83  if (!readHeaderOk(IOstream::ASCII, typeName))
84  {
86  }
87 
88  // For if MUST_READ_IF_MODIFIED
89  addWatch();
90 }
91 
92 
94 (
95  const IOobject& io,
96  Istream& is
97 )
98 :
99  regIOobject(io)
100 {
102 
103  // Note that we do construct the dictionary null and read in
104  // afterwards
105  // so that if there is some fancy massaging due to a
106  // functionEntry in
107  // the dictionary at least the type information is already complete.
108  is >> *this;
109 
110  // For if MUST_READ_IF_MODIFIED
111  addWatch();
112 }
113 
114 
116 :
117  regIOobject(dict),
119 {}
120 
121 
123 :
124  regIOobject(move(dict)),
125  dictionary(move(dict))
126 {}
127 
128 
129 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
130 
132 {}
133 
134 
135 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
136 
138 {
140 }
141 
142 
144 {
145  dictionary::operator=(move(rhs));
146 }
147 
148 
149 // ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
void operator=(const IOdictionary &)
Assignment of dictionary entries only.
Definition: IOdictionary.C:137
IOdictionary(const IOobject &io, const word &wantedType)
Construct given an IOobject, supply wanted typeName.
Definition: IOdictionary.C:47
static bool writeDictionaries
Definition: IOdictionary.H:74
virtual ~IOdictionary()
Destructor.
Definition: IOdictionary.C:131
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:109
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
void operator=(const dictionary &)
Definition: dictionary.C:1529
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
fileName objectPath() const
Return complete path + object name.
Definition: regIOobject.H:159
bool readHeaderOk(const IOstream::streamFormat defaultFormat, const word &typeName)
Read header, check readOpt flags and read data if necessary.
void addWatch()
Add file watch on object (if registered and READ_IF_MODIFIED)
Definition: regIOobject.C:259
A class for handling words, derived from string.
Definition: word.H:62
int infoSwitch(const char *name, const int defaultValue=0)
Lookup info switch or add default value.
Definition: debug.C:233
Namespace for OpenFOAM.
defineTypeNameAndDebug(combustionModel, 0)
dictionary dict