Add watch on D-Bus object paths

Clients specify the object paths to watch in the config yaml.

Example yaml file and parser changes are pushed in separate
patch

Callbacks are invoked based on the watch type created i.e
interfaceadded/interfaceremoved

Change-Id: Icb7b9bf4c072f8b8df33747c813a1f07b61de637
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
diff --git a/src/pathwatchimpl.hpp b/src/pathwatchimpl.hpp
new file mode 100644
index 0000000..6be0f50
--- /dev/null
+++ b/src/pathwatchimpl.hpp
@@ -0,0 +1,53 @@
+/**
+ * @file PathWatchimpl.hpp
+ * @brief Add interfaces added watch for the specified path
+ *
+ */
+#pragma once
+
+#include <sdbusplus/message.hpp>
+#include <sdbusplus/bus/match.hpp>
+#include <vector>
+#include "callback.hpp"
+#include "data_types.hpp"
+#include "pathwatch.hpp"
+
+namespace phosphor
+{
+namespace dbus
+{
+namespace monitoring
+{
+
+template <typename DBusInterfaceType> void PathWatch<DBusInterfaceType>::start()
+{
+    if (alreadyRan)
+    {
+        return;
+    }
+    // Watch for new interfaces added on this path.
+    DBusInterfaceType::addMatch(
+        sdbusplus::bus::match::rules::interfacesAdded(objectPath),
+        [this](auto& msg)
+        // *INDENT-OFF*
+        { (this->cb)(Context::SIGNAL, msg); });
+    // *INDENT-ON*
+
+    alreadyRan = true;
+}
+
+template <typename DBusInterfaceType>
+void PathWatch<DBusInterfaceType>::callback(Context ctx)
+{
+    (this->cb)(ctx);
+}
+
+template <typename DBusInterfaceType>
+void PathWatch<DBusInterfaceType>::callback(Context ctx,
+                                            sdbusplus::message::message& msg)
+{
+    (this->cb)(ctx, msg);
+}
+} // namespace monitoring
+} // namespace dbus
+} // namespace phosphor