Condition.hpp
Go to the documentation of this file.
1/*
2 Copyright 2019 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 ACTIONX_CONDITION_HPP
21#define ACTIONX_CONDITION_HPP
22
23#include <string>
24#include <vector>
25
27
28namespace Opm {
29
30namespace Action {
31
32
33class Quantity {
34public:
35 Quantity() = default;
36
37 Quantity(const std::string& arg) :
38 quantity(arg)
39 {}
40
41 void add_arg(const std::string& arg);
43 std::vector<std::string> args;
44
45 bool operator==(const Quantity& data) const {
46 return quantity == data.quantity &&
47 args == data.args;
48 }
49
50 template<class Serializer>
51 void serializeOp(Serializer& serializer)
52 {
53 serializer(quantity);
54 serializer(args);
55 }
56};
57
58
59
60class Condition {
61public:
62
63enum class Logical {
64 AND,
65 OR,
66 END
67};
68
69enum class Comparator {
70 EQUAL,
71 GREATER,
72 LESS,
73 GREATER_EQUAL,
74 LESS_EQUAL,
75 INVALID
76};
77
78
79 Condition() = default;
80 Condition(const std::vector<std::string>& tokens, const Location& location);
81
82
88
89 bool operator==(const Condition& data) const;
90
91 template<class Serializer>
92 void serializeOp(Serializer& serializer)
93 {
94 lhs.serializeOp(serializer);
95 rhs.serializeOp(serializer);
96 serializer(logic);
97 serializer(cmp);
98 serializer(cmp_string);
99 }
100};
101
102
103}
104}
105
106#endif
const char *const string
Definition: cJSON.h:170
Definition: Condition.hpp:60
Logical logic
Definition: Condition.hpp:85
bool operator==(const Condition &data) const
Quantity lhs
Definition: Condition.hpp:83
Condition(const std::vector< std::string > &tokens, const Location &location)
Quantity rhs
Definition: Condition.hpp:84
Comparator
Definition: Condition.hpp:69
Logical
Definition: Condition.hpp:63
Comparator cmp
Definition: Condition.hpp:86
std::string cmp_string
Definition: Condition.hpp:87
void serializeOp(Serializer &serializer)
Definition: Condition.hpp:92
Definition: Condition.hpp:33
Quantity(const std::string &arg)
Definition: Condition.hpp:37
std::vector< std::string > args
Definition: Condition.hpp:43
void add_arg(const std::string &arg)
bool operator==(const Quantity &data) const
Definition: Condition.hpp:45
std::string quantity
Definition: Condition.hpp:42
void serializeOp(Serializer &serializer)
Definition: Condition.hpp:51
Definition: Location.hpp:25
Definition: Serializer.hpp:38
Action
Definition: InputErrorAction.hpp:36
Definition: A.hpp:4
static std::string data()
Definition: exprtk.hpp:40022