UDQInput.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
21#ifndef UDQINPUT__HPP_
22#define UDQINPUT__HPP_
23
24#include <memory>
25
27
28namespace Opm {
29
30class UDQAssign;
31class UDQDefine;
32
33class UDQIndex {
34public:
35 UDQIndex() = default;
36
37 UDQIndex(std::size_t insert_index_arg, std::size_t typed_insert_index_arg, UDQAction action_arg, UDQVarType var_type_arg) :
38 insert_index(insert_index_arg),
39 typed_insert_index(typed_insert_index_arg),
40 action(action_arg),
41 var_type(var_type_arg)
42 {
43 }
44
46 {
47 UDQIndex result;
48 result.insert_index = 1;
49 result.typed_insert_index = 2;
52
53 return result;
54 }
55
56 bool operator==(const UDQIndex& data) const {
57 return insert_index == data.insert_index &&
58 typed_insert_index == data.typed_insert_index &&
59 action == data.action &&
60 var_type == data.var_type;
61 }
62
63 template<class Serializer>
64 void serializeOp(Serializer& serializer)
65 {
66 serializer(insert_index);
67 serializer(typed_insert_index);
68 serializer(action);
69 serializer(var_type);
70 }
71
72 std::size_t insert_index;
73 std::size_t typed_insert_index;
76};
77
78
80public:
81 UDQInput(const UDQIndex& index, const UDQDefine& udq_define, const std::string& unit);
82 UDQInput(const UDQIndex& index, const UDQAssign& udq_assign, const std::string& unit);
83
84 template<typename T>
85 const T& get() const;
86
87 template<typename T>
88 bool is() const;
89
90 const std::string& keyword() const;
91 const UDQVarType& var_type() const;
92 const std::string& unit() const;
94private:
95 const UDQDefine * define;
96 const UDQAssign * assign;
97 const std::string m_keyword;
98 UDQVarType m_var_type;
99 const std::string m_unit;
100};
101}
102
103
104
105#endif
const char *const string
Definition: cJSON.h:170
Definition: Serializer.hpp:38
Definition: UDQAssign.hpp:33
Definition: UDQDefine.hpp:39
Definition: UDQInput.hpp:33
bool operator==(const UDQIndex &data) const
Definition: UDQInput.hpp:56
UDQAction action
Definition: UDQInput.hpp:74
std::size_t typed_insert_index
Definition: UDQInput.hpp:73
static UDQIndex serializeObject()
Definition: UDQInput.hpp:45
UDQIndex(std::size_t insert_index_arg, std::size_t typed_insert_index_arg, UDQAction action_arg, UDQVarType var_type_arg)
Definition: UDQInput.hpp:37
std::size_t insert_index
Definition: UDQInput.hpp:72
void serializeOp(Serializer &serializer)
Definition: UDQInput.hpp:64
UDQIndex()=default
UDQVarType var_type
Definition: UDQInput.hpp:75
Definition: UDQInput.hpp:79
const std::string & unit() const
const std::string & keyword() const
UDQInput(const UDQIndex &index, const UDQAssign &udq_assign, const std::string &unit)
UDQInput(const UDQIndex &index, const UDQDefine &udq_define, const std::string &unit)
const UDQVarType & var_type() const
bool is() const
const T & get() const
const UDQIndex index
Definition: UDQInput.hpp:93
Definition: A.hpp:4
UDQVarType
Definition: UDQEnums.hpp:59
UDQAction
Definition: UDQEnums.hpp:129
static std::string data()
Definition: exprtk.hpp:40022