Add serializer support for PyAction

This commit is contained in:
Joakim Hove
2020-03-19 14:21:49 +01:00
parent d2af97b1b2
commit 81b70de140
4 changed files with 25 additions and 5 deletions

View File

@@ -39,7 +39,7 @@ namespace Action {
class Actions {
public:
Actions() = default;
Actions(const std::vector<ActionX>& action);
Actions(const std::vector<ActionX>& action, const std::vector<PyAction>& pyactions);
size_t size() const;
int max_input_lines() const;
bool empty() const;
@@ -59,6 +59,7 @@ public:
void serializeOp(Serializer& serializer)
{
serializer.vector(actions);
serializer.vector(pyactions);
}
private:

View File

@@ -39,9 +39,11 @@ public:
static RunCount from_string(std::string run_count);
static std::string load(const std::string& input_path, const std::string& fname);
PyAction() = default;
PyAction(const std::string& name, RunCount run_count, const std::string& code);
const std::string& code() const;
const std::string& name() const;
bool operator==(const PyAction& other) const;
PyAction::RunCount run_count() const;
~PyAction();
@@ -56,11 +58,20 @@ public:
between invocations.
*/
void * storage() const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_name);
serializer(m_run_count);
serializer(input_code);
}
private:
std::string m_name;
RunCount m_run_count;
std::string input_code;
void * m_storage;
void * m_storage = nullptr;
};
}

View File

@@ -25,8 +25,9 @@ namespace Opm {
namespace Action {
Actions::Actions(const std::vector<ActionX>& action)
: actions(action)
Actions::Actions(const std::vector<ActionX>& action, const std::vector<PyAction>& pyactions)
: actions(action),
pyactions(pyactions)
{}
@@ -106,7 +107,8 @@ std::vector<ActionX>::const_iterator Actions::end() const {
bool Actions::operator==(const Actions& data) const {
return actions == data.actions;
return this->actions == data.actions &&
this->pyactions == data.pyactions;
}
}

View File

@@ -103,6 +103,12 @@ PyAction::~PyAction() {
#endif
}
bool PyAction::operator==(const PyAction& other) const {
return this->m_name == other.m_name &&
this->m_run_count == other.m_run_count &&
this->input_code == other.input_code;
}
void * PyAction::storage() const {