blob: 0f736d15ab683563c4392b4a61afe1f01d887cd1 [file] [log] [blame]
Václav Kubernát80aacc02018-08-22 17:41:54 +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 <string>
Václav Kubernátcfdb9222021-07-07 22:36:24 +020012#include <sysrepo-cpp/Connection.hpp>
Václav Kubernát80aacc02018-08-22 17:41:54 +020013#include "datastore_access.hpp"
14
15/*! \class DatastoreAccess
16 * \brief Abstract class for accessing a datastore
17 */
18
Jan Kundrát68d4a2c2018-10-01 17:17:09 +020019namespace sysrepo {
Václav Kubernát80aacc02018-08-22 17:41:54 +020020class Connection;
21class Session;
Václav Kubernátbf9c6112019-11-04 16:03:35 +010022class Yang_Schema;
Jan Kundrát68d4a2c2018-10-01 17:17:09 +020023}
24
Václav Kubernáta6c5fff2018-09-07 15:16:25 +020025class Schema;
26class YangSchema;
Václav Kubernát80aacc02018-08-22 17:41:54 +020027
28class SysrepoAccess : public DatastoreAccess {
29public:
30 ~SysrepoAccess() override;
Václav Kubernátf5d75152020-12-03 03:52:34 +010031 SysrepoAccess();
Václav Kubernát59e4ee42020-07-08 17:32:45 +020032 [[nodiscard]] Tree getItems(const std::string& path) const override;
Václav Kubernát80aacc02018-08-22 17:41:54 +020033 void setLeaf(const std::string& path, leaf_data_ value) override;
Jan Kundrátcbf288b2020-06-18 20:44:39 +020034 void createItem(const std::string& path) override;
35 void deleteItem(const std::string& path) override;
Václav Kubernátbf65dd72020-05-28 02:32:31 +020036 void moveItem(const std::string& source, std::variant<yang::move::Absolute, yang::move::Relative> move) override;
Václav Kubernátb3960f82020-12-01 03:21:48 +010037 Tree execute(const std::string& path, const Tree& input) override;
Jan Kundrát77d9f612019-09-03 16:52:32 +020038
39 std::shared_ptr<Schema> schema() override;
Václav Kubernát80aacc02018-08-22 17:41:54 +020040
Václav Kubernát812ee282018-08-30 17:10:03 +020041 void commitChanges() override;
Václav Kubernát6d791432018-10-25 16:00:35 +020042 void discardChanges() override;
Václav Kubernát7160a132020-04-03 02:11:01 +020043 void copyConfig(const Datastore source, const Datastore destination) override;
Václav Kubernát812ee282018-08-30 17:10:03 +020044
Václav Kubernát59e4ee42020-07-08 17:32:45 +020045 [[nodiscard]] std::string dump(const DataFormat format) const override;
Václav Kubernátb4e5b182020-11-16 19:55:09 +010046
Václav Kubernát80aacc02018-08-22 17:41:54 +020047private:
Václav Kubernátc15fe822020-06-04 11:28:39 +020048 std::vector<ListInstance> listInstances(const std::string& path) override;
Václav Kubernátd6282912020-06-23 14:49:34 +020049 [[noreturn]] void reportErrors() const;
Václav Kubernátc58e4aa2019-04-03 18:37:32 +020050
Václav Kubernátcfdb9222021-07-07 22:36:24 +020051 sysrepo::Connection m_connection;
52 sysrepo::Session m_session;
Václav Kubernáta6c5fff2018-09-07 15:16:25 +020053 std::shared_ptr<YangSchema> m_schema;
Václav Kubernát80aacc02018-08-22 17:41:54 +020054};