control: Add all fan functionality to JSON fan object

In transitioning to JSON based configuration support, the objects
created based on the JSON will eventually replace the similar objects
used for YAML based configurations. This adds all the functionality from
the current fan class used for YAML configs to the fan class used for
JSON configs.

Change-Id: I50bdd218fc964a4b75126643727f1c3f4d27966b
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/fan.hpp b/control/json/fan.hpp
index d0f7a06..90bb13a 100644
--- a/control/json/fan.hpp
+++ b/control/json/fan.hpp
@@ -20,6 +20,8 @@
 #include <nlohmann/json.hpp>
 #include <sdbusplus/bus.hpp>
 
+#include <map>
+
 namespace phosphor::fan::control::json
 {
 
@@ -90,15 +92,26 @@
         return _interface;
     }
 
-  private:
-    /* The zone this fan belongs to */
-    std::string _zone;
+    /**
+     * @brief Get the current fan target
+     *
+     * @return - The current target of the fan
+     */
+    inline auto getTarget() const
+    {
+        return _target;
+    }
 
     /**
-     * Sensors containing the `Target` property on
-     * dbus that make up the fan
+     * Sets the target value on all contained sensors
+     *
+     * @param[in] target - The value to set
      */
-    std::vector<std::string> _sensors;
+    void setTarget(uint64_t target);
+
+  private:
+    /* The sdbusplus bus object */
+    sdbusplus::bus::bus& _bus;
 
     /**
      * Interface containing the `Target` property
@@ -106,14 +119,26 @@
      */
     std::string _interface;
 
+    /* Target for this fan */
+    uint64_t _target;
+
     /**
-     * @brief Parse and set the fan's zone
+     * Map of sensors containing the `Target` property on
+     * dbus to the service providing them that make up the fan
+     */
+    std::map<std::string, std::string> _sensors;
+
+    /* The zone this fan belongs to */
+    std::string _zone;
+
+    /**
+     * @brief Parse and set the fan's sensor interface
      *
      * @param[in] jsonObj - JSON object for the fan
      *
-     * Sets the zone this fan is included in.
+     * Sets the sensor interface to use when setting the `Target` property
      */
-    void setZone(const json& jsonObj);
+    void setInterface(const json& jsonObj);
 
     /**
      * @brief Parse and set the fan's sensor list
@@ -126,13 +151,13 @@
     void setSensors(const json& jsonObj);
 
     /**
-     * @brief Parse and set the fan's sensor interface
+     * @brief Parse and set the fan's zone
      *
      * @param[in] jsonObj - JSON object for the fan
      *
-     * Sets the sensor interface to use when setting the `Target` property
+     * Sets the zone this fan is included in.
      */
-    void setInterface(const json& jsonObj);
+    void setZone(const json& jsonObj);
 };
 
 } // namespace phosphor::fan::control::json