blob: 06ac40523be1b902d0e2abc6d6c067a52cf8b4bd [file] [log] [blame]
Václav Kubernát73109382018-09-14 19:52:03 +02001/*
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át69aabe92020-01-24 16:53:12 +010011#include <optional>
Václav Kubernát73109382018-09-14 19:52:03 +020012#include <memory>
Jan Kundrátbb525b42020-02-04 11:56:59 +010013#include "datastore_access.hpp"
Václav Kubernát73109382018-09-14 19:52:03 +020014
15namespace sysrepo {
16class Callback;
17class Connection;
18class Session;
19class Subscribe;
20}
21class YangSchema;
22
23class Recorder {
24public:
25 virtual ~Recorder();
Václav Kubernát69aabe92020-01-24 16:53:12 +010026 virtual void write(const std::string& xpath, const std::optional<std::string>& oldValue, const std::optional<std::string>& newValue) = 0;
Václav Kubernát73109382018-09-14 19:52:03 +020027};
28
Jan Kundrátbb525b42020-02-04 11:56:59 +010029class DataSupplier {
30public:
31 virtual ~DataSupplier();
Václav Kubernát59e4ee42020-07-08 17:32:45 +020032 [[nodiscard]] virtual DatastoreAccess::Tree get_data(const std::string& xpath) const = 0;
Jan Kundrátbb525b42020-02-04 11:56:59 +010033};
34
35
Václav Kubernát73109382018-09-14 19:52:03 +020036class SysrepoSubscription {
37public:
Václav Kubernátab612e92019-11-26 19:51:31 +010038 SysrepoSubscription(const std::string& moduleName, Recorder* rec = nullptr);
Václav Kubernát73109382018-09-14 19:52:03 +020039
40private:
41 std::shared_ptr<sysrepo::Connection> m_connection;
42 std::shared_ptr<sysrepo::Session> m_session;
43 std::shared_ptr<YangSchema> m_schema;
Václav Kubernát73109382018-09-14 19:52:03 +020044 std::shared_ptr<sysrepo::Subscribe> m_subscription;
45};
Jan Kundrátbb525b42020-02-04 11:56:59 +010046
47class OperationalDataSubscription {
48public:
Václav Kubernát654303f2020-07-31 13:16:54 +020049 OperationalDataSubscription(const std::string& moduleName, const std::string& path, const DataSupplier& dataSupplier);
Jan Kundrátbb525b42020-02-04 11:56:59 +010050private:
51 std::shared_ptr<sysrepo::Connection> m_connection;
52 std::shared_ptr<sysrepo::Session> m_session;
53 std::shared_ptr<YangSchema> m_schema;
54 std::shared_ptr<sysrepo::Subscribe> m_subscription;
Jan Kundrátbb525b42020-02-04 11:56:59 +010055};