control:actions: Support adding zones to actions after creation

Allow adding zones, if not already included, on an action.

Change-Id: I27c6c8c4cd45522f343373b26279692043af3360
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/actions/action.hpp b/control/json/actions/action.hpp
index 93219af..58d79b2 100644
--- a/control/json/actions/action.hpp
+++ b/control/json/actions/action.hpp
@@ -24,6 +24,7 @@
 #include <nlohmann/json.hpp>
 #include <phosphor-logging/log.hpp>
 
+#include <algorithm>
 #include <functional>
 #include <iterator>
 #include <map>
@@ -144,6 +145,25 @@
     }
 
     /**
+     * @brief Add a zone to the list of zones the action is run against if its
+     * not already there
+     *
+     * @param[in] zone - Zone to add
+     */
+    virtual void addZone(Zone& zone)
+    {
+        auto itZone =
+            std::find_if(_zones.begin(), _zones.end(),
+                         [&zone](std::reference_wrapper<Zone>& z) {
+                             return z.get().getName() == zone.getName();
+                         });
+        if (itZone == _zones.end())
+        {
+            _zones.emplace_back(std::reference_wrapper<Zone>(zone));
+        }
+    }
+
+    /**
      * @brief Run the action
      *
      * Run the action function associated to the derived action object