sensormanager: use bus reference_wrapper over pointer

Switch the SensorManager class to use a `reference_wrapper` to the
sdbusplus connection rather than a raw pointer for code safety.
This has a side-effect of disabling the default constructor for the
class, which implicates using wrappers like `std::optional`.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I799d4564f0dbd9698951f0ec8e86a7272299ebf6
diff --git a/main.cpp b/main.cpp
index d823966..4539d83 100644
--- a/main.cpp
+++ b/main.cpp
@@ -45,6 +45,7 @@
 #include <list>
 #include <map>
 #include <memory>
+#include <optional>
 #include <unordered_map>
 #include <utility>
 #include <vector>
@@ -68,7 +69,7 @@
 /* The timers used by the PID loop */
 static std::vector<std::shared_ptr<boost::asio::steady_timer>> timers;
 /* The sensors build from configuration */
-static SensorManager mgmr;
+static std::optional<SensorManager> mgmr;
 } // namespace state
 
 } // namespace pid_control
@@ -162,7 +163,7 @@
 
     state::mgmr = buildSensors(sensorConfig, passiveBus, hostBus);
     state::zones =
-        buildZones(zoneConfig, zoneDetailsConfig, state::mgmr, modeControlBus);
+        buildZones(zoneConfig, zoneDetailsConfig, *state::mgmr, modeControlBus);
     // Set `logMaxCountPerSecond` to 20 will limit the number of logs output per
     // second in each zone. Using 20 here would limit the output rate to be no
     // larger than 100 per sec for most platforms as the number of zones are