Tomáš Pecka | ccd80c3 | 2020-06-22 14:44:32 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 CESNET, https://photonics.cesnet.cz/ |
| 3 | * |
| 4 | * Written by Tomáš Pecka <tomas.pecka@fit.cvut.cz> |
| 5 | * |
| 6 | */ |
| 7 | #pragma once |
| 8 | |
| 9 | #include <memory> |
| 10 | #include <sdbus-c++/sdbus-c++.h> |
| 11 | #include <set> |
| 12 | #include "inputs/AbstractInput.h" |
| 13 | #include "manager/StateManager.h" |
| 14 | |
| 15 | namespace velia { |
| 16 | |
| 17 | /** |
| 18 | * Register |
| 19 | */ |
| 20 | class DbusSystemdInput : public AbstractInput { |
| 21 | public: |
| 22 | DbusSystemdInput(std::shared_ptr<AbstractManager> manager, sdbus::IConnection& connection); |
| 23 | DbusSystemdInput(std::shared_ptr<AbstractManager> manager, sdbus::IConnection& connection, const std::string& busname, const std::string& managerObjectPath, const std::string& managerIface, const std::string& unitIface); |
| 24 | ~DbusSystemdInput() override; |
| 25 | |
| 26 | private: |
| 27 | velia::Log m_log; |
| 28 | |
| 29 | std::string m_busName; |
| 30 | std::string m_unitIface; |
| 31 | std::unique_ptr<sdbus::IProxy> m_proxyManager; |
| 32 | |
| 33 | /** List of registered unit watchers */ |
| 34 | std::map<sdbus::ObjectPath, std::unique_ptr<sdbus::IProxy>> m_proxyUnits; |
| 35 | |
| 36 | /** List of units in failed state. */ |
| 37 | std::set<std::string> m_failedUnits; |
| 38 | |
Tomáš Pecka | 8ce8835 | 2020-11-04 19:14:13 +0100 | [diff] [blame^] | 39 | /** Current unit state. */ |
| 40 | std::map<std::string, std::pair<std::string, std::string>> m_unitState; |
| 41 | |
Tomáš Pecka | ccd80c3 | 2020-06-22 14:44:32 +0200 | [diff] [blame] | 42 | void registerSystemdUnit(sdbus::IConnection& connection, const std::string& unitName, const sdbus::ObjectPath& unitObjectPath); |
| 43 | void onUnitStateChange(const std::string& name, const std::string& activeState, const std::string& nSubState); |
| 44 | }; |
| 45 | |
Tomáš Pecka | 8ce8835 | 2020-11-04 19:14:13 +0100 | [diff] [blame^] | 46 | } |