control: Update config loading
Change the method used to load objects' JSON configuration where a list
of arguments specific to the object's class is given. This allows each
class to be constructed with its specific set of required arguments.
With this change, the zones require a pointer to their manager object
along with a reference to the event loop for their increment and
decrement timers. The manager object stores the cache for all zones,
each zone needs a pointer to its manager to be able to provide access
to that cache.
With the change in how the objects are created from their JSON
configuration files, loading the information into the YAML based
ZoneDefinitions structure is no longer needed.
Change-Id: I4f70cbeb3a708b985ca01a1f3df14ad78da053fb
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/zone.hpp b/control/json/zone.hpp
index 3ae8139..5256018 100644
--- a/control/json/zone.hpp
+++ b/control/json/zone.hpp
@@ -21,6 +21,7 @@
#include <nlohmann/json.hpp>
#include <sdbusplus/bus.hpp>
+#include <sdeventplus/event.hpp>
#include <any>
#include <functional>
@@ -30,6 +31,8 @@
namespace phosphor::fan::control::json
{
+class Manager;
+
using json = nlohmann::json;
/* Extend the Control::ThermalMode interface */
@@ -69,10 +72,13 @@
* Constructor
* Parses and populates a zone from JSON object data
*
- * @param[in] bus - sdbusplus bus object
* @param[in] jsonObj - JSON object
+ * @param[in] bus - sdbusplus bus object
+ * @param[in] event - sdeventplus event loop
+ * @param[in] mgr - Manager of this zone
*/
- Zone(sdbusplus::bus::bus& bus, const json& jsonObj);
+ Zone(const json& jsonObj, sdbusplus::bus::bus& bus,
+ const sdeventplus::Event& event, Manager* mgr);
/**
* @brief Get the default ceiling
@@ -156,6 +162,16 @@
};
/**
+ * @brief Get the manager of the zone
+ *
+ * @return - The manager of the zone
+ */
+ inline auto* getManager() const
+ {
+ return _manager;
+ }
+
+ /**
* @brief Add a fan object to the zone
*
* @param[in] fan - Unique pointer to a fan object that will be moved into
@@ -308,6 +324,9 @@
}
private:
+ /* The zone's manager */
+ Manager* _manager;
+
/* The zone's default ceiling value for fans */
uint64_t _defaultCeiling;