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
9  Copyright (C) 2019-2022 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 :
72  expressions::exprResult(rhs),
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_("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);
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 
135 }
136 
137 
138 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
139 
140 Foam::Istream& Foam::operator>>
141 (
142  Istream& is,
143  expressions::exprResultStored& data
144 )
145 {
146  dictionary dict(is);
148 
149  return is;
150 }
151 
152 
153 Foam::Ostream& Foam::operator<<
154 (
155  Ostream& os,
156  const expressions::exprResultStored& data
157 )
158 {
159  data.writeDict(os);
160 
161  return os;
162 }
163 
164 
165 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A polymorphic field/result from evaluating an expression.
Definition: exprResult.H:121
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Macros for easy insertion into run-time selection tables.
defineTypeName(fvExprDriverWriter)
A class for handling words, derived from Foam::string.
Definition: word.H:63
An exprResult with persistence.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable(exprResult, exprResult, dictionary)
virtual void operator=(const exprResult &rhs)
Copy assignment.
Definition: exprResult.C:467
void writeDict(Ostream &os) const
Namespace for OpenFOAM.