xref: /openbmc/dbus-sensors/src/leakdetector/LeakEvents.hpp (revision 15dde8641baa1cb902d17f9857effb081e384944)
1 #pragma once
2 
3 #include <sdbusplus/async.hpp>
4 #include <sdbusplus/message/native_types.hpp>
5 #include <xyz/openbmc_project/State/Leak/Detector/client.hpp>
6 
7 #include <map>
8 #include <string>
9 #include <tuple>
10 
11 namespace leak
12 {
13 
14 namespace config
15 {
16 enum class DetectorLevel;
17 }
18 
19 using DetectorStateIntf =
20     sdbusplus::client::xyz::openbmc_project::state::leak::Detector<>;
21 
22 class Events
23 {
24   public:
25     Events() = delete;
26 
Events(sdbusplus::async::context & ctx)27     explicit Events(sdbusplus::async::context& ctx) : ctx(ctx) {}
28 
29     auto generateLeakEvent(sdbusplus::message::object_path detectorPath,
30                            DetectorStateIntf::DetectorState state,
31                            config::DetectorLevel level)
32         -> sdbusplus::async::task<>;
33 
34   private:
35     /** @brief Map type for event name to log event object path */
36     using event_key_t = std::tuple<std::string, config::DetectorLevel>;
37     using event_map_t = std::map<event_key_t, sdbusplus::message::object_path>;
38 
39     sdbusplus::async::context& ctx;
40     event_map_t pendingEvents;
41 };
42 
43 } // namespace leak
44