regs: Get JSON configuration data filename from dbus
Retrieve the JSON configuration data filename from the service on dbus
hosting the predefined path, interface and system identifier property.
The system identifier property's value is used as the direct JSON
configuration data filename with the `.json` extension added.
Tested:
A string representing the filename is retrieved from dbus
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Change-Id: Ib9a5227439045cd027125e9dd3ead377be19acba
diff --git a/phosphor-regulators/src/manager.hpp b/phosphor-regulators/src/manager.hpp
index ab51a1d..eb0cef8 100644
--- a/phosphor-regulators/src/manager.hpp
+++ b/phosphor-regulators/src/manager.hpp
@@ -7,6 +7,8 @@
#include <sdeventplus/source/signal.hpp>
#include <sdeventplus/utility/timer.hpp>
+#include <algorithm>
+
namespace phosphor::power::regulators
{
@@ -83,6 +85,34 @@
* List of event timers
*/
std::vector<Timer> timers;
+
+ /**
+ * JSON configuration data filename
+ */
+ std::string fileName;
+
+ /**
+ * @brief Set the JSON configuration data filename
+ *
+ * @param[in] fName = filename without `.json` extension
+ */
+ inline void setFileName(const std::string& fName)
+ {
+ fileName = fName;
+ if (!fileName.empty())
+ {
+ // Replace all spaces with underscores
+ std::replace(fileName.begin(), fileName.end(), ' ', '_');
+ fileName.append(".json");
+ }
+ };
+
+ /**
+ * @brief Get the JSON configuration data filename from dbus
+ *
+ * @return - JSON configuration data filename
+ */
+ const std::string getFileNameDbus();
};
} // namespace phosphor::power::regulators