blob: 52565826d1139065b08236388e14e27c13cff40d [file] [log] [blame]
Matthew Barth1febc282017-04-12 11:33:39 -05001#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include <sdbusplus/server.hpp>
5#include "events.hpp"
6
7namespace phosphor
8{
9namespace dbus
10{
11namespace monitoring
12{
13
14class Monitor
15{
16 public:
17 Monitor() = delete;
18 Monitor(const Monitor&) = delete;
19 Monitor(Monitor&&) = default;
20 Monitor& operator=(const Monitor&) = delete;
21 Monitor& operator=(Monitor&&) = default;
22 ~Monitor() = default;
23
24 explicit Monitor(sdbusplus::bus::bus& bus);
25
Matthew Barthe6af2332017-04-12 13:37:29 -050026 void processStart() noexcept;
27
28 void handleEvent(sdbusplus::message::message& msg,
29 const Event& event,
30 const std::tuple<std::vector<std::shared_ptr<Event>>,
31 std::vector<Action>>& eventDef);
32
Matthew Barth240bf332017-04-12 13:48:29 -050033 using eventArg = std::tuple<Monitor*,
34 const SignalEvent*,
35 const std::tuple<
36 std::vector<std::shared_ptr<Event>>,
37 std::vector<Action>>*>;
38
Matthew Barth1febc282017-04-12 11:33:39 -050039 private:
40 sdbusplus::bus::bus& bus;
41
Matthew Barthe6af2332017-04-12 13:37:29 -050042 static const std::vector<
43 std::tuple<std::vector<std::shared_ptr<Event>>,
44 std::vector<Action>>> events;
45
Matthew Barth240bf332017-04-12 13:48:29 -050046 std::vector<std::unique_ptr<eventArg>> eventArgs;
47
48 std::vector<sdbusplus::server::match::match> matches;
49
50 static int handleSignal(sd_bus_message* msg,
51 void* data,
52 sd_bus_error* err);
53
Matthew Barth1febc282017-04-12 11:33:39 -050054};
55
56} // namespace monitoring
57} // namespace dbus
58} // namespace phosphor