baseIOdictionary.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-2014 OpenFOAM Foundation
9 Copyright (C) 2021 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 "baseIOdictionary.H"
30#include "objectRegistry.H"
31#include "Pstream.H"
32#include "Time.H"
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
39
40 bool baseIOdictionary::writeDictionaries
41 (
42 debug::infoSwitch("writeDictionaries", 0)
43 );
44}
45
46
47// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48
50(
51 const IOobject& io,
52 const dictionary* fallback
53)
54:
56{
58}
59
60
62(
63 const IOobject& io,
64 const dictionary& dict
65)
66:
68{}
69
70
72(
73 const IOobject& io,
74 Istream& is
75)
76:
78{
80}
81
82
83// * * * * * * * * * * * * * * * Members Functions * * * * * * * * * * * * * //
84
86{
87 return regIOobject::name();
88}
89
90
92{
93 is >> *this;
94
95 if (writeDictionaries && Pstream::master() && !is.bad())
96 {
97 Sout<< nl
98 << "--- baseIOdictionary " << name()
99 << ' ' << objectPath() << ":" << nl;
102 Sout<< "--- End of baseIOdictionary " << name() << nl << endl;
103 }
104
105 return !is.bad();
106}
107
108
110{
111 dictionary::write(os, false);
112 return os.good();
113}
114
115
116// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
117
119{
121}
122
123
124// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
fileName objectPath() const
The complete path + object name.
Definition: IOobjectI.H:214
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:233
bool bad() const noexcept
True if stream is corrupted.
Definition: IOstream.H:251
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
baseIOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO function...
virtual bool writeData(Ostream &) const
The writeData function required by regIOobject write operation.
void operator=(const baseIOdictionary &rhs)
Copy assignment of dictionary entries (leave regIOobject untouched)
virtual bool readData(Istream &)
The readData function required by regIOobject read operation.
const word & name() const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const fileName & name() const noexcept
The dictionary name.
Definition: dictionaryI.H:48
void operator=(const dictionary &rhs)
Copy assignment.
Definition: dictionary.C:881
virtual bool write()
Write the output fields.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
splitCell * master() const
Definition: splitCell.H:113
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
Definition: debug.C:231
Namespace for OpenFOAM.
static void writeHeader(Ostream &os, const word &fieldName)
OSstream Sout
OSstream wrapped stdout (std::cout)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
static void writeData(Ostream &os, const Type &val)
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict