Refactor core dump handling functions into core manager class

Change-Id: I700ecf517f26332c0a5e0de87c77cffd94f6bb9a
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
diff --git a/core_manager.hpp b/core_manager.hpp
index 84818e5..6187486 100644
--- a/core_manager.hpp
+++ b/core_manager.hpp
@@ -4,6 +4,7 @@
 
 #include "dump_utils.hpp"
 #include "watch.hpp"
+#include "config.h"
 
 namespace phosphor
 {
@@ -11,23 +12,58 @@
 {
 namespace core
 {
-namespace manager
-{
-
+using Watch = phosphor::dump::inotify::Watch;
 using UserMap = phosphor::dump::inotify::UserMap;
 
-/** @brief Implementation of core watch call back
-  * @param [in] fileInfo - map of file info  path:event
-  */
-void watchCallback(const UserMap& fileInfo);
-
-/** @brief Helper function for initiating dump request using
- *         D-bus internal create interface.
- *  @param [in] files - Core files list
+/** @class Manager
+ *  @brief OpenBMC Core manager implementation.
  */
-void createHelper(const std::vector<std::string>& files);
+class Manager
+{
+    public:
+        Manager() = delete;
+        Manager(const Manager&) = default;
+        Manager& operator=(const Manager&) = delete;
+        Manager(Manager&&) = delete;
+        Manager& operator=(Manager&&) = delete;
+        virtual ~Manager() = default;
 
-} // namespace manager
+        /** @brief Constructor to create core watch object.
+         *  @param[in] event - Dump manager sd_event loop.
+         */
+        Manager(const EventPtr& event) :
+            eventLoop(event.get()),
+            coreWatch(eventLoop,
+                      IN_NONBLOCK,
+                      IN_CLOSE_WRITE,
+                      EPOLLIN,
+                      CORE_FILE_DIR,
+                      std::bind(
+                          std::mem_fn(
+                              &phosphor::dump::core::Manager::watchCallback),
+                          this, std::placeholders::_1))
+        {}
+
+    private:
+        /** @brief Helper function for initiating dump request using
+         *         D-bus internal create interface.
+         *  @param [in] files - Core files list
+         */
+        void createHelper(const std::vector<std::string>& files);
+
+
+        /** @brief Implementation of core watch call back
+         * @param [in] fileInfo - map of file info  path:event
+         */
+        void watchCallback(const UserMap& fileInfo);
+
+        /** @brief sdbusplus Dump event loop */
+        EventPtr eventLoop;
+
+        /** @brief Core watch object */
+        Watch coreWatch;
+};
+
 } // namepsace core
 } // namespace dump
 } // namespace phosphor