DataNode¶
-
class
ydk::path::DataNode¶ Class represents the
DataNode.-
virtual
~DataNode()¶ The destructor.
Note
A
DataNoderepresents a containment hierarchy. So invocation of the destructor will lead to the children of this node being destroyed.
-
virtual const SchemaNode &
get_schema_node() const¶ Returns the
SchemaNodeassociated with thisDataNode.Returns: SchemaNodeassociated with thisDataNode.
-
virtual std::string
get_path() const¶ Returns the path expression representing this Node in in the NodeTree.
Returns: std::stringrepresenting the path to this Node.
-
virtual DataNode &
create_datanode(const std::string &path)¶ Creates a
DataNodecorresponding to the path and set its value.This methods creates a
DataNodetree based on the path passed in. The path expression must identify a single node. If the last node created is of schema typelist,leaf-listoranyxmlthat value is also set in the node.The returned
DataNodeis the last node created (the terminal part of the path).The user is responsible for managing the memory of this returned tree. Use
get_root()to get the root element of the this tree and use that pointer to dispose of the entire tree.Note
In the case of
listnodes the keys must be present in the path expression in the form of predicates.Parameters: - path – The XPath expression identifying the node.
- value – The string representation of the value to set.
Returns: Pointer to
DataNodecreated.Raises: YInvalidArgumentErrorIn case the argument is invalid.Raises: YPathErrorIn case the path is invalid.
-
virtual DataNode &
create_datanode(const std::string &path, const std::string &value)¶ Create a
DataNodecorresponding to the path and set its value.This methods creates a
DataNodetree based on the path passed in. The path expression must identify a single node. If the last node created is of schema typelist,leaf-listoranyxmlthat value is also set in the node.The returned
DataNodeis the last node created (the terminal part of the path).The user is responsible for managing the memory of this returned tree. Use
root()to get the root element of the this tree and use that pointer to dispose of the entire tree.Note
In the case of
listnodes the keys must be present in the path expression in the form of predicates.Parameters: path – The XPath expression identifying the node. Returns: Pointer to DataNodecreated.Raises: YInvalidArgumentErrorIn case the argument is invalid.Raises: YPathErrorIn case the path is invalid.
-
virtual DataNode &
create_action(const std::string &path)¶ Creates a
DataNoderepresenting a YANG 1.1 action corresponding to the path and set its value.This methods creates a
DataNodetree based on the path passed in. The path expression must identify a single node.The returned
DataNodeis the last node created (the terminal part of the path).Parameters: - path – The XPath expression identifying the node.
- value – The string representation of the value to set.
Returns: Pointer to
DataNodecreated.Raises: YInvalidArgumentErrorIn case the argument is invalid.Raises: YPathErrorIn case the path is invalid.
-
virtual void
set_value(const std::string &value)¶ Set the value of this
DataNode.Note
- The
DataNodeshould represent aleaf,leaf-listoranyxmlelement for this to work. The value should be the string representation of the type of according to the schema. - This method does not validate the value being set. To validate please see the
ValidationService.
Parameters: value – The value to set. This should be the string representation of the YANG type. Raises: YInvalidArgumentErrorif theDataNode‘s value cannot be set (for example it represents a container)- The
-
virtual std::string
get_value() const¶ Returns a copy of the value of this
DataNode.Returns: A std::stringrepresentation of the value.
-
virtual std::vector<std::shared_ptr<DataNode>>
find(const std::string &path)¶ Finds nodes that satisfy the given path expression. For details about the path expression see how to path.
Parameters: path – The path expression. Returns: Vector of DataNodethat satisfy the path expression supplied.
-
virtual DataNode *
get_parent() const¶ Returns: Pointer to the parent of this DataNodeornullptrif None exist.
-
virtual std::vector<std::shared_ptr<DataNode>>
get_children() const¶ Returns: Pointer to the children of this DataNode.
-
virtual std::shared_ptr<DataNode>
operator()(const Session &session)¶ Execute/Invoke the action contained in the DataNode through the given Session and return the output of the action as a DataNode.
Parameters: session – The Session. Returns: Pointer to the DataNodeornullptrif none exists.
-
virtual bool
has_action() const¶ Returns: true if the DataNode contains any action node created by invoking create_action.
-
virtual void
add_annotation(const Annotation &an)¶ This method adds the annotation to this
Datanode.Parameters: an – The annotation to add to this DataNode.Raises: YInvalidArgumentErrorin case the argument is invalid.
-
virtual bool
remove_annotation(const Annotation &an)¶ This method will remove the annotation from the given node.
Note
The
m_valfor annotation is ignored.Parameters: an – The reference to the annotation. Returns: boolIf true the annotation was found and removed, false otherwise.
-
virtual std::vector<Annotation>
annotations()¶ Get the annotations associated with this data node.
Returns: Vector of Annotationfor this node.
-
virtual