Make DatastoreAccess::getItems const

I want to use this method in other const methods.

Change-Id: I32ff3fd8f0e77dbcea9b83b8ab8da99c1aa41f17
diff --git a/src/datastore_access.hpp b/src/datastore_access.hpp
index 29253ce..addd9f8 100644
--- a/src/datastore_access.hpp
+++ b/src/datastore_access.hpp
@@ -44,7 +44,7 @@
 public:
     using Tree = std::vector<std::pair<std::string, leaf_data_>>;
     virtual ~DatastoreAccess() = 0;
-    virtual Tree getItems(const std::string& path) = 0;
+    virtual Tree getItems(const std::string& path) const = 0;
     virtual void setLeaf(const std::string& path, leaf_data_ value) = 0;
     virtual void createItem(const std::string& path) = 0;
     virtual void deleteItem(const std::string& path) = 0;
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index bcf6fb4..dccec1c 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -16,7 +16,7 @@
 
 NetconfAccess::~NetconfAccess() = default;
 
-DatastoreAccess::Tree NetconfAccess::getItems(const std::string& path)
+DatastoreAccess::Tree NetconfAccess::getItems(const std::string& path) const
 {
     Tree res;
     auto config = m_session->get((path != "/") ? std::optional{path} : std::nullopt);
diff --git a/src/netconf_access.hpp b/src/netconf_access.hpp
index 3f45a27..924b2c2 100644
--- a/src/netconf_access.hpp
+++ b/src/netconf_access.hpp
@@ -33,7 +33,7 @@
     NetconfAccess(const std::string& socketPath);
     NetconfAccess(std::unique_ptr<libnetconf::client::Session>&& session);
     ~NetconfAccess() override;
-    Tree getItems(const std::string& path) override;
+    Tree getItems(const std::string& path) const override;
     void setLeaf(const std::string& path, leaf_data_ value) override;
     void createItem(const std::string& path) override;
     void deleteItem(const std::string& path) override;
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index 70b8823..e95d740 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -186,7 +186,7 @@
     }
 }
 
-DatastoreAccess::Tree SysrepoAccess::getItems(const std::string& path)
+DatastoreAccess::Tree SysrepoAccess::getItems(const std::string& path) const
 {
     using namespace std::string_literals;
     Tree res;
@@ -364,7 +364,7 @@
     return m_schema;
 }
 
-[[noreturn]] void SysrepoAccess::reportErrors()
+[[noreturn]] void SysrepoAccess::reportErrors() const
 {
     // I only use get_last_errors to get error info, since the error code from
     // sysrepo_exception doesn't really give any meaningful information. For
diff --git a/src/sysrepo_access.hpp b/src/sysrepo_access.hpp
index 4d87847..3150791 100644
--- a/src/sysrepo_access.hpp
+++ b/src/sysrepo_access.hpp
@@ -28,7 +28,7 @@
 public:
     ~SysrepoAccess() override;
     SysrepoAccess(const std::string& appname, const Datastore datastore);
-    Tree getItems(const std::string& path) override;
+    Tree getItems(const std::string& path) const override;
     void setLeaf(const std::string& path, leaf_data_ value) override;
     void createItem(const std::string& path) override;
     void deleteItem(const std::string& path) override;
@@ -43,7 +43,7 @@
 
 private:
     std::vector<ListInstance> listInstances(const std::string& path) override;
-    [[noreturn]] void reportErrors();
+    [[noreturn]] void reportErrors() const;
 
     std::string fetchSchema(const char* module, const char* revision, const char* submodule);
     std::vector<std::shared_ptr<sysrepo::Yang_Schema>> listSchemas();
diff --git a/src/yang_access.cpp b/src/yang_access.cpp
index 71aebf1..c509231 100644
--- a/src/yang_access.cpp
+++ b/src/yang_access.cpp
@@ -108,7 +108,7 @@
     m_datastore = lyWrap(datastore);
 }
 
-DatastoreAccess::Tree YangAccess::getItems(const std::string& path)
+DatastoreAccess::Tree YangAccess::getItems(const std::string& path) const
 {
     DatastoreAccess::Tree res;
     if (!m_datastore) {
diff --git a/src/yang_access.hpp b/src/yang_access.hpp
index 9f20b51..9b8a443 100644
--- a/src/yang_access.hpp
+++ b/src/yang_access.hpp
@@ -22,7 +22,7 @@
 public:
     YangAccess();
     ~YangAccess() override;
-    Tree getItems(const std::string& path) override;
+    Tree getItems(const std::string& path) const override;
     void setLeaf(const std::string& path, leaf_data_ value) override;
     void createItem(const std::string& path) override;
     void deleteItem(const std::string& path) override;
diff --git a/tests/datastoreaccess_mock.hpp b/tests/datastoreaccess_mock.hpp
index 8252d04..a495b99 100644
--- a/tests/datastoreaccess_mock.hpp
+++ b/tests/datastoreaccess_mock.hpp
@@ -19,7 +19,7 @@
 }
 
 class MockDatastoreAccess : public trompeloeil::mock_interface<DatastoreAccess> {
-    IMPLEMENT_MOCK1(getItems);
+    IMPLEMENT_CONST_MOCK1(getItems);
     IMPLEMENT_MOCK2(setLeaf);
     IMPLEMENT_MOCK1(createItem);
     IMPLEMENT_MOCK1(deleteItem);