blob: 09b5dc885cd5730c68f3775d128e9a1b6aa65dc1 [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"
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +00007#include "types/trigger_types.hpp"
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01008
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:
Cezary Zwolak4416fce2021-03-17 03:21:06 +010017 Trigger(boost::asio::io_context& ioc,
18 const std::shared_ptr<sdbusplus::asio::object_server>& objServer,
19 const std::string& name, const bool isDiscrete,
20 const bool logToJournal, const bool logToRedfish,
21 const bool updateReport,
22 const std::vector<std::string>& reportNames,
23 const std::vector<LabeledSensorInfo>& LabeledSensorsInfoIn,
24 const LabeledTriggerThresholdParams& labeledThresholdParamsIn,
25 std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholds,
26 interfaces::TriggerManager& triggerManager,
27 interfaces::JsonStorage& triggerStorage);
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010028
29 Trigger(const Trigger&) = delete;
30 Trigger(Trigger&&) = delete;
31 Trigger& operator=(const Trigger&) = delete;
32 Trigger& operator=(Trigger&&) = delete;
33
34 std::string getName() const override
35 {
36 return name;
37 }
38
39 std::string getPath() const override
40 {
41 return path;
42 }
43
Cezary Zwolaka4e67612021-02-18 13:16:16 +010044 bool storeConfiguration() const;
45
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010046 private:
47 const std::string name;
Cezary Zwolaka4e67612021-02-18 13:16:16 +010048 bool isDiscrete;
49 bool logToJournal;
50 bool logToRedfish;
51 bool updateReport;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010052 const std::string path;
Cezary Zwolaka4e67612021-02-18 13:16:16 +010053 bool persistent = false;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010054 std::vector<std::string> reportNames;
Cezary Zwolak4416fce2021-03-17 03:21:06 +010055 std::vector<LabeledSensorInfo> labeledSensorsInfo;
56 LabeledTriggerThresholdParams labeledThresholdParams;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010057 std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface;
58 std::unique_ptr<sdbusplus::asio::dbus_interface> triggerIface;
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010059 std::vector<std::shared_ptr<interfaces::Threshold>> thresholds;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010060
Cezary Zwolaka4e67612021-02-18 13:16:16 +010061 interfaces::JsonStorage::FilePath fileName;
62 interfaces::JsonStorage& triggerStorage;
63
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010064 public:
65 static constexpr const char* triggerIfaceName =
66 "xyz.openbmc_project.Telemetry.Trigger";
67 static constexpr const char* triggerDir =
68 "/xyz/openbmc_project/Telemetry/Triggers/";
69 static constexpr const char* deleteIfaceName =
70 "xyz.openbmc_project.Object.Delete";
Cezary Zwolaka4e67612021-02-18 13:16:16 +010071 static constexpr size_t triggerVersion = 0;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010072};