regulators: ActionEnvironment enhancements

Define a new struct named SensorReading.  This will be used the store the
value read when PMBusReadSensorAction::execute() is called.

Add a new data member sensorReadings.
This will hold the sensor readings that are obtained

Add a new method addSensorReading.
It add the specified SensorReading to the sensorReadings vector.

Add a new method getSensorReadings.
This will be called by the SensorMonitoring object.

Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I91076227498712750187d354b76faa2d95e33aac
diff --git a/phosphor-regulators/src/actions/action_environment.hpp b/phosphor-regulators/src/actions/action_environment.hpp
index f94345a..ce06aff 100644
--- a/phosphor-regulators/src/actions/action_environment.hpp
+++ b/phosphor-regulators/src/actions/action_environment.hpp
@@ -16,11 +16,13 @@
 #pragma once
 
 #include "id_map.hpp"
+#include "pmbus_utils.hpp"
 
 #include <cstddef> // for size_t
 #include <optional>
 #include <stdexcept>
 #include <string>
+#include <vector>
 
 namespace phosphor::power::regulators
 {
@@ -39,6 +41,7 @@
  *   - current volts value (if any)
  *   - mapping from device and rule IDs to the corresponding objects
  *   - rule call stack depth (to detect infinite recursion)
+ *   - sensor readings
  */
 class ActionEnvironment
 {
@@ -70,6 +73,16 @@
     }
 
     /**
+     * Adds the specified sensor reading to this action environment.
+     *
+     * @param reading sensor reading from a regulator rail
+     */
+    void addSensorReading(const pmbus_utils::SensorReading& reading)
+    {
+        sensorReadings.emplace_back(reading);
+    }
+
+    /**
      * Decrements the rule call stack depth by one.
      *
      * Should be used when a call to a rule returns.  Does nothing if depth is
@@ -131,6 +144,16 @@
     }
 
     /**
+     * Returns the sensor readings stored in this action environment.
+     *
+     * @return sensor readings
+     */
+    const std::vector<pmbus_utils::SensorReading>& getSensorReadings() const
+    {
+        return sensorReadings;
+    }
+
+    /**
      * Returns the current volts value, if set.
      *
      * @return current volts value
@@ -201,6 +224,11 @@
      * Rule call stack depth.
      */
     size_t ruleDepth{0};
+
+    /**
+     * Sensor readings for a single regulator rail.
+     */
+    std::vector<pmbus_utils::SensorReading> sensorReadings{};
 };
 
 } // namespace phosphor::power::regulators