NebulaStream
0.6.213
NebulaStream is a data and application management framework for the internet of things
|
#include <Node.hpp>
Public Member Functions | |
Node () | |
virtual | ~Node ()=default |
bool | addChildWithEqual (NodePtr const &newNode) |
adds a newNode as a child to the current newNode. More... | |
virtual bool | addChild (NodePtr newNode) |
adds a newNode as a child to the current newNode. More... | |
bool | removeChild (NodePtr const &node) |
remove a node from current children. More... | |
virtual bool | addParent (NodePtr newNode) |
add a parent to vector of parents no duplicated node inside parents. one cannot add current node into its parents. More... | |
bool | removeParent (NodePtr const &node) |
remove a parent from vector of parents More... | |
void | removeAllParent () |
Remove all parents. More... | |
void | removeChildren () |
Remove all children. More... | |
bool | replace (const NodePtr &newNode, const NodePtr &oldNode) |
replace an old node with new now 1) old node is the child of current node, remove old node from current nodes's children and add new node to current noed's children. If old node has children, unionWith the children of old nodes and new nodes's children. If there's duplicated children among old nodes and new nodes's children, the children in new noeds will overwrite that inside old noeds's. 2) More... | |
bool | replace (NodePtr newNode) |
replace current node with new node More... | |
bool | swap (NodePtr const &newNode, NodePtr const &oldNode) |
swap given old node by new node More... | |
bool | swapLeftAndRightBranch () |
Swaps the left and right branch of binary nodes, by reversing the vector of children. More... | |
bool | remove (NodePtr const &node) |
remove the given node together with its children More... | |
bool | removeAndLevelUpChildren (NodePtr const &node) |
remove the given node and add its children to the children of the current node More... | |
bool | removeAndJoinParentAndChildren () |
Remove this node as child to its parents and as parent to its children. Once done, the method joins the parent and children together. More... | |
void | clear () |
clear all parents and children More... | |
bool | equalWithAllChildren (NodePtr const &node) |
checks if the current node and its children are equal a other node and its children More... | |
bool | equalWithAllParents (NodePtr const &node) |
checks if the current node and its parents are equal a other node and its parents More... | |
virtual bool | equal (NodePtr const &rhs) const |
check two node are equal. More... | |
virtual bool | isIdentical (NodePtr const &rhs) const |
check two nodes whether are exactly the same object or not More... | |
std::vector< NodePtr > | split (NodePtr const &splitNode) |
split graph into multiple sub-graphs. The graph starts at current splitNode. If the given splitNode is not in the graph, throw exception @params splitNode the given splitNode to split at. More... | |
bool | isValid () |
validation of this node More... | |
template<class NodeType > | |
bool | instanceOf () |
Checks if the current node is of type NodeType. More... | |
template<class NodeType > | |
std::shared_ptr< NodeType > | as () |
Dynamically casts the node to a NodeType. More... | |
template<class NodeType > | |
std::shared_ptr< NodeType > | as_if () |
Dynamically casts the node to a NodeType or returns nullptr. More... | |
template<class NodeType > | |
std::vector< std::shared_ptr< NodeType > > | getNodesByType () |
Collects all nodes that are of a specific node type, e.g. all FilterOperatorNodes. More... | |
bool | isCyclic () |
checks if the node and its children contain cycles. More... | |
std::vector< NodePtr > | getAndFlattenAllChildren (bool withDuplicateChildren) |
return all children of current node Always excluding current node, no matter a cycle exists More... | |
const std::vector< NodePtr > & | getChildren () const |
get direct children. More... | |
virtual bool | containAsGrandParent (NodePtr node) |
Check if the node is present as the parent or grand-parent. More... | |
virtual bool | containAsParent (NodePtr node) |
Check if input node is present as parent to this. More... | |
virtual bool | containAsGrandChild (NodePtr node) |
Check if the node is present as the child or grand-child. More... | |
virtual bool | containAsChild (NodePtr node) |
Check if input node is present as children to this. More... | |
const std::vector< NodePtr > & | getParents () const |
get direct parents. More... | |
std::vector< NodePtr > | getAllRootNodes () |
std::vector< NodePtr > | getAllLeafNodes () |
Get all the leaf nodes. More... | |
bool | insertBetweenThisAndParentNodes (NodePtr const &newNode) |
Add input node as parent to the current node and move the parents of current node as parent to the input node. If the node is already exists as parent then skip the operation. More... | |
bool | insertBetweenThisAndChildNodes (NodePtr const &newNode) |
Add input node as child to the current node and add the input node as new parent to the old child. More... | |
virtual std::string | toString () const =0 |
To string method for the current node. More... | |
virtual std::vector< std::string > | toMultilineString () |
To multiline string method for the current node. More... | |
std::vector< NodePtr > | getAndFlattenAllAncestors () |
Get all nodes that are parents to this node. More... | |
Static Public Member Functions | |
static NodePtr | findRecursively (NodePtr const &root, NodePtr const &nodeToFind) |
check if a node is the child or grandchild of the given root node More... | |
Protected Attributes | |
std::vector< NodePtr > | parents {} |
the parents of this node. There is no equal nodes in this vector More... | |
std::vector< NodePtr > | children {} |
the children of this node. There is no equal nodes in this vector More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const NodePtr &node) |
NES::Node::Node | ( | ) |
|
virtualdefault |
|
virtual |
adds a newNode as a child to the current newNode.
newNode |
References children, and NES_ERROR.
Referenced by insertBetweenThisAndChildNodes().
bool NES::Node::addChildWithEqual | ( | NodePtr const & | newNode | ) |
|
virtual |
add a parent to vector of parents no duplicated node inside parents. one cannot add current node into its parents.
newNode |
References NES_WARNING, and parents.
Referenced by insertBetweenThisAndParentNodes().
|
inline |
Dynamically casts the node to a NodeType.
NodeType |
References toString().
|
inline |
Dynamically casts the node to a NodeType or returns nullptr.
NodeType |
|
virtual |
Check if input node is present as children to this.
References children, backward::details::move(), and NES_DEBUG.
|
virtual |
Check if the node is present as the child or grand-child.
node | node to look for |
References children, backward::details::move(), and NES_TRACE.
|
virtual |
Check if the node is present as the parent or grand-parent.
node | node to look for |
References backward::details::move(), NES_TRACE, and parents.
|
virtual |
Check if input node is present as parent to this.
References backward::details::move(), NES_DEBUG, and parents.
|
inlinevirtual |
check two node are equal.
rhs | the node to compare |
References isIdentical().
Referenced by equalWithAllChildren(), and equalWithAllParents().
bool NES::Node::equalWithAllChildren | ( | NodePtr const & | node | ) |
checks if the current node and its children are equal a other node and its children
node | the node to compare |
References equal().
bool NES::Node::equalWithAllParents | ( | NodePtr const & | node | ) |
checks if the current node and its parents are equal a other node and its parents
node | the node to compare |
References equal().
std::vector< NodePtr > NES::Node::getAllLeafNodes | ( | ) |
std::vector< NodePtr > NES::Node::getAllRootNodes | ( | ) |
Get all the root nodes
References getParents(), NES_DEBUG, and parents.
std::vector< NodePtr > NES::Node::getAndFlattenAllAncestors | ( | ) |
std::vector< NodePtr > NES::Node::getAndFlattenAllChildren | ( | bool | withDuplicateChildren | ) |
return all children of current node Always excluding current node, no matter a cycle exists
withDuplicateChildren | set true to allow to retrieve duplicate elements |
Referenced by isCyclic().
const std::vector< NodePtr > & NES::Node::getChildren | ( | ) | const |
|
inline |
Collects all nodes that are of a specific node type, e.g. all FilterOperatorNodes.
NodeType |
const std::vector< NodePtr > & NES::Node::getParents | ( | ) | const |
get direct parents.
References parents.
Referenced by getAllRootNodes().
bool NES::Node::insertBetweenThisAndChildNodes | ( | NodePtr const & | newNode | ) |
Add input node as child to the current node and add the input node as new parent to the old child.
References addChild(), children, NES_ERROR, NES_INFO, NES_WARNING, and removeChildren().
bool NES::Node::insertBetweenThisAndParentNodes | ( | NodePtr const & | newNode | ) |
Add input node as parent to the current node and move the parents of current node as parent to the input node. If the node is already exists as parent then skip the operation.
References addParent(), NES_DEBUG, NES_ERROR, NES_INFO, NES_WARNING, parents, and removeAllParent().
Referenced by replace().
|
inline |
Checks if the current node is of type NodeType.
NodeType |
bool NES::Node::isCyclic | ( | ) |
checks if the node and its children contain cycles.
References getAndFlattenAllChildren().
Referenced by isValid().
|
inlinevirtual |
check two nodes whether are exactly the same object or not
rhs | the node to check |
Referenced by equal().
bool NES::Node::isValid | ( | ) |
validation of this node
References isCyclic().
bool NES::Node::remove | ( | NodePtr const & | node | ) |
remove the given node together with its children
node | the given node to remove |
References removeChild(), and removeParent().
void NES::Node::removeAllParent | ( | ) |
Remove all parents.
References NES_INFO, parents, and removeParent().
Referenced by insertBetweenThisAndParentNodes().
bool NES::Node::removeAndJoinParentAndChildren | ( | ) |
bool NES::Node::removeAndLevelUpChildren | ( | NodePtr const & | node | ) |
remove the given node and add its children to the children of the current node
node |
References children, magic_enum::detail::n(), and removeChild().
bool NES::Node::removeChild | ( | NodePtr const & | node | ) |
remove a node from current children.
node |
References children, NES_DEBUG, and NES_ERROR.
Referenced by remove(), removeAndLevelUpChildren(), removeChildren(), and replace().
void NES::Node::removeChildren | ( | ) |
Remove all children.
References children, NES_INFO, and removeChild().
Referenced by insertBetweenThisAndChildNodes().
bool NES::Node::removeParent | ( | NodePtr const & | node | ) |
replace an old node with new now 1) old node is the child of current node, remove old node from current nodes's children and add new node to current noed's children. If old node has children, unionWith the children of old nodes and new nodes's children. If there's duplicated children among old nodes and new nodes's children, the children in new noeds will overwrite that inside old noeds's. 2)
newNode | |
oldNode |
References children, insertBetweenThisAndParentNodes(), NES_DEBUG, NES_ERROR, NES_WARNING, parents, removeAndJoinParentAndChildren(), removeChild(), and removeParent().
Referenced by replace().
bool NES::Node::replace | ( | NodePtr | newNode | ) |
replace current node with new node
newNode |
References backward::details::move(), and replace().
split graph into multiple sub-graphs. The graph starts at current splitNode. If the given splitNode is not in the graph, throw exception @params splitNode the given splitNode to split at.
References findRecursively(), and NES_DEBUG.
swap given old node by new node
newNode | the node to mount at oldNode parents instead of oldNode |
oldNode | the node to remove from graph |
References findRecursively().
bool NES::Node::swapLeftAndRightBranch | ( | ) |
Swaps the left and right branch of binary nodes, by reversing the vector of children.
References children, and NES_WARNING.
|
virtual |
To multiline string method for the current node.
References toString().
|
pure virtual |
To string method for the current node.
Referenced by as(), and toMultilineString().
|
friend |
|
protected |
the children of this node. There is no equal nodes in this vector
Referenced by addChild(), addChildWithEqual(), clear(), containAsChild(), containAsGrandChild(), getAllLeafNodes(), getChildren(), insertBetweenThisAndChildNodes(), removeAndJoinParentAndChildren(), removeAndLevelUpChildren(), removeChild(), removeChildren(), replace(), and swapLeftAndRightBranch().
|
protected |
the parents of this node. There is no equal nodes in this vector
Referenced by addParent(), clear(), containAsGrandParent(), containAsParent(), getAllRootNodes(), getAndFlattenAllAncestors(), getParents(), insertBetweenThisAndParentNodes(), removeAllParent(), removeAndJoinParentAndChildren(), removeParent(), and replace().