blob: fc2e4995ebe3bcdc4a6057a8b909b9051519462b [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
11#include <memory>
Václav Kubernátb4e5b182020-11-16 19:55:09 +010012#include <optional>
Václav Kubernáteaf56682021-02-22 17:15:41 +010013#include <sysrepo-cpp/Session.hpp>
Jan Kundrátbb525b42020-02-04 11:56:59 +010014#include "datastore_access.hpp"
Václav Kubernát73109382018-09-14 19:52:03 +020015
16namespace sysrepo {
17class Callback;
18class Connection;
19class Session;
20class Subscribe;
21}
22class YangSchema;
23
24class Recorder {
25public:
26 virtual ~Recorder();
Václav Kubernát69aabe92020-01-24 16:53:12 +010027 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 +020028};
29
Jan Kundrátbb525b42020-02-04 11:56:59 +010030class DataSupplier {
31public:
32 virtual ~DataSupplier();
Václav Kubernát59e4ee42020-07-08 17:32:45 +020033 [[nodiscard]] virtual DatastoreAccess::Tree get_data(const std::string& xpath) const = 0;
Jan Kundrátbb525b42020-02-04 11:56:59 +010034};
35
36
Václav Kubernát73109382018-09-14 19:52:03 +020037class SysrepoSubscription {
38public:
Václav Kubernáteaf56682021-02-22 17:15:41 +010039 SysrepoSubscription(const std::string& moduleName, Recorder* rec = nullptr, sr_datastore_t ds = SR_DS_RUNNING);
Václav Kubernát73109382018-09-14 19:52:03 +020040
41private:
42 std::shared_ptr<sysrepo::Connection> m_connection;
43 std::shared_ptr<sysrepo::Session> m_session;
44 std::shared_ptr<YangSchema> m_schema;
Václav Kubernát73109382018-09-14 19:52:03 +020045 std::shared_ptr<sysrepo::Subscribe> m_subscription;
46};
Jan Kundrátbb525b42020-02-04 11:56:59 +010047
48class OperationalDataSubscription {
49public:
Václav Kubernát654303f2020-07-31 13:16:54 +020050 OperationalDataSubscription(const std::string& moduleName, const std::string& path, const DataSupplier& dataSupplier);
Václav Kubernátb4e5b182020-11-16 19:55:09 +010051
Jan Kundrátbb525b42020-02-04 11:56:59 +010052private:
53 std::shared_ptr<sysrepo::Connection> m_connection;
54 std::shared_ptr<sysrepo::Session> m_session;
55 std::shared_ptr<YangSchema> m_schema;
56 std::shared_ptr<sysrepo::Subscribe> m_subscription;
Jan Kundrátbb525b42020-02-04 11:56:59 +010057};