regulators: Add Services to ActionEnvironment
Add Services& services to the ActionEnvironment constructor.
Add Services& getServices() to the ActionEnvironment class.
Add Services& services to the ActionEnvironment class.
Update the ActionEnvironment test for the new getServices() method.
Update classes that create an ActionEnvironment.
Update all affected testcases that create an ActionEnvironment.
Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I12ac9f301746965aa282b69432a71ad525739c9e
diff --git a/phosphor-regulators/src/actions/action_environment.hpp b/phosphor-regulators/src/actions/action_environment.hpp
index ce06aff..bfd1b37 100644
--- a/phosphor-regulators/src/actions/action_environment.hpp
+++ b/phosphor-regulators/src/actions/action_environment.hpp
@@ -17,6 +17,7 @@
#include "id_map.hpp"
#include "pmbus_utils.hpp"
+#include "services.hpp"
#include <cstddef> // for size_t
#include <optional>
@@ -64,11 +65,12 @@
*
* @param idMap mapping from IDs to the associated Device/Rule objects
* @param deviceID current device ID
+ * @param services system services like error logging and the journal
*/
- explicit ActionEnvironment(const IDMap& idMap,
- const std::string& deviceID) :
+ explicit ActionEnvironment(const IDMap& idMap, const std::string& deviceID,
+ Services& services) :
idMap{idMap},
- deviceID{deviceID}
+ deviceID{deviceID}, services{services}
{
}
@@ -154,6 +156,16 @@
}
/**
+ * Returns the services in this action environment.
+ *
+ * @return system services
+ */
+ Services& getServices() const
+ {
+ return services;
+ }
+
+ /**
* Returns the current volts value, if set.
*
* @return current volts value
@@ -216,6 +228,11 @@
std::string deviceID{};
/**
+ * System services like error logging and the journal.
+ */
+ Services& services;
+
+ /**
* Current volts value (if set).
*/
std::optional<double> volts{};