PyAction.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 PYACTION_HPP_
22#define PYACTION_HPP_
23
24
25#include <string>
26#include <memory>
27
28
29namespace Opm {
30
31class Python;
32class EclipseState;
33class Schedule;
34class SummaryState;
35class PyRunModule;
36
37namespace Action {
38
39class PyAction {
40public:
41 enum class RunCount {
42 single,
43 unlimited,
44 first_true
45 };
46
47
48 static RunCount from_string(std::string run_count);
50 PyAction() = default;
51 PyAction(std::shared_ptr<const Python> python, const std::string& name, RunCount run_count, const std::string& module_file);
52 bool run(EclipseState& ecl_state, Schedule& schedule, std::size_t report_step, SummaryState& st) const;
53 const std::string& name() const;
54 bool active() const;
55 bool operator==(const PyAction& other) const;
56
57 template<class Serializer>
58 void serializeOp(Serializer& serializer)
59 {
60 serializer(m_name);
61 serializer(m_run_count);
62 serializer(module_file);
63 serializer(m_active);
64 }
65
66private:
67 void update(bool result) const;
68
69 mutable std::shared_ptr< PyRunModule > run_module;
70 std::string m_name;
71 RunCount m_run_count;
72 std::string module_file;
73 mutable bool m_active = true;
74};
75}
76
77}
78
79#endif
const char *const string
Definition: cJSON.h:170
Definition: PyAction.hpp:39
RunCount
Definition: PyAction.hpp:41
PyAction(std::shared_ptr< const Python > python, const std::string &name, RunCount run_count, const std::string &module_file)
const std::string & name() const
static RunCount from_string(std::string run_count)
bool operator==(const PyAction &other) const
bool run(EclipseState &ecl_state, Schedule &schedule, std::size_t report_step, SummaryState &st) const
static PyAction serializeObject()
void serializeOp(Serializer &serializer)
Definition: PyAction.hpp:58
Definition: EclipseState.hpp:63
Definition: Schedule.hpp:113
Definition: Serializer.hpp:38
Definition: SummaryState.hpp:65
Action
Definition: InputErrorAction.hpp:36
Definition: A.hpp:4