blob: b2bdc1df20f384c0a327226a1dac7d53104c286a [file] [log] [blame]
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01001#pragma once
2
Cezary Zwolaka4e67612021-02-18 13:16:16 +01003#include "interfaces/json_storage.hpp"
Wludzik, Jozef1477fe62021-01-02 11:56:10 +01004#include "interfaces/threshold.hpp"
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01005#include "interfaces/trigger.hpp"
6#include "interfaces/trigger_manager.hpp"
7#include "interfaces/trigger_types.hpp"
8
9#include <boost/asio/io_context.hpp>
10#include <sdbusplus/asio/object_server.hpp>
11
12#include <memory>
13
14class Trigger : public interfaces::Trigger
15{
16 public:
17 Trigger(
18 boost::asio::io_context& ioc,
19 const std::shared_ptr<sdbusplus::asio::object_server>& objServer,
20 const std::string& name, const bool isDiscrete, const bool logToJournal,
21 const bool logToRedfish, const bool updateReport,
22 const std::vector<
23 std::pair<sdbusplus::message::object_path, std::string>>& sensorsIn,
24 const std::vector<std::string>& reportNames,
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010025 const TriggerThresholdParams& thresholdParams,
26 std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholds,
Cezary Zwolaka4e67612021-02-18 13:16:16 +010027 interfaces::TriggerManager& triggerManager,
28 interfaces::JsonStorage& triggerStorage);
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010029
30 Trigger(const Trigger&) = delete;
31 Trigger(Trigger&&) = delete;
32 Trigger& operator=(const Trigger&) = delete;
33 Trigger& operator=(Trigger&&) = delete;
34
35 std::string getName() const override
36 {
37 return name;
38 }
39
40 std::string getPath() const override
41 {
42 return path;
43 }
44
Cezary Zwolaka4e67612021-02-18 13:16:16 +010045 bool storeConfiguration() const;
46
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010047 private:
48 const std::string name;
Cezary Zwolaka4e67612021-02-18 13:16:16 +010049 bool isDiscrete;
50 bool logToJournal;
51 bool logToRedfish;
52 bool updateReport;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010053 const std::string path;
Cezary Zwolaka4e67612021-02-18 13:16:16 +010054 bool persistent = false;
55 TriggerSensors sensors;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010056 std::vector<std::string> reportNames;
57 TriggerThresholdParams thresholdParams;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010058 std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface;
59 std::unique_ptr<sdbusplus::asio::dbus_interface> triggerIface;
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010060 std::vector<std::shared_ptr<interfaces::Threshold>> thresholds;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010061
Cezary Zwolaka4e67612021-02-18 13:16:16 +010062 interfaces::JsonStorage::FilePath fileName;
63 interfaces::JsonStorage& triggerStorage;
64
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010065 public:
66 static constexpr const char* triggerIfaceName =
67 "xyz.openbmc_project.Telemetry.Trigger";
68 static constexpr const char* triggerDir =
69 "/xyz/openbmc_project/Telemetry/Triggers/";
70 static constexpr const char* deleteIfaceName =
71 "xyz.openbmc_project.Object.Delete";
Cezary Zwolaka4e67612021-02-18 13:16:16 +010072 static constexpr size_t triggerVersion = 0;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010073};