blob: 76838142e703d954f614d9da6da284e60c3c5f70 [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();
32 virtual DatastoreAccess::Tree get_data(const std::string& xpath) const = 0;
33};
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;
44 std::shared_ptr<sysrepo::Callback> m_callback;
45 std::shared_ptr<sysrepo::Subscribe> m_subscription;
46};
Jan Kundrátbb525b42020-02-04 11:56:59 +010047
48class OperationalDataSubscription {
49public:
50 OperationalDataSubscription(const std::string& moduleName, const DataSupplier& dataSupplier);
51private:
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};