NVMeContext: Improve encapsulation of state
Consolidate NVMe MI MCTP message exchange and data parsing in the
NVMeContext implementation, and prevent NVMeSensorMain reaching into
internal details of NVMeContext when adding new sensors.
Previously message data parsing was intermixed with the MCTP message
handler implementation. Instead, make the MCTP message handler simply
dispatch the message buffer to the appropriate context instance.
Refactoring the code in this way makes it easier to later extract a base
class from the NVMeContext implementation.
Change-Id: I77bdfb703fd3da43186994d7b306076bd092afcf
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/src/NVMeSensorMain.cpp b/src/NVMeSensorMain.cpp
index 4c6804e..d744ece 100644
--- a/src/NVMeSensorMain.cpp
+++ b/src/NVMeSensorMain.cpp
@@ -136,7 +136,7 @@
objectServer, io, dbusConnection, sensorName,
std::move(sensorThresholds), interfacePath, busNumber);
- context->sensors.emplace_back(sensorPtr);
+ context->addSensor(sensorPtr);
}
for (const auto& [_, context] : nvmeDeviceMap)
{