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/include/NVMeContext.hpp b/include/NVMeContext.hpp
index f2d804a..7f24e17 100644
--- a/include/NVMeContext.hpp
+++ b/include/NVMeContext.hpp
@@ -8,20 +8,27 @@
 
 #include <memory>
 
-struct NVMeContext : std::enable_shared_from_this<NVMeContext>
+class NVMeContext : public std::enable_shared_from_this<NVMeContext>
 {
+  public:
     NVMeContext(boost::asio::io_service& io, int rootBus);
 
     virtual ~NVMeContext();
 
-    void pollNVMeDevices();
-    void close();
+    void addSensor(std::shared_ptr<NVMeSensor> sensor);
+    virtual void pollNVMeDevices();
+    virtual void close();
+    virtual void readAndProcessNVMeSensor();
+    virtual void processResponse(void* msg, size_t len);
 
+  private:
     boost::asio::deadline_timer scanTimer;
     int rootBus; // Root bus for this drive
     boost::asio::deadline_timer mctpResponseTimer;
     boost::asio::ip::tcp::socket nvmeSlaveSocket;
     std::list<std::shared_ptr<NVMeSensor>> sensors; // used as a poll queue
+
+    void readResponse();
 };
 
 using NVMEMap = boost::container::flat_map<int, std::shared_ptr<NVMeContext>>;