Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 1 | /* |
| 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át | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 12 | #include "datastore_access.hpp" |
| 13 | |
| 14 | /*! \class DatastoreAccess |
| 15 | * \brief Abstract class for accessing a datastore |
| 16 | */ |
| 17 | |
Jan Kundrát | 68d4a2c | 2018-10-01 17:17:09 +0200 | [diff] [blame] | 18 | namespace sysrepo { |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 19 | class Connection; |
| 20 | class Session; |
Václav Kubernát | bf9c611 | 2019-11-04 16:03:35 +0100 | [diff] [blame] | 21 | class Yang_Schema; |
Jan Kundrát | 68d4a2c | 2018-10-01 17:17:09 +0200 | [diff] [blame] | 22 | } |
| 23 | |
Václav Kubernát | a6c5fff | 2018-09-07 15:16:25 +0200 | [diff] [blame] | 24 | class Schema; |
| 25 | class YangSchema; |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 26 | |
| 27 | class SysrepoAccess : public DatastoreAccess { |
| 28 | public: |
| 29 | ~SysrepoAccess() override; |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 30 | SysrepoAccess(const Datastore datastore); |
Václav Kubernát | 59e4ee4 | 2020-07-08 17:32:45 +0200 | [diff] [blame] | 31 | [[nodiscard]] Tree getItems(const std::string& path) const override; |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 32 | void setLeaf(const std::string& path, leaf_data_ value) override; |
Jan Kundrát | cbf288b | 2020-06-18 20:44:39 +0200 | [diff] [blame] | 33 | void createItem(const std::string& path) override; |
| 34 | void deleteItem(const std::string& path) override; |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 35 | void moveItem(const std::string& source, std::variant<yang::move::Absolute, yang::move::Relative> move) override; |
Václav Kubernát | b3960f8 | 2020-12-01 03:21:48 +0100 | [diff] [blame^] | 36 | Tree execute(const std::string& path, const Tree& input) override; |
Jan Kundrát | 77d9f61 | 2019-09-03 16:52:32 +0200 | [diff] [blame] | 37 | |
| 38 | std::shared_ptr<Schema> schema() override; |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 39 | |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 40 | void commitChanges() override; |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 41 | void discardChanges() override; |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 42 | void copyConfig(const Datastore source, const Datastore destination) override; |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 43 | |
Václav Kubernát | 59e4ee4 | 2020-07-08 17:32:45 +0200 | [diff] [blame] | 44 | [[nodiscard]] std::string dump(const DataFormat format) const override; |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 45 | |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 46 | private: |
Václav Kubernát | c15fe82 | 2020-06-04 11:28:39 +0200 | [diff] [blame] | 47 | std::vector<ListInstance> listInstances(const std::string& path) override; |
Václav Kubernát | d628291 | 2020-06-23 14:49:34 +0200 | [diff] [blame] | 48 | [[noreturn]] void reportErrors() const; |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 49 | |
Jan Kundrát | 68d4a2c | 2018-10-01 17:17:09 +0200 | [diff] [blame] | 50 | std::shared_ptr<sysrepo::Connection> m_connection; |
| 51 | std::shared_ptr<sysrepo::Session> m_session; |
Václav Kubernát | a6c5fff | 2018-09-07 15:16:25 +0200 | [diff] [blame] | 52 | std::shared_ptr<YangSchema> m_schema; |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 53 | }; |