control: Delete a parameter when nullopt is used

This commit changes the Manager::setParameter function to take a
std::optional.  When std::nullopt is passed in, the parameter is
deleted.  This removes the need for a separate deleteParameter function
and simplifies a code path that uses it.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ia32bc0e977245bd7d06b8d12c0cdfd79b981e4ba
diff --git a/control/json/actions/set_parameter_from_group_max.cpp b/control/json/actions/set_parameter_from_group_max.cpp
index 42b5c3c..ae5b31d 100644
--- a/control/json/actions/set_parameter_from_group_max.cpp
+++ b/control/json/actions/set_parameter_from_group_max.cpp
@@ -112,14 +112,7 @@
         }
     }
 
-    if (max)
-    {
-        Manager::setParameter(_name, *max);
-    }
-    else
-    {
-        Manager::deleteParameter(_name);
-    }
+    Manager::setParameter(_name, max);
 }
 
 void SetParameterFromGroupMax::setParameterName(const json& jsonObj)
diff --git a/control/json/manager.hpp b/control/json/manager.hpp
index cc68deb..e449145 100644
--- a/control/json/manager.hpp
+++ b/control/json/manager.hpp
@@ -463,20 +463,34 @@
     /**
      * @brief Sets a value in the parameter map.
      *
+     * If it's a std::nullopt, it will be deleted instead.
+     *
      * @param[in] name - The parameter name
      * @param[in] value - The parameter value
      */
     static void setParameter(const std::string& name,
-                             const PropertyVariantType& value)
+                             const std::optional<PropertyVariantType>& value)
     {
-        auto it = _parameters.find(name);
-        auto changed = (it == _parameters.end()) ||
-                       ((it != _parameters.end()) && it->second != value);
-        _parameters[name] = value;
-
-        if (changed)
+        if (value)
         {
-            runParameterActions(name);
+            auto it = _parameters.find(name);
+            auto changed = (it == _parameters.end()) ||
+                           ((it != _parameters.end()) && it->second != *value);
+            _parameters[name] = *value;
+
+            if (changed)
+            {
+                runParameterActions(name);
+            }
+        }
+        else
+        {
+            size_t deleted = _parameters.erase(name);
+
+            if (deleted)
+            {
+                runParameterActions(name);
+            }
         }
     }
 
@@ -500,21 +514,6 @@
     }
 
     /**
-     * @brief Deletes a parameter from the parameter map
-     *
-     * @param[in] name - The parameter name
-     */
-    static void deleteParameter(const std::string& name)
-    {
-        size_t deleted = _parameters.erase(name);
-
-        if (deleted)
-        {
-            runParameterActions(name);
-        }
-    }
-
-    /**
      * @brief Runs the actions registered to a parameter
      *        trigger with this name.
      *