exprResultStored.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) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
9  Copyright (C) 2019-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 "exprResultStored.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace expressions
37 {
38  defineTypeName(exprResultStored);
39 
41  (
42  exprResult,
43  exprResultStored,
44  dictionary
45  );
47  (
48  exprResult,
49  exprResultStored,
50  empty
51  );
52 
53 } // End namespace expressions
54 } // End namespace Foam
55 
56 
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 
60 :
61  expressions::exprResult(),
62  name_("none"),
63  startExpr_()
64 {}
65 
66 
68 (
69  const exprResultStored& rhs
70 )
71 :
73  name_(rhs.name_),
74  startExpr_(rhs.startExpr_)
75 {}
76 
77 
79 (
80  const dictionary& dict
81 )
82 :
83  expressions::exprResult(dict.subOrEmptyDict("value")),
84  name_(dict.get<word>("name")),
85  startExpr_(dict.get<string>("initialValue"), dict)
86 {}
87 
88 
89 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90 
92 {
93  os.beginBlock();
94 
95  os.writeEntry("name", name_);
96  os.writeEntry("initialValue", startExpr_);
97 
98  os.writeKeyword("value");
99  os << static_cast<const exprResult&>(*this);
100 
101  os.endBlock();
102 }
103 
104 
105 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
106 
107 void Foam::expressions::exprResultStored::operator=
108 (
109  const exprResultStored& rhs
110 )
111 {
112  if (this == &rhs)
113  {
114  return; // Self-assignment is a no-op
115  }
116 
117  this->exprResult::operator=(rhs);
118 
119  name_ = rhs.name_;
120  startExpr_ = rhs.startExpr_;
121 }
122 
123 
124 void Foam::expressions::exprResultStored::operator=
125 (
126  const exprResult& rhs
127 )
128 {
129  if (this == &rhs)
130  {
131  return; // Self-assignment is a no-op
132  }
133 
134  this->exprResult::operator=(rhs);
135 }
136 
137 
138 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
139 
140 Foam::Istream& Foam::operator>>
141 (
142  Istream& is,
144 )
145 {
146  dictionary dict(is);
148 
149  return is;
150 }
151 
152 
153 Foam::Ostream& Foam::operator<<
154 (
155  Ostream& os,
157 )
158 {
159  data.writeDict(os);
160 
161  return os;
162 }
163 
164 
165 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
exprResultStored.H
Foam::expressions::defineTypeName
defineTypeName(fvExprDriverWriter)
Foam::expressions::exprResult::operator=
virtual void operator=(const exprResult &rhs)
Copy assignment.
Definition: exprResult.C:498
Foam::expressions::exprResult
A polymorphic field/result from evaluating an expression.
Definition: exprResult.H:124
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::expressions::exprResultStored
An exprResult with persistence.
Definition: exprResultStored.H:82
Foam::expressions::exprResultStored::writeDict
void writeDict(Ostream &os) const
Definition: exprResultStored.C:91
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::expressions::addToRunTimeSelectionTable
addToRunTimeSelectionTable(exprResult, exprResult, dictionary)
Foam::expressions::exprResultStored::exprResultStored
exprResultStored()
Default construct.
Definition: exprResultStored.C:59
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:55