diff options
author | Jayanth Othayoth <ojayanth@in.ibm.com> | 2017-08-28 01:48:49 -0500 |
---|---|---|
committer | Jayanth Othayoth <ojayanth@in.ibm.com> | 2017-09-12 02:40:24 -0500 |
commit | bf6ec60041550272a231661fcc0d2b8a3c9dd6f1 (patch) | |
tree | 4b3b1db77561484c2cef17ac2d665d09b3d62a68 | |
parent | d7b95d5a03c72be167a449028f12bbf1869883ce (diff) | |
download | phosphor-debug-collector-bf6ec60041550272a231661fcc0d2b8a3c9dd6f1.tar.gz phosphor-debug-collector-bf6ec60041550272a231661fcc0d2b8a3c9dd6f1.zip |
Refactor core dump handling functions into core manager class
Change-Id: I700ecf517f26332c0a5e0de87c77cffd94f6bb9a
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
-rw-r--r-- | core_manager.cpp | 7 | ||||
-rw-r--r-- | core_manager.hpp | 60 | ||||
-rw-r--r-- | core_manager_main.cpp | 10 |
3 files changed, 51 insertions, 26 deletions
diff --git a/core_manager.cpp b/core_manager.cpp index eb6cef5..beddd89 100644 --- a/core_manager.cpp +++ b/core_manager.cpp @@ -12,13 +12,11 @@ namespace dump { namespace core { -namespace manager -{ using namespace phosphor::logging; using namespace std; -void watchCallback(const UserMap& fileInfo) +void Manager::watchCallback(const UserMap& fileInfo) { vector<string> files; @@ -55,7 +53,7 @@ void watchCallback(const UserMap& fileInfo) } } -void createHelper(const vector<string>& files) +void Manager::createHelper(const vector<string>& files) { constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper"; @@ -97,7 +95,6 @@ void createHelper(const vector<string>& files) b.call_noreply(m); } -} // namespace manager } // namespace core } // namespace dump } // namespace phosphor 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 dump { namespace core { -namespace manager +using Watch = phosphor::dump::inotify::Watch; +using UserMap = phosphor::dump::inotify::UserMap; + +/** @class Manager + * @brief OpenBMC Core manager implementation. + */ +class Manager { + public: + Manager() = delete; + Manager(const Manager&) = default; + Manager& operator=(const Manager&) = delete; + Manager(Manager&&) = delete; + Manager& operator=(Manager&&) = delete; + virtual ~Manager() = default; -using UserMap = phosphor::dump::inotify::UserMap; + /** @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)) + {} -/** @brief Implementation of core watch call back - * @param [in] fileInfo - map of file info path:event - */ -void watchCallback(const UserMap& fileInfo); + 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 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); -} // namespace manager + /** @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 diff --git a/core_manager_main.cpp b/core_manager_main.cpp index 6f7383f..1f9d195 100644 --- a/core_manager_main.cpp +++ b/core_manager_main.cpp @@ -27,15 +27,7 @@ int main(int argc, char* argv[]) try { - phosphor::dump::inotify::Watch watch( - eventP, - IN_NONBLOCK, - IN_CLOSE_WRITE, - EPOLLIN, - CORE_FILE_DIR, - std::bind( - &phosphor::dump::core::manager::watchCallback, - std::placeholders::_1)); + phosphor::dump::core::Manager manager(eventP); auto rc = sd_event_loop(eventP.get()); if (rc < 0) |