My Project
Loading...
Searching...
No Matches
ActionAST.hpp
1/*
2 Copyright 2018 Equinor ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef ActionAST_HPP
21#define ActionAST_HPP
22
23#include <opm/input/eclipse/Schedule/Action/ActionResult.hpp>
24
25#include <memory>
26#include <string>
27#include <unordered_set>
28#include <vector>
29
30namespace Opm::Action {
31
32class Context;
33class ASTNode;
34
35} // namespace Opm::Action
36
37namespace Opm::Action {
38
44
45class AST
46{
47public:
52 AST();
53
61 explicit AST(const std::vector<std::string>& tokens);
62
65
69 AST(const AST& rhs);
70
75 AST(AST&& rhs);
76
82 AST& operator=(const AST& rhs);
83
90 AST& operator=(AST&& rhs);
91
94
103 Result eval(const Context& context) const;
104
111 bool operator==(const AST& data) const;
112
118 template<class Serializer>
119 void serializeOp(Serializer& serializer)
120 {
121 serializer(condition);
122 }
123
130 void required_summary(std::unordered_set<std::string>& required_summary) const;
131
132private:
134 std::unique_ptr<ASTNode> condition{};
135};
136
137} // namespace Opm::Action
138
139#endif // ActionAST_HPP
Expression evaluation tree of a full ACTIONX condition block.
Definition ActionAST.hpp:46
AST()
Default constructor.
static AST serializationTestObject()
Create a serialisation test object.
Definition ActionAST.cpp:76
bool operator==(const AST &data) const
Equality predicate.
Definition ActionAST.cpp:94
Result eval(const Context &context) const
Evaluate the expression tree at current dynamic state.
Definition ActionAST.cpp:85
AST & operator=(const AST &rhs)
Assignment operator.
Definition ActionAST.cpp:52
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition ActionAST.hpp:119
void required_summary(std::unordered_set< std::string > &required_summary) const
Export all summary vectors needed to evaluate the expression tree.
Definition ActionAST.cpp:102
~AST()
Destructor.
Manager of summary vector values.
Definition ActionContext.hpp:42
Class Action::Result holds the boolean result of a ACTIONX condition like.
Definition ActionResult.hpp:69
Class for (de-)serializing.
Definition Serializer.hpp:94