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/src/system.cpp b/src/system.cpp
index c0713a6..a838577 100644
--- a/src/system.cpp
+++ b/src/system.cpp
@@ -133,7 +133,7 @@
if (std::find_if(tempS.begin(), tempS.end(),
[](char ch) { return !isprint(ch); }) != tempS.end())
{
- std::ofstream smbiosFile(mdrType2File, std::ios_base::trunc);
+ std::ofstream smbiosFile(smbiosFilePath, std::ios_base::trunc);
if (!smbiosFile.good())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -149,7 +149,7 @@
}
result = tempS;
- setProperty(bus, biosActiveObjPath, biosVersionIntf, biosVersionProp,
+ setProperty(*bus, biosActiveObjPath, biosVersionIntf, biosVersionProp,
result);
}
lg2::info("VERSION INFO - BIOS - {VER}", "VER", result);