blob: a7713603375cb0ca2fee9feff775c062ab90c86b [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>
12#include "ast_commands.hpp"
13#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;
Jan Kundrát68d4a2c2018-10-01 17:17:09 +020022}
23
Václav Kubernáta6c5fff2018-09-07 15:16:25 +020024class Schema;
25class YangSchema;
Václav Kubernát80aacc02018-08-22 17:41:54 +020026
27class SysrepoAccess : public DatastoreAccess {
28public:
29 ~SysrepoAccess() override;
30 SysrepoAccess(const std::string& appname);
31 std::map<std::string, leaf_data_> getItems(const std::string& path) override;
32 void setLeaf(const std::string& path, leaf_data_ value) override;
33 void createPresenceContainer(const std::string& path) override;
34 void deletePresenceContainer(const std::string& path) override;
Václav Kubernátf5f64f02019-03-19 17:15:47 +010035 void createListInstance(const std::string& path) override;
36 void deleteListInstance(const std::string& path) override;
Jan Kundrát77d9f612019-09-03 16:52:32 +020037
38 std::shared_ptr<Schema> schema() override;
Václav Kubernát80aacc02018-08-22 17:41:54 +020039
Václav Kubernát812ee282018-08-30 17:10:03 +020040 void commitChanges() override;
Václav Kubernát6d791432018-10-25 16:00:35 +020041 void discardChanges() override;
Václav Kubernát812ee282018-08-30 17:10:03 +020042
Václav Kubernát80aacc02018-08-22 17:41:54 +020043private:
Václav Kubernátc58e4aa2019-04-03 18:37:32 +020044 [[noreturn]] void reportErrors();
45
Jan Kundrát77d9f612019-09-03 16:52:32 +020046 std::string fetchSchema(const char* module, const char* revision, const char* submodule);
47 std::vector<std::string> listImplementedSchemas();
48
Jan Kundrát68d4a2c2018-10-01 17:17:09 +020049 std::shared_ptr<sysrepo::Connection> m_connection;
50 std::shared_ptr<sysrepo::Session> m_session;
Václav Kubernáta6c5fff2018-09-07 15:16:25 +020051 std::shared_ptr<YangSchema> m_schema;
Václav Kubernát80aacc02018-08-22 17:41:54 +020052};