Refactor MDRV2 class to allow more than one
Refactored the main MDRV2 class to allow more than one object of this
class to exist at the same time. All hardcoded paths have been made
parameters to the constructor, so that they can be varied at runtime as
needed, to avoid overlap.
Also did some necessary internal cleanups to facilitate this.
Tested: Created multiple copies of the MDRV2 object at the same time,
it worked, all appeared on D-Bus, under distinct object paths and
inventory paths. Destructed the MDRV2 object, it disappeared from
D-Bus, constructed it again, it came back.
https://gist.github.com/Krellan/6930bc2ed1ac16b93afcc3a12c02e545
Change-Id: Icd1ebf50086b526cf0cff149eb8ddc59da78f0a9
Signed-off-by: Josh Lehan <krellan@google.com>
diff --git a/include/smbios_mdrv2.hpp b/include/smbios_mdrv2.hpp
index e77abf4..a730061 100644
--- a/include/smbios_mdrv2.hpp
+++ b/include/smbios_mdrv2.hpp
@@ -19,9 +19,9 @@
#include <phosphor-logging/elog-errors.hpp>
#include <array>
+#include <string>
-static constexpr const char* mdrType2File = "/var/lib/smbios/smbios2";
-static constexpr const char* smbiosPath = "/var/lib/smbios";
+static constexpr const char* mdrDefaultFile = "/var/lib/smbios/smbios2";
static constexpr uint16_t mdrSMBIOSSize = 32 * 1024;
@@ -157,17 +157,13 @@
uint64_t structTableAddr;
} __attribute__((packed));
-static constexpr const char* cpuPath =
- "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu";
+static constexpr const char* cpuSuffix = "/chassis/motherboard/cpu";
-static constexpr const char* dimmPath =
- "/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm";
+static constexpr const char* dimmSuffix = "/chassis/motherboard/dimm";
-static constexpr const char* pciePath =
- "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot";
+static constexpr const char* pcieSuffix = "/chassis/motherboard/pcieslot";
-static constexpr const char* systemPath =
- "/xyz/openbmc_project/inventory/system/chassis/motherboard/bios";
+static constexpr const char* systemSuffix = "/chassis/motherboard/bios";
constexpr std::array<SMBIOSVersion, 3> supportedSMBIOSVersions{
SMBIOSVersion{3, 2}, SMBIOSVersion{3, 3}, SMBIOSVersion{3, 5}};