exprResultStored.H
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-2023 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 Class
28  Foam::expressions::exprResultStored
29 
30 Description
31  An exprResult with persistence.
32 
33  \heading Dictionary parameters
34  \table
35  Property | Description | Required | Default
36  name | The result name | yes |
37  initialValue | The initial value | yes |
38  value | The expression result (dictionary) | no |
39  \endtable
40 
41 SourceFiles
42  StoredExpressionResult.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef Foam_expressions_exprResultStored_H
47 #define Foam_expressions_exprResultStored_H
48 
49 #include "exprResult.H"
50 #include "exprString.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 namespace expressions
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class exprResultStored Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class exprResultStored
64 :
65  public expressions::exprResult
66 {
67  // Private Data
68 
69  //- The name of the expression
70  word name_;
71 
72  //- The initial value expression
73  expressions::exprString startExpr_;
74 
75 
76 protected:
77 
78  // Protected Member Functions
79 
80  //- Reset at new timestep - disabling locally
81  virtual void resetImpl() {}
82 
83 
84 public:
85 
86  //- Runtime type information
87  TypeNameNoDebug("exprResultStored");
88 
89 
90  // Constructors
91 
92  //- Default construct
94 
95  //- Copy construct
97 
98  //- Construct from a dictionary
99  explicit exprResultStored(const dictionary& dict);
100 
101 
102  // Selectors
103 
104  virtual autoPtr<exprResult> clone() const
105  {
106  return autoPtr<exprResult>
107  (
108  new exprResultStored(*this)
109  );
110  }
111 
112 
113  //- Destructor
114  virtual ~exprResultStored() = default;
115 
116 
117  // Member Functions
118 
119  //- The name of the expression
120  const word& name() const
121  {
122  return name_;
123  }
124 
125  //- The initial value expression
127  {
128  return startExpr_;
129  }
130 
131 
132  void writeDict(Ostream& os) const;
134 
135  // Member Operators
136 
137  //- Copy assignment
138  void operator=(const exprResultStored& rhs);
139 
140  //- Copy assignment
141  void operator=(const exprResult& rhs);
142 
143  //- Compare for inequality (need by Ulist)
144  bool operator!=(const exprResultStored& rhs) const noexcept
145  {
146  return (this != &rhs);
147  }
148 };
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace expressions
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 // IO Operators
160 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #endif
169 
170 // ************************************************************************* //
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
virtual void resetImpl()
Reset at new timestep - disabling locally.
bool operator!=(const exprResultStored &rhs) const noexcept
Compare for inequality (need by Ulist)
virtual autoPtr< exprResult > clone() const
Clone.
TypeNameNoDebug("exprResultStored")
Runtime type information.
const word & name() const
The name of the expression.
A class for handling words, derived from Foam::string.
Definition: word.H:63
Istream & operator>>(Istream &, directionInfo &)
A variant of Foam::string with expansion of dictionary variables into a comma-separated form...
Definition: exprString.H:55
An exprResult with persistence.
void operator=(const exprResultStored &rhs)
Copy assignment.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
const expressions::exprString & initialValueExpression() const
The initial value expression.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
void writeDict(Ostream &os) const
Namespace for OpenFOAM.
virtual ~exprResultStored()=default
Destructor.