Refactor singleton and filesystem path handling
- Remove singleton PostCodeDataHolder. It only contained a single int
which could easily be held inside the main PostCode class instead.
- Simplify D-Bus match construction by using predefined
PropertiesChanged rule.
- Remove unnecessary PostCode members which were just copies of const
strings.
- Refactor some filesystem path construction/handling to simplify code.
Tested:
Rebooted host a few times and observed that correct POST code history is
still populated in Redfish.
Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Change-Id: Ifd61751807da704eaf2a64dac34ca708fd28c872
diff --git a/src/main.cpp b/src/main.cpp
index 98e09fb..6d53629 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -19,12 +19,10 @@
int main(int argc, char* argv[])
{
- PostCodeDataHolder& postcodeDataHolderObj =
- PostCodeDataHolder::getInstance();
-
int arg;
int optIndex = 0;
int ret = 0;
+ int node = 0;
std::string intfName;
@@ -36,7 +34,7 @@
switch (arg)
{
case 'h':
- postcodeDataHolderObj.node = std::stoi(optarg);
+ node = std::stoi(optarg);
break;
default:
break;
@@ -59,15 +57,14 @@
sdbusplus::bus_t bus = sdbusplus::bus::new_default();
- std::string dbusObjName =
- DBUS_OBJECT_NAME + std::to_string(postcodeDataHolderObj.node);
+ std::string dbusObjName = DBUS_OBJECT_NAME + std::to_string(node);
sdbusplus::server::manager_t m{bus, dbusObjName.c_str()};
- intfName = DBUS_INTF_NAME + std::to_string(postcodeDataHolderObj.node);
+ intfName = DBUS_INTF_NAME + std::to_string(node);
bus.request_name(intfName.c_str());
- PostCode postCode{bus, dbusObjName.c_str(), eventP};
+ PostCode postCode{bus, dbusObjName.c_str(), node};
try
{