From 45a6e4fb15aac68b43b16565c2e39111410126ae Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 20 Jan 2022 16:12:17 +0100 Subject: [PATCH] Add method Actions::has( action_name ) --- opm/input/eclipse/Schedule/Action/Actions.hpp | 1 + src/opm/input/eclipse/Schedule/Action/Actions.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/opm/input/eclipse/Schedule/Action/Actions.hpp b/opm/input/eclipse/Schedule/Action/Actions.hpp index 70bce07dc..a8b4e261b 100644 --- a/opm/input/eclipse/Schedule/Action/Actions.hpp +++ b/opm/input/eclipse/Schedule/Action/Actions.hpp @@ -57,6 +57,7 @@ public: std::vector pending(const State& state, std::time_t sim_time) const; std::vector pending_python() const; + bool has(const std::string& name) const; std::vector::const_iterator begin() const; std::vector::const_iterator end() const; diff --git a/src/opm/input/eclipse/Schedule/Action/Actions.cpp b/src/opm/input/eclipse/Schedule/Action/Actions.cpp index 3bad329d3..dfbab48d1 100644 --- a/src/opm/input/eclipse/Schedule/Action/Actions.cpp +++ b/src/opm/input/eclipse/Schedule/Action/Actions.cpp @@ -82,6 +82,12 @@ const ActionX& Actions::operator[](const std::string& name) const { return *iter; } +bool Actions::has(const std::string& name) const { + const auto iter = std::find_if( this->actions.begin(), this->actions.end(), [&name](const ActionX& action) { return action.name() == name; }); + return (iter != this->actions.end()); +} + + const ActionX& Actions::operator[](std::size_t index) const { return this->actions[index]; }