Use unique_ptr for sd_event object wrapper

Convert the sd_event object wrapper from a shared_ptr to
a unique_ptr.  Requires a new header file.

Change-Id: I868a9e88ed93878c2e0bb12e58f8d3a604510da0
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 639d88e..17f5812 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -38,7 +38,7 @@
 
 
 Fan::Fan(sdbusplus::bus::bus& bus,
-         std::shared_ptr<sd_event>&  events,
+         phosphor::fan::event::EventPtr&  events,
          const FanDefinition& def) :
     _bus(bus),
     _name(std::get<fanNameField>(def)),
diff --git a/monitor/fan.hpp b/monitor/fan.hpp
index 910b4eb..8e7f86f 100644
--- a/monitor/fan.hpp
+++ b/monitor/fan.hpp
@@ -3,6 +3,7 @@
 #include <sdbusplus/bus.hpp>
 #include <tuple>
 #include <vector>
+#include "event.hpp"
 #include "tach_sensor.hpp"
 #include "types.hpp"
 
@@ -72,7 +73,7 @@
          * @param def - the fan definition structure
          */
         Fan(sdbusplus::bus::bus& bus,
-            std::shared_ptr<sd_event>& events,
+            phosphor::fan::event::EventPtr& events,
             const FanDefinition& def);
 
         /**
diff --git a/monitor/main.cpp b/monitor/main.cpp
index 6d51fbb..c10efb9 100644
--- a/monitor/main.cpp
+++ b/monitor/main.cpp
@@ -15,6 +15,7 @@
  */
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/bus.hpp>
+#include "event.hpp"
 #include "fan.hpp"
 #include "fan_defs.hpp"
 
@@ -22,16 +23,11 @@
 using namespace phosphor::logging;
 
 
-void EventDeleter(sd_event* event)
-{
-    sd_event_unref(event);
-}
-
 int main()
 {
     auto bus = sdbusplus::bus::new_default();
     sd_event* events = nullptr;
-    std::vector<std::unique_ptr<Fan>> fans;
+    std::vector<Fan> fans;
 
     auto r = sd_event_default(&events);
     if (r < 0)
@@ -41,7 +37,7 @@
         return -1;
     }
 
-    std::shared_ptr<sd_event> eventPtr{events, EventDeleter};
+    phosphor::fan::event::EventPtr eventPtr{events};
 
     //Attach the event object to the bus object so we can
     //handle both sd_events (for the timers) and dbus signals.
@@ -49,7 +45,7 @@
 
     for (const auto& fanDef : fanDefinitions)
     {
-        fans.emplace_back(std::make_unique<Fan>(bus, eventPtr, fanDef));
+        fans.emplace_back(bus, eventPtr, fanDef);
     }
 
     r = sd_event_loop(eventPtr.get());
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 806eed7..80eb974 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -85,7 +85,7 @@
                        const std::string& id,
                        bool hasTarget,
                        size_t timeout,
-                       std::shared_ptr<sd_event>& events) :
+                       phosphor::fan::event::EventPtr& events) :
     _bus(bus),
     _fan(fan),
     _name(FAN_SENSOR_PATH + id),
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index 7a65b64..84e02fe 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -3,6 +3,7 @@
 #include <chrono>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server.hpp>
+#include "event.hpp"
 #include "timer.hpp"
 
 namespace phosphor
@@ -54,7 +55,7 @@
                    const std::string& id,
                    bool hasTarget,
                    size_t timeout,
-                   std::shared_ptr<sd_event>& events);
+                   phosphor::fan::event::EventPtr& events);
 
         /**
          * @brief Returns the target speed value