Disable readonly data paths in set
The first solution to this was to just filter operational nodes directly
inside NodeParser. That however can't work, because we might want to
parse operational data paths (for `get` and also `ls`). That means I
have to define, what gets filtered out, outside of NodeParser. The first
thing that came to mind is using a template argument, however, that
can't be used with lambdas (at least not easily). Instead I just use the
constructor and std::function.
Change-Id: Ic9e503ff721970066ef53d7b5626ff153ad44e18
diff --git a/src/static_schema.hpp b/src/static_schema.hpp
index 5184ae6..b94dfa3 100644
--- a/src/static_schema.hpp
+++ b/src/static_schema.hpp
@@ -32,10 +32,20 @@
struct module {
};
+
+enum class AccessType {
+ Writable,
+ ReadOnly
+};
}
using NodeType = boost::variant<yang::container, yang::list, yang::leaf, yang::module>;
+struct NodeInfo {
+ NodeType m_nodeType;
+ yang::AccessType m_configType;
+};
+
/*! \class StaticSchema
* \brief Static schema, used mainly for testing
@@ -66,17 +76,17 @@
* used in addLeaf for the `type` argument */
std::set<identityRef_> validIdentities(std::string_view module, std::string_view value);
void addContainer(const std::string& location, const std::string& name, yang::ContainerTraits isPresence = yang::ContainerTraits::None);
- void addLeaf(const std::string& location, const std::string& name, const yang::LeafDataType& type);
+ void addLeaf(const std::string& location, const std::string& name, const yang::LeafDataType& type, const yang::AccessType accessType = yang::AccessType::Writable);
void addList(const std::string& location, const std::string& name, const std::set<std::string>& keys);
void addModule(const std::string& name);
void addIdentity(const std::optional<identityRef_>& base, const identityRef_& name);
private:
- const std::unordered_map<std::string, NodeType>& children(const std::string& name) const;
+ const std::unordered_map<std::string, NodeInfo>& children(const std::string& name) const;
void getIdentSet(const identityRef_& ident, std::set<identityRef_>& res) const;
bool nodeExists(const std::string& location, const std::string& node) const;
- std::unordered_map<std::string, std::unordered_map<std::string, NodeType>> m_nodes;
+ std::unordered_map<std::string, std::unordered_map<std::string, NodeInfo>> m_nodes;
std::set<std::string> m_modules;
std::map<identityRef_, std::set<identityRef_>> m_identities;