blob: 85d048df2e6817889c88e31beb3b0c7f00ca8679 [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átcfdb9222021-07-07 22:36:24 +020013#include <sysrepo-cpp/Connection.hpp>
Jan Kundrátbb525b42020-02-04 11:56:59 +010014#include "datastore_access.hpp"
Václav Kubernát73109382018-09-14 19:52:03 +020015
Václav Kubernát73109382018-09-14 19:52:03 +020016class YangSchema;
17
18class Recorder {
19public:
20 virtual ~Recorder();
Václav Kubernátcfdb9222021-07-07 22:36:24 +020021 virtual void write(const sysrepo::ChangeOperation operation, const std::string& xpath, const std::optional<std::string>& oldValue, const std::optional<std::string>& newValue, const std::optional<std::string> previousList) = 0;
Václav Kubernát73109382018-09-14 19:52:03 +020022};
23
Jan Kundrátbb525b42020-02-04 11:56:59 +010024class DataSupplier {
25public:
26 virtual ~DataSupplier();
Václav Kubernát59e4ee42020-07-08 17:32:45 +020027 [[nodiscard]] virtual DatastoreAccess::Tree get_data(const std::string& xpath) const = 0;
Jan Kundrátbb525b42020-02-04 11:56:59 +010028};
29
30
Václav Kubernát73109382018-09-14 19:52:03 +020031class SysrepoSubscription {
32public:
Václav Kubernátcfdb9222021-07-07 22:36:24 +020033 SysrepoSubscription(const std::string& moduleName, Recorder* rec = nullptr, sysrepo::Datastore ds = sysrepo::Datastore::Running);
Václav Kubernát73109382018-09-14 19:52:03 +020034
35private:
Václav Kubernátcfdb9222021-07-07 22:36:24 +020036 sysrepo::Subscription m_subscription;
Václav Kubernát73109382018-09-14 19:52:03 +020037};
Jan Kundrátbb525b42020-02-04 11:56:59 +010038
39class OperationalDataSubscription {
40public:
Václav Kubernát654303f2020-07-31 13:16:54 +020041 OperationalDataSubscription(const std::string& moduleName, const std::string& path, const DataSupplier& dataSupplier);
Václav Kubernátb4e5b182020-11-16 19:55:09 +010042
Jan Kundrátbb525b42020-02-04 11:56:59 +010043private:
Jan Kundrátbb525b42020-02-04 11:56:59 +010044 std::shared_ptr<YangSchema> m_schema;
Václav Kubernátcfdb9222021-07-07 22:36:24 +020045 sysrepo::Subscription m_subscription;
Jan Kundrátbb525b42020-02-04 11:56:59 +010046};