Attach sdevent mainloop to dbus

Switch from sd_bus process to sd_event run so that sd event
handlers are invoked.

Change-Id: If7c1f046f30cc845c6e9fcc72eb99c5bdfb36052
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/src/main.cpp b/src/main.cpp
index 00d7200..79c4062 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -13,27 +13,37 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include <sdbusplus/bus.hpp>
+#include "sdbusplus.hpp"
 #include "generated.hpp"
 #include "monitor.hpp"
 
+using namespace phosphor::dbus::monitoring;
+
+struct Loop
+{
+    /** @brief indefinitely process dbus traffic. */
+    static void run()
+    {
+        auto& bus = SDBusPlus::getBus();
+        auto& event = SDEvent::getEvent();
+        event.attach(bus);
+        event.loop();
+    }
+};
+
 int main(void)
 {
-    auto bus = sdbusplus::bus::new_default();
-
-    phosphor::dbus::monitoring::Monitor monitor(bus);
-
-    for (auto& watch : phosphor::dbus::monitoring::ConfigPropertyWatches::get())
+    for (auto& watch : ConfigPropertyWatches::get())
     {
         watch->start();
     }
 
-    // Keep application running
-    while (true)
+    for (auto& watch : ConfigPropertyWatches::get())
     {
-        bus.process_discard();
-        bus.wait();
+        watch->callback();
     }
 
+    Loop::run();
+
     return -1;
 }
diff --git a/src/sdbusplus.hpp b/src/sdbusplus.hpp
index 8afb8b5..aba5a36 100644
--- a/src/sdbusplus.hpp
+++ b/src/sdbusplus.hpp
@@ -4,6 +4,8 @@
 #include <sdbusplus/message.hpp>
 #include <sdbusplus/bus/match.hpp>
 
+struct Loop;
+
 namespace phosphor
 {
 namespace dbus
@@ -101,6 +103,8 @@
                     match,
                     callback);
         }
+
+        friend Loop;
 };
 
 } // namespace monitoring
diff --git a/src/sdevent.hpp b/src/sdevent.hpp
index be8b510..dc912c1 100644
--- a/src/sdevent.hpp
+++ b/src/sdevent.hpp
@@ -3,6 +3,8 @@
 #include "sdevent/event.hpp"
 #include "sdevent/timer.hpp"
 
+struct Loop;
+
 namespace phosphor
 {
 namespace dbus
@@ -29,6 +31,8 @@
         {
             return getEvent().now();
         }
+
+        friend Loop;
 };
 
 /** @class SDEventTimer