My Project
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 
21 #ifndef ActionAST_HPP
22 #define ActionAST_HPP
23 
24 #include <memory>
25 #include <string>
26 #include <unordered_set>
27 #include <vector>
28 
29 #include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp>
30 
31 namespace Opm {
32 namespace Action {
33 
34 class Context;
35 class ASTNode;
36 
37 
38 /*
39  The Action::AST class implements a tree with the result of the parsing of the
40  ACTIONX condition. The AST does not contain any context, that is supplied with
41  a Action::Context instace when calling the eval() methoid is called.
42 */
43 
44 class AST{
45 public:
46  AST() = default;
47  explicit AST(const std::vector<std::string>& tokens);
48 
49  static AST serializeObject();
50 
51  Result eval(const Context& context) const;
52 
53  bool operator==(const AST& data) const;
54 
55  template<class Serializer>
56  void serializeOp(Serializer& serializer)
57  {
58  serializer(condition);
59  }
60  void required_summary(std::unordered_set<std::string>& required_summary) const;
61 
62 private:
63  /*
64  The use of a pointer here is to be able to create this class with only a
65  forward declaration of the ASTNode class. Would have prefered to use a
66  unique_ptr, but that requires writing custom destructors - the use of a
67  shared_ptr does not imply any shared ownership of the ASTNode.
68  */
69  std::shared_ptr<ASTNode> condition;
70 };
71 }
72 }
73 #endif
Definition: ActionAST.hpp:44
Definition: ActionContext.hpp:39
Definition: ActionResult.hpp:99
Definition: Serializer.hpp:38
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29