Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/ |
| 3 | * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/ |
| 4 | * |
| 5 | * Written by Václav Kubernát <kubervac@fit.cvut.cz> |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #pragma once |
| 10 | |
Václav Kubernát | 69aabe9 | 2020-01-24 16:53:12 +0100 | [diff] [blame] | 11 | #include <optional> |
Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 12 | #include <memory> |
Jan Kundrát | bb525b4 | 2020-02-04 11:56:59 +0100 | [diff] [blame] | 13 | #include "datastore_access.hpp" |
Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 14 | |
| 15 | namespace sysrepo { |
| 16 | class Callback; |
| 17 | class Connection; |
| 18 | class Session; |
| 19 | class Subscribe; |
| 20 | } |
| 21 | class YangSchema; |
| 22 | |
| 23 | class Recorder { |
| 24 | public: |
| 25 | virtual ~Recorder(); |
Václav Kubernát | 69aabe9 | 2020-01-24 16:53:12 +0100 | [diff] [blame] | 26 | virtual void write(const std::string& xpath, const std::optional<std::string>& oldValue, const std::optional<std::string>& newValue) = 0; |
Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 27 | }; |
| 28 | |
Jan Kundrát | bb525b4 | 2020-02-04 11:56:59 +0100 | [diff] [blame] | 29 | class DataSupplier { |
| 30 | public: |
| 31 | virtual ~DataSupplier(); |
Václav Kubernát | 59e4ee4 | 2020-07-08 17:32:45 +0200 | [diff] [blame] | 32 | [[nodiscard]] virtual DatastoreAccess::Tree get_data(const std::string& xpath) const = 0; |
Jan Kundrát | bb525b4 | 2020-02-04 11:56:59 +0100 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | |
Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 36 | class SysrepoSubscription { |
| 37 | public: |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 38 | SysrepoSubscription(const std::string& moduleName, Recorder* rec = nullptr); |
Václav Kubernát | 7310938 | 2018-09-14 19:52:03 +0200 | [diff] [blame] | 39 | |
| 40 | private: |
| 41 | std::shared_ptr<sysrepo::Connection> m_connection; |
| 42 | std::shared_ptr<sysrepo::Session> m_session; |
| 43 | std::shared_ptr<YangSchema> m_schema; |
| 44 | std::shared_ptr<sysrepo::Callback> m_callback; |
| 45 | std::shared_ptr<sysrepo::Subscribe> m_subscription; |
| 46 | }; |
Jan Kundrát | bb525b4 | 2020-02-04 11:56:59 +0100 | [diff] [blame] | 47 | |
| 48 | class OperationalDataSubscription { |
| 49 | public: |
| 50 | OperationalDataSubscription(const std::string& moduleName, const DataSupplier& dataSupplier); |
| 51 | private: |
| 52 | std::shared_ptr<sysrepo::Connection> m_connection; |
| 53 | std::shared_ptr<sysrepo::Session> m_session; |
| 54 | std::shared_ptr<YangSchema> m_schema; |
| 55 | std::shared_ptr<sysrepo::Subscribe> m_subscription; |
| 56 | std::shared_ptr<sysrepo::Callback> m_callback; |
| 57 | }; |