blob: 8df11530534b1fc093bd4bfbca8f4cc5506f2dd1 [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át80aacc02018-08-22 17:41:54 +020012#include "datastore_access.hpp"
13
14/*! \class DatastoreAccess
15 * \brief Abstract class for accessing a datastore
16 */
17
Jan Kundrát68d4a2c2018-10-01 17:17:09 +020018namespace sysrepo {
Václav Kubernát80aacc02018-08-22 17:41:54 +020019class Connection;
20class Session;
Jan Kundrát68d4a2c2018-10-01 17:17:09 +020021}
22
Václav Kubernáta6c5fff2018-09-07 15:16:25 +020023class Schema;
24class YangSchema;
Václav Kubernát80aacc02018-08-22 17:41:54 +020025
26class SysrepoAccess : public DatastoreAccess {
27public:
28 ~SysrepoAccess() override;
29 SysrepoAccess(const std::string& appname);
30 std::map<std::string, leaf_data_> getItems(const std::string& path) override;
31 void setLeaf(const std::string& path, leaf_data_ value) override;
32 void createPresenceContainer(const std::string& path) override;
33 void deletePresenceContainer(const std::string& path) override;
Václav Kubernátf5f64f02019-03-19 17:15:47 +010034 void createListInstance(const std::string& path) override;
35 void deleteListInstance(const std::string& path) override;
Jan Kundrát77d9f612019-09-03 16:52:32 +020036
37 std::shared_ptr<Schema> schema() override;
Václav Kubernát80aacc02018-08-22 17:41:54 +020038
Václav Kubernát812ee282018-08-30 17:10:03 +020039 void commitChanges() override;
Václav Kubernát6d791432018-10-25 16:00:35 +020040 void discardChanges() override;
Václav Kubernát812ee282018-08-30 17:10:03 +020041
Václav Kubernát80aacc02018-08-22 17:41:54 +020042private:
Václav Kubernátc58e4aa2019-04-03 18:37:32 +020043 [[noreturn]] void reportErrors();
44
Jan Kundrát77d9f612019-09-03 16:52:32 +020045 std::string fetchSchema(const char* module, const char* revision, const char* submodule);
46 std::vector<std::string> listImplementedSchemas();
47
Jan Kundrát68d4a2c2018-10-01 17:17:09 +020048 std::shared_ptr<sysrepo::Connection> m_connection;
49 std::shared_ptr<sysrepo::Session> m_session;
Václav Kubernáta6c5fff2018-09-07 15:16:25 +020050 std::shared_ptr<YangSchema> m_schema;
Václav Kubernát80aacc02018-08-22 17:41:54 +020051};