blob: 6187486591ab64004a4c5a1226960d8084d9ff26 [file] [log] [blame]
Jayanth Othayothd02153c2017-07-02 22:29:42 -05001#pragma once
2
3#include <map>
4
5#include "dump_utils.hpp"
6#include "watch.hpp"
Jayanth Othayothbf6ec602017-08-28 01:48:49 -05007#include "config.h"
Jayanth Othayothd02153c2017-07-02 22:29:42 -05008
9namespace phosphor
10{
11namespace dump
12{
13namespace core
14{
Jayanth Othayothbf6ec602017-08-28 01:48:49 -050015using Watch = phosphor::dump::inotify::Watch;
Jayanth Othayothd02153c2017-07-02 22:29:42 -050016using UserMap = phosphor::dump::inotify::UserMap;
17
Jayanth Othayothbf6ec602017-08-28 01:48:49 -050018/** @class Manager
19 * @brief OpenBMC Core manager implementation.
Jayanth Othayothd3273ea2017-07-12 22:55:32 -050020 */
Jayanth Othayothbf6ec602017-08-28 01:48:49 -050021class Manager
22{
23 public:
24 Manager() = delete;
25 Manager(const Manager&) = default;
26 Manager& operator=(const Manager&) = delete;
27 Manager(Manager&&) = delete;
28 Manager& operator=(Manager&&) = delete;
29 virtual ~Manager() = default;
Jayanth Othayothd3273ea2017-07-12 22:55:32 -050030
Jayanth Othayothbf6ec602017-08-28 01:48:49 -050031 /** @brief Constructor to create core watch object.
32 * @param[in] event - Dump manager sd_event loop.
33 */
34 Manager(const EventPtr& event) :
35 eventLoop(event.get()),
36 coreWatch(eventLoop,
37 IN_NONBLOCK,
38 IN_CLOSE_WRITE,
39 EPOLLIN,
40 CORE_FILE_DIR,
41 std::bind(
42 std::mem_fn(
43 &phosphor::dump::core::Manager::watchCallback),
44 this, std::placeholders::_1))
45 {}
46
47 private:
48 /** @brief Helper function for initiating dump request using
49 * D-bus internal create interface.
50 * @param [in] files - Core files list
51 */
52 void createHelper(const std::vector<std::string>& files);
53
54
55 /** @brief Implementation of core watch call back
56 * @param [in] fileInfo - map of file info path:event
57 */
58 void watchCallback(const UserMap& fileInfo);
59
60 /** @brief sdbusplus Dump event loop */
61 EventPtr eventLoop;
62
63 /** @brief Core watch object */
64 Watch coreWatch;
65};
66
Jayanth Othayothd02153c2017-07-02 22:29:42 -050067} // namepsace core
68} // namespace dump
69} // namespace phosphor