blob: b7ef182af11c31f5f37524846b7be83fb159caa1 [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"
Szymon Dompke94f71c52021-12-10 07:16:33 +01006#include "interfaces/trigger_factory.hpp"
Wludzik, Jozef76833cb2020-12-21 14:42:41 +01007#include "interfaces/trigger_manager.hpp"
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +00008#include "types/trigger_types.hpp"
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +01009#include "utils/messanger.hpp"
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010010
11#include <boost/asio/io_context.hpp>
12#include <sdbusplus/asio/object_server.hpp>
13
14#include <memory>
15
16class Trigger : public interfaces::Trigger
17{
18 public:
Cezary Zwolak4416fce2021-03-17 03:21:06 +010019 Trigger(boost::asio::io_context& ioc,
20 const std::shared_ptr<sdbusplus::asio::object_server>& objServer,
Szymon Dompkee28aa532021-10-27 12:33:12 +020021 const std::string& id, const std::string& name,
Szymon Dompke94f71c52021-12-10 07:16:33 +010022 const std::vector<TriggerAction>& triggerActions,
23 const std::shared_ptr<std::vector<std::string>> reportIds,
Cezary Zwolak4416fce2021-03-17 03:21:06 +010024 std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholds,
25 interfaces::TriggerManager& triggerManager,
Szymon Dompke94f71c52021-12-10 07:16:33 +010026 interfaces::JsonStorage& triggerStorage,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +010027 const interfaces::TriggerFactory& triggerFactory,
28 Sensors sensorsIn);
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
Szymon Dompkee28aa532021-10-27 12:33:12 +020035 std::string getId() const override
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010036 {
Szymon Dompkee28aa532021-10-27 12:33:12 +020037 return id;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010038 }
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:
Szymon Dompkee28aa532021-10-27 12:33:12 +020048 std::string id;
49 std::string name;
Szymon Dompke94f71c52021-12-10 07:16:33 +010050 std::vector<TriggerAction> triggerActions;
Szymon Dompkee28aa532021-10-27 12:33:12 +020051 std::string path;
Cezary Zwolaka4e67612021-02-18 13:16:16 +010052 bool persistent = false;
Szymon Dompke94f71c52021-12-10 07:16:33 +010053 std::shared_ptr<std::vector<std::string>> reportIds;
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;
Szymon Dompke94f71c52021-12-10 07:16:33 +010060 Sensors sensors;
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +010061 utils::Messanger messanger;
Cezary Zwolaka4e67612021-02-18 13:16:16 +010062
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010063 public:
64 static constexpr const char* triggerIfaceName =
65 "xyz.openbmc_project.Telemetry.Trigger";
66 static constexpr const char* triggerDir =
67 "/xyz/openbmc_project/Telemetry/Triggers/";
68 static constexpr const char* deleteIfaceName =
69 "xyz.openbmc_project.Object.Delete";
Szymon Dompke94f71c52021-12-10 07:16:33 +010070 static constexpr size_t triggerVersion = 1;
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010071};