blob: e1874e74c4c1b50b64dbd38d3d3a2017018b9071 [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,
Szymon Dompkee28aa532021-10-27 12:33:12 +020019 const std::string& id, const std::string& name,
Szymon Dompke20013012021-07-23 09:54:20 +020020 const std::vector<std::string>& triggerActions,
Cezary Zwolak4416fce2021-03-17 03:21:06 +010021 const std::vector<std::string>& reportNames,
22 const std::vector<LabeledSensorInfo>& LabeledSensorsInfoIn,
23 const LabeledTriggerThresholdParams& labeledThresholdParamsIn,
24 std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholds,
25 interfaces::TriggerManager& triggerManager,
26 interfaces::JsonStorage& triggerStorage);
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010027
28 Trigger(const Trigger&) = delete;
29 Trigger(Trigger&&) = delete;
30 Trigger& operator=(const Trigger&) = delete;
31 Trigger& operator=(Trigger&&) = delete;
32
Szymon Dompkee28aa532021-10-27 12:33:12 +020033 std::string getId() const override
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010034 {
Szymon Dompkee28aa532021-10-27 12:33:12 +020035 return id;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010036 }
37
38 std::string getPath() const override
39 {
40 return path;
41 }
42
Cezary Zwolaka4e67612021-02-18 13:16:16 +010043 bool storeConfiguration() const;
44
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010045 private:
Szymon Dompkee28aa532021-10-27 12:33:12 +020046 std::string id;
47 std::string name;
Szymon Dompke20013012021-07-23 09:54:20 +020048 std::vector<std::string> triggerActions;
Szymon Dompkee28aa532021-10-27 12:33:12 +020049 std::string path;
Cezary Zwolaka4e67612021-02-18 13:16:16 +010050 bool persistent = false;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010051 std::vector<std::string> reportNames;
Cezary Zwolak4416fce2021-03-17 03:21:06 +010052 std::vector<LabeledSensorInfo> labeledSensorsInfo;
53 LabeledTriggerThresholdParams labeledThresholdParams;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010054 std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface;
55 std::unique_ptr<sdbusplus::asio::dbus_interface> triggerIface;
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010056 std::vector<std::shared_ptr<interfaces::Threshold>> thresholds;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010057
Cezary Zwolaka4e67612021-02-18 13:16:16 +010058 interfaces::JsonStorage::FilePath fileName;
59 interfaces::JsonStorage& triggerStorage;
60
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010061 public:
62 static constexpr const char* triggerIfaceName =
63 "xyz.openbmc_project.Telemetry.Trigger";
64 static constexpr const char* triggerDir =
65 "/xyz/openbmc_project/Telemetry/Triggers/";
66 static constexpr const char* deleteIfaceName =
67 "xyz.openbmc_project.Object.Delete";
Cezary Zwolaka4e67612021-02-18 13:16:16 +010068 static constexpr size_t triggerVersion = 0;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010069};