xref: /openbmc/telemetry/src/telemetry.hpp (revision e6d4887453f0b23b46c012da7cb26f2beb38ef0e)
1 #pragma once
2 
3 #include "persistent_json_storage.hpp"
4 #include "report_factory.hpp"
5 #include "report_manager.hpp"
6 #include "sensor_cache.hpp"
7 #include "trigger_factory.hpp"
8 #include "trigger_manager.hpp"
9 
10 #include <sdbusplus/asio/connection.hpp>
11 #include <sdbusplus/asio/object_server.hpp>
12 
13 #include <memory>
14 
15 class Telemetry
16 {
17   public:
Telemetry(std::shared_ptr<sdbusplus::asio::connection> bus)18     explicit Telemetry(std::shared_ptr<sdbusplus::asio::connection> bus) :
19         objServer(std::make_shared<sdbusplus::asio::object_server>(bus)),
20         reportManager(
21             std::make_unique<ReportFactory>(bus, objServer, sensorCache),
22             std::make_unique<PersistentJsonStorage>(
23                 interfaces::JsonStorage::DirectoryPath(
24                     "/var/lib/telemetry/Reports")),
25             objServer),
26         triggerManager(
27             std::make_unique<TriggerFactory>(bus, objServer, sensorCache),
28             std::make_unique<PersistentJsonStorage>(
29                 interfaces::JsonStorage::DirectoryPath(
30                     "/var/lib/telemetry/Triggers")),
31             objServer)
32     {}
33 
34   private:
35     std::shared_ptr<sdbusplus::asio::object_server> objServer;
36     mutable SensorCache sensorCache;
37     ReportManager reportManager;
38     TriggerManager triggerManager;
39 };
40