regulators: Add remaining properties to Rail class
Enhance the C++ Rail class by adding the remaining properties from the
JSON config file:
* configuration
* sensor_monitoring
See rail.md for more information.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I9c2e46fe8bec39454b0ad3f703eee3b497efd82a
diff --git a/phosphor-regulators/src/rail.hpp b/phosphor-regulators/src/rail.hpp
index 247e8ee..19e8a58 100644
--- a/phosphor-regulators/src/rail.hpp
+++ b/phosphor-regulators/src/rail.hpp
@@ -15,7 +15,12 @@
*/
#pragma once
+#include "configuration.hpp"
+#include "sensor_monitoring.hpp"
+
+#include <memory>
#include <string>
+#include <utility>
namespace phosphor::power::regulators
{
@@ -43,12 +48,31 @@
* Constructor.
*
* @param id unique rail ID
+ * @param configuration configuration changes to apply to this rail, if any
+ * @param sensorMonitoring sensor monitoring for this rail, if any
*/
- explicit Rail(const std::string& id) : id{id}
+ explicit Rail(
+ const std::string& id,
+ std::unique_ptr<Configuration> configuration = nullptr,
+ std::unique_ptr<SensorMonitoring> sensorMonitoring = nullptr) :
+ id{id},
+ configuration{std::move(configuration)}, sensorMonitoring{std::move(
+ sensorMonitoring)}
{
}
/**
+ * Returns the configuration changes to apply to this rail, if any.
+ *
+ * @return Pointer to Configuration object. Will equal nullptr if no
+ * configuration changes are defined for this rail.
+ */
+ const std::unique_ptr<Configuration>& getConfiguration() const
+ {
+ return configuration;
+ }
+
+ /**
* Returns the unique ID of this rail.
*
* @return rail ID
@@ -58,11 +82,34 @@
return id;
}
+ /**
+ * Returns the sensor monitoring for this rail, if any.
+ *
+ * @return Pointer to SensorMonitoring object. Will equal nullptr if no
+ * sensor monitoring is defined for this rail.
+ */
+ const std::unique_ptr<SensorMonitoring>& getSensorMonitoring() const
+ {
+ return sensorMonitoring;
+ }
+
private:
/**
* Unique ID of this rail.
*/
const std::string id{};
+
+ /**
+ * Configuration changes to apply to this rail, if any. Set to nullptr if
+ * no configuration changes are defined for this rail.
+ */
+ std::unique_ptr<Configuration> configuration{};
+
+ /**
+ * Sensor monitoring for this rail, if any. Set to nullptr if no sensor
+ * monitoring is defined for this rail.
+ */
+ std::unique_ptr<SensorMonitoring> sensorMonitoring{};
};
} // namespace phosphor::power::regulators