opm-common
Actions.hpp
1 /*
2  Copyright 2018 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 ActionCOnfig_HPP
21 #define ActionCOnfig_HPP
22 
23 #include <opm/input/eclipse/Schedule/Action/ActionX.hpp>
24 #include <opm/input/eclipse/Schedule/Action/PyAction.hpp>
25 
26 #include <cstddef>
27 #include <ctime>
28 #include <string>
29 #include <vector>
30 
31 namespace Opm::Action {
32 
33 class State;
34 
35 } // namespace Opm::Action
36 
37 namespace Opm::Action {
38 
43 class Actions
44 {
45 public:
51  Actions() = default;
52 
62  Actions(const std::vector<ActionX>& action,
63  const std::vector<PyAction>& pyactions);
64 
67 
74  void add(const ActionX& action);
75 
82  void add(const PyAction& pyaction);
83 
85  std::size_t ecl_size() const;
86 
88  std::size_t py_size() const;
89 
93  int max_input_lines() const;
94 
98  bool empty() const;
99 
109  bool ready(const State& state, std::time_t sim_time) const;
110 
120  const ActionX& operator[](const std::string& name) const;
121 
128  const ActionX& operator[](std::size_t index) const;
129 
142  std::vector<const ActionX*>
143  pending(const State& state, std::time_t sim_time) const;
144 
150  std::vector<const PyAction*> pending_python(const State& state) const;
151 
158  bool has(const std::string& name) const;
159 
161  auto begin() const { return this->actions_.begin(); }
162 
164  auto end() const { return this->actions_.end(); }
165 
172  bool operator==(const Actions& data) const;
173 
179  template<class Serializer>
180  void serializeOp(Serializer& serializer)
181  {
182  serializer(this->actions_);
183  serializer(this->pyactions_);
184  }
185 
186 private:
188  std::vector<ActionX> actions_{};
189 
191  std::vector<PyAction> pyactions_{};
192 };
193 
194 } // namespace Opm::Action
195 
196 #endif // ActionCOnfig_HPP
Definition: Python.hpp:35
const ActionX & operator[](const std::string &name) const
Look up ActionX object by name.
Definition: Actions.cpp:124
std::size_t ecl_size() const
Number of ActionX objects in this collection.
Definition: Actions.cpp:89
std::size_t py_size() const
Number of PyAction objects in this collection.
Definition: Actions.cpp:94
std::vector< const PyAction * > pending_python(const State &state) const
Retrieve PyAction objects that are ready to run.
Definition: Actions.cpp:157
auto begin() const
Beginning of this collection&#39;s ActionX objects.
Definition: Actions.hpp:161
Actions()=default
Default constructor.
Management information about the current run&#39;s ACTION system, especially concerning the number of tim...
Definition: State.hpp:50
bool ready(const State &state, std::time_t sim_time) const
Runnability predicate.
Definition: Actions.cpp:117
static Actions serializationTestObject()
Create a serialisation test object.
Definition: Actions.cpp:55
std::vector< const ActionX * > pending(const State &state, std::time_t sim_time) const
Retrieve ActionX objects that are ready to run.
Definition: Actions.cpp:143
Definition: PyAction.hpp:39
Definition: ActionX.hpp:71
Container of action keywords.
Definition: Actions.hpp:43
bool has(const std::string &name) const
ActionX object existence predicate.
Definition: Actions.cpp:170
bool empty() const
Whether or not this collection is empty.
Definition: Actions.cpp:112
bool operator==(const Actions &data) const
Equality predicate.
Definition: Actions.cpp:176
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition: Actions.hpp:180
auto end() const
End of this collection&#39;s ActionX objects.
Definition: Actions.hpp:164
Class for (de-)serializing.
Definition: Serializer.hpp:94
int max_input_lines() const
Maximum number of records in any one ACTIONX block.
Definition: Actions.cpp:99
void add(const ActionX &action)
Include ActionX object in current collection.
Definition: Actions.cpp:64