My Project
Loading...
Searching...
No Matches
PyAction.hpp
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 PYACTION_HPP_
21#define PYACTION_HPP_
22
23#include <functional>
24#include <memory>
25#include <string>
26#include <vector>
27
28namespace Opm {
29
30class Python;
31class EclipseState;
32class Schedule;
33class SummaryState;
34class PyRunModule;
35
36namespace Action {
37class State;
38
40{
41public:
42 enum class RunCount {
43 single,
44 unlimited,
45 first_true
46 };
47
48
49 static RunCount from_string(std::string run_count);
50 static PyAction serializationTestObject();
51 PyAction() = default;
52 PyAction(std::shared_ptr<const Python> python, const std::string& name, RunCount run_count, const std::string& module_file);
53 bool run(EclipseState& ecl_state, Schedule& schedule, std::size_t report_step, SummaryState& st,
54 const std::function<void(const std::string&, const std::vector<std::string>&)>& actionx_callback) const;
55 const std::string& name() const;
56 bool ready(const State& state) const;
57 bool operator==(const PyAction& other) const;
58
59 template<class Serializer>
60 void serializeOp(Serializer& serializer)
61 {
62 serializer(m_name);
63 serializer(m_run_count);
64 serializer(module_file);
65 serializer(m_active);
66 }
67 static bool valid_keyword(const std::string& keyword);
68
69private:
70 void update(bool result) const;
71
72 mutable std::shared_ptr< PyRunModule > run_module;
73 std::string m_name;
74 RunCount m_run_count{RunCount::single};
75 std::string module_file;
76 mutable bool m_active = true;
77};
78
79}
80
81}
82
83#endif
Definition PyAction.hpp:40
Definition State.hpp:40
Definition EclipseState.hpp:63
Definition Schedule.hpp:89
Class for (de-)serializing.
Definition Serializer.hpp:91
Definition SummaryState.hpp:72
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30