Implement fetching of enabled features

Change-Id: I298a3ffeba4606bd0111460830e9ec60682e5f32
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index 2c80c2d..f84bb91 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -93,8 +93,13 @@
         return fetchSchema(moduleName, revision, submodule);
     });
 
-    for (const auto& it : listImplementedSchemas()) {
-        m_schema->loadModule(it);
+    for (const auto& it : listSchemas()) {
+        if (it->implemented()) {
+            m_schema->loadModule(it->module_name());
+            for (unsigned int i = 0; i < it->enabled_feature_cnt(); i++) {
+                m_schema->enableFeature(it->module_name(), it->enabled_features(i));
+            }
+        }
     }
 }
 
@@ -205,9 +210,9 @@
     return schema;
 }
 
-std::vector<std::string> SysrepoAccess::listImplementedSchemas()
+std::vector<std::shared_ptr<sysrepo::Yang_Schema>> SysrepoAccess::listSchemas()
 {
-    std::vector<std::string> res;
+    std::vector<sysrepo::S_Yang_Schema> res;
     std::shared_ptr<sysrepo::Yang_Schemas> schemas;
     try {
         schemas = m_session->list_schemas();
@@ -216,8 +221,7 @@
     }
     for (unsigned int i = 0; i < schemas->schema_cnt(); i++) {
         auto schema = schemas->schema(i);
-        if (schema->implemented())
-            res.push_back(schema->module_name());
+        res.push_back(schema);
     }
     return res;
 }
diff --git a/src/sysrepo_access.hpp b/src/sysrepo_access.hpp
index 8df1153..9861ab4 100644
--- a/src/sysrepo_access.hpp
+++ b/src/sysrepo_access.hpp
@@ -18,6 +18,7 @@
 namespace sysrepo {
 class Connection;
 class Session;
+class Yang_Schema;
 }
 
 class Schema;
@@ -43,7 +44,7 @@
     [[noreturn]] void reportErrors();
 
     std::string fetchSchema(const char* module, const char* revision, const char* submodule);
-    std::vector<std::string> listImplementedSchemas();
+    std::vector<std::shared_ptr<sysrepo::Yang_Schema>> listSchemas();
 
     std::shared_ptr<sysrepo::Connection> m_connection;
     std::shared_ptr<sysrepo::Session> m_session;
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 1ac7a79..4c55b27 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -370,6 +370,11 @@
     m_context->load_module(moduleName.c_str());
 }
 
+void YangSchema::enableFeature(const std::string& moduleName, const std::string& featureName)
+{
+    m_context->get_module(moduleName.c_str())->feature_enable(featureName.c_str());
+}
+
 void YangSchema::registerModuleCallback(const std::function<std::string(const char*, const char*, const char*)>& clb)
 {
     auto lambda = [clb](const char* mod_name, const char* mod_revision, const char* submod_name, const char* submod_revision) {
diff --git a/src/yang_schema.hpp b/src/yang_schema.hpp
index aa5faa4..14b0f1e 100644
--- a/src/yang_schema.hpp
+++ b/src/yang_schema.hpp
@@ -50,6 +50,9 @@
     /** @short Loads a module called moduleName. */
     void loadModule(const std::string& moduleName);
 
+    /** @short Enables a feature called featureName on a module called moduleName. */
+    void enableFeature(const std::string& moduleName, const std::string& featureName);
+
     /** @short Adds a new module passed as a YANG string. */
     void addSchemaString(const char* schema);