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