exprResultStack.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 <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 Class
28  Foam::expressions::exprResultStack
29 
30 Description
31  A stack of polymorphic fields.
32  Can be used to build a list of results one at a time.
33 
34 SourceFiles
35  exprResultStack.C
36  exprResultStackTemplates.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef expressions_exprResultStack_H
41 #define expressions_exprResultStack_H
42 
43 #include "exprResult.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 namespace expressions
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class exprResultStack Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class exprResultStack
57 :
59 {
60  // Private Data
61 
62  //- Type-checked pop value.
63  // \return True if the type check was satisfied
64  template<class T>
65  bool popChecked(exprResult& result);
66 
67  //- Type-checked push value.
68  // \return True if the type check was satisfied
69  template<class T>
70  bool pushChecked(const exprResult& result);
71 
72 
73 public:
74 
75  //- Runtime type information
76  TypeName("exprResultStack");
77 
78 
79  // Constructors
80 
81  //- Default construct
83 
84  //- Copy construct
85  exprResultStack(const exprResultStack& rhs);
86 
87  //- Construct from a dictionary
88  explicit exprResultStack(const dictionary& dict);
89 
90 
91  // Selectors
92 
93  virtual autoPtr<exprResult> clone() const
94  {
95  return autoPtr<exprResult>
96  (
97  new exprResultStack(*this)
98  );
99  }
100 
101 
102  //- Destructor
103  virtual ~exprResultStack() = default;
104 
105 
106  // Member Functions
107 
108  //- Pop the last value as an expression result
109  exprResult pop();
110 
111  //- Push an expression result value
112  void push(const exprResult& result);
113 
114 
115  // Member Operators
116 
117  //- Copy assignment
118  void operator=(const exprResultStack& rhs);
119 
120  //- Copy assignment
121  void operator=(const exprResult& rhs);
122 };
123 
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 } // End namespace expressions
128 } // End namespace Foam
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 #ifdef NoRepository
133  #include "exprResultStackTemplates.C"
134 #endif
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 #endif
139 
140 // ************************************************************************* //
Foam::expressions::exprResultStack::~exprResultStack
virtual ~exprResultStack()=default
Destructor.
Foam::expressions::exprResultStack::pop
exprResult pop()
Pop the last value as an expression result.
Definition: exprResultStack.C:96
Foam::expressions::exprResultStack::push
void push(const exprResult &result)
Push an expression result value.
Definition: exprResultStack.C:129
Foam::expressions::exprResultStack::clone
virtual autoPtr< exprResult > clone() const
Clone.
Definition: exprResultStack.H:92
Foam::expressions::exprResult
A polymorphic field/result from evaluating an expression.
Definition: exprResult.H:124
exprResultStackTemplates.C
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
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::expressions::exprResultStack::operator=
void operator=(const exprResultStack &rhs)
Copy assignment.
Definition: exprResultStack.C:172
Foam::expressions::exprResultStack
A stack of polymorphic fields. Can be used to build a list of results one at a time.
Definition: exprResultStack.H:55
Foam::expressions::exprResultStack::TypeName
TypeName("exprResultStack")
Runtime type information.
Foam::expressions::exprResultStack::exprResultStack
exprResultStack()
Default construct.
Definition: exprResultStack.C:63
exprResult.H