My Project
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 <string>
26 #include <memory>
27 
28 
29 namespace Opm {
30 
31 class Python;
32 class EclipseState;
33 class Schedule;
34 class SummaryState;
35 class PyRunModule;
36 
37 namespace Action {
38 
39 class PyAction {
40 public:
41  enum class RunCount {
42  single,
43  unlimited,
44  first_true
45  };
46 
47 
48  static RunCount from_string(std::string run_count);
49  static PyAction serializeObject();
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 
66 private:
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
Definition: PyAction.hpp:39
Definition: EclipseState.hpp:55
Definition: Schedule.hpp:135
Definition: Serializer.hpp:38
Definition: SummaryState.hpp:69
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29