Find a policy entry and create the Policy object

Find an entry in the policy table based on the error
log entry's properties, and create and save the
sdbusplus object for it.

Change-Id: Ifc09059169b5faedb4eae74a76d59847d7b2868b
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/manager.cpp b/manager.cpp
index 978d8b6..f09464a 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -15,6 +15,7 @@
  */
 #include "config.h"
 #include "manager.hpp"
+#include "policy_find.hpp"
 
 namespace ibm
 {
@@ -70,9 +71,45 @@
         const std::string& objectPath,
         const DbusPropertyMap& properties)
 {
-    //TODO
+
+#ifdef USE_POLICY_INTERFACE
+    createPolicyInterface(objectPath, properties);
+#endif
+
 }
 
+#ifdef USE_POLICY_INTERFACE
+void Manager::createPolicyInterface(
+        const std::string& objectPath,
+        const DbusPropertyMap& properties)
+{
+    auto values = policy::find(policies, properties);
+
+    auto object = std::make_shared<PolicyObject>(
+            bus, objectPath.c_str(), true);
+
+    object->eventID(std::get<policy::EIDField>(values));
+    object->description(std::get<policy::MsgField>(values));
+
+    object->emit_object_added();
+
+    auto id = getEntryID(objectPath);
+    auto entry = entries.find(id);
+
+    if (entry == entries.end())
+    {
+        InterfaceMap interfaces;
+        interfaces.emplace(InterfaceType::POLICY, object);
+        entries.emplace(id, interfaces);
+    }
+    else
+    {
+        entry->second.emplace(InterfaceType::POLICY, object);
+    }
+}
+#endif
+
+
 void Manager::interfaceAdded(sdbusplus::message::message& msg)
 {
     sdbusplus::message::object_path path;