NebulaStream  0.6.213
NebulaStream is a data and application management framework for the internet of things
NES::Node Class Referenceabstract

#include <Node.hpp>

Collaboration diagram for NES::Node:
[legend]

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< NodePtrsplit (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< NodePtrgetAndFlattenAllChildren (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< NodePtrgetAllRootNodes ()
 
std::vector< NodePtrgetAllLeafNodes ()
 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< NodePtrgetAndFlattenAllAncestors ()
 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< NodePtrparents {}
 the parents of this node. There is no equal nodes in this vector More...
 
std::vector< NodePtrchildren {}
 the children of this node. There is no equal nodes in this vector More...
 

Friends

std::ostream & operator<< (std::ostream &os, const NodePtr &node)
 

Constructor & Destructor Documentation

◆ Node()

NES::Node::Node ( )

References NES::collectAndPrintStacktrace().

Here is the call graph for this function:

◆ ~Node()

virtual NES::Node::~Node ( )
virtualdefault

Member Function Documentation

◆ addChild()

bool NES::Node::addChild ( NodePtr  newNode)
virtual

adds a newNode as a child to the current newNode.

Note
Duplicates inside the children are ignored.
A newNode cannot be in its own child.
Parameters
newNode

References children, and NES_ERROR.

Referenced by insertBetweenThisAndChildNodes().

Here is the caller graph for this function:

◆ addChildWithEqual()

bool NES::Node::addChildWithEqual ( NodePtr const &  newNode)

adds a newNode as a child to the current newNode.

Note
Duplicates inside the children are not ignored.
A newNode cannot be in its own child.
Parameters
newNode

References children, and NES_DEBUG.

◆ addParent()

bool NES::Node::addParent ( NodePtr  newNode)
virtual

add a parent to vector of parents no duplicated node inside parents. one cannot add current node into its parents.

Parameters
newNode

References NES_WARNING, and parents.

Referenced by insertBetweenThisAndParentNodes().

Here is the caller graph for this function:

◆ as()

template<class NodeType >
std::shared_ptr<NodeType> NES::Node::as ( )
inline

Dynamically casts the node to a NodeType.

Template Parameters
NodeType
Returns
returns a shared pointer of the NodeType

References toString().

Here is the call graph for this function:

◆ as_if()

template<class NodeType >
std::shared_ptr<NodeType> NES::Node::as_if ( )
inline

Dynamically casts the node to a NodeType or returns nullptr.

Template Parameters
NodeType
Returns
returns a shared pointer of the NodeType or nullptr if the type can't be casted.

◆ clear()

void NES::Node::clear ( )

clear all parents and children

References children, and parents.

◆ containAsChild()

bool NES::Node::containAsChild ( NodePtr  node)
virtual

Check if input node is present as children to this.

Returns
true if input node is in children list

References children, backward::details::move(), and NES_DEBUG.

Here is the call graph for this function:

◆ containAsGrandChild()

bool NES::Node::containAsGrandChild ( NodePtr  node)
virtual

Check if the node is present as the child or grand-child.

Parameters
nodenode to look for
Returns
true if present as false

References children, backward::details::move(), and NES_TRACE.

Here is the call graph for this function:

◆ containAsGrandParent()

bool NES::Node::containAsGrandParent ( NodePtr  node)
virtual

Check if the node is present as the parent or grand-parent.

Parameters
nodenode to look for
Returns
true if present as false

References backward::details::move(), NES_TRACE, and parents.

Here is the call graph for this function:

◆ containAsParent()

bool NES::Node::containAsParent ( NodePtr  node)
virtual

Check if input node is present as parent to this.

Returns
true if input node is in parent list

References backward::details::move(), NES_DEBUG, and parents.

Here is the call graph for this function:

◆ equal()

virtual bool NES::Node::equal ( NodePtr const &  rhs) const
inlinevirtual

check two node are equal.

Parameters
rhsthe node to compare
Returns
bool true if they are the same otherwise false

References isIdentical().

Referenced by equalWithAllChildren(), and equalWithAllParents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ equalWithAllChildren()

bool NES::Node::equalWithAllChildren ( NodePtr const &  node)

checks if the current node and its children are equal a other node and its children

Parameters
nodethe node to compare
Returns
bool

References equal().

Here is the call graph for this function:

◆ equalWithAllParents()

bool NES::Node::equalWithAllParents ( NodePtr const &  node)

checks if the current node and its parents are equal a other node and its parents

Parameters
nodethe node to compare
Returns
bool

References equal().

Here is the call graph for this function:

◆ findRecursively()

NodePtr NES::Node::findRecursively ( NodePtr const &  root,
NodePtr const &  nodeToFind 
)
static

check if a node is the child or grandchild of the given root node

Parameters
rootthe root node
nodeToFindthe node to find
Returns
return true if the given nodeToFind is found in the graph of root, otherwise false

Referenced by split(), and swap().

Here is the caller graph for this function:

◆ getAllLeafNodes()

std::vector< NodePtr > NES::Node::getAllLeafNodes ( )

Get all the leaf nodes.

Returns
vector of leaf nodes

References children, and NES_DEBUG.

◆ getAllRootNodes()

std::vector< NodePtr > NES::Node::getAllRootNodes ( )

Get all the root nodes

Returns
vector of root nodes

References getParents(), NES_DEBUG, and parents.

Here is the call graph for this function:

◆ getAndFlattenAllAncestors()

std::vector< NodePtr > NES::Node::getAndFlattenAllAncestors ( )

Get all nodes that are parents to this node.

Returns
vector of all of its parent nodes

References NES_TRACE, and parents.

◆ getAndFlattenAllChildren()

std::vector< NodePtr > NES::Node::getAndFlattenAllChildren ( bool  withDuplicateChildren)

return all children of current node Always excluding current node, no matter a cycle exists

Parameters
withDuplicateChildrenset true to allow to retrieve duplicate elements
Returns
allChildren a vector to store all children of current node

Referenced by isCyclic().

Here is the caller graph for this function:

◆ getChildren()

const std::vector< NodePtr > & NES::Node::getChildren ( ) const

get direct children.

Returns
vector of children.

References children.

◆ getNodesByType()

template<class NodeType >
std::vector<std::shared_ptr<NodeType> > NES::Node::getNodesByType ( )
inline

Collects all nodes that are of a specific node type, e.g. all FilterOperatorNodes.

Template Parameters
NodeType
Returns
vector of nodes

◆ getParents()

const std::vector< NodePtr > & NES::Node::getParents ( ) const

get direct parents.

Returns
vector of parents.

References parents.

Referenced by getAllRootNodes().

Here is the caller graph for this function:

◆ insertBetweenThisAndChildNodes()

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.

Returns
true if operation succeeded else false

References addChild(), children, NES_ERROR, NES_INFO, NES_WARNING, and removeChildren().

Here is the call graph for this function:

◆ insertBetweenThisAndParentNodes()

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.

Returns
true if operation succeeded else false

References addParent(), NES_DEBUG, NES_ERROR, NES_INFO, NES_WARNING, parents, and removeAllParent().

Referenced by replace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ instanceOf()

template<class NodeType >
bool NES::Node::instanceOf ( )
inline

Checks if the current node is of type NodeType.

Template Parameters
NodeType
Returns
bool true if node is of NodeType

◆ isCyclic()

bool NES::Node::isCyclic ( )

checks if the node and its children contain cycles.

Returns
true if cyclic

References getAndFlattenAllChildren().

Referenced by isValid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isIdentical()

virtual bool NES::Node::isIdentical ( NodePtr const &  rhs) const
inlinevirtual

check two nodes whether are exactly the same object or not

Parameters
rhsthe node to check
Returns
bool true if they are the same object otherwise false

Referenced by equal().

Here is the caller graph for this function:

◆ isValid()

bool NES::Node::isValid ( )

validation of this node

Returns
true if there is no ring/node inside this node's children, otherwise false

References isCyclic().

Here is the call graph for this function:

◆ remove()

bool NES::Node::remove ( NodePtr const &  node)

remove the given node together with its children

Parameters
nodethe given node to remove
Returns
bool true if successful

References removeChild(), and removeParent().

Here is the call graph for this function:

◆ removeAllParent()

void NES::Node::removeAllParent ( )

Remove all parents.

References NES_INFO, parents, and removeParent().

Referenced by insertBetweenThisAndParentNodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeAndJoinParentAndChildren()

bool NES::Node::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.

Returns
bool true if successful

References children, NES_DEBUG, NES_ERROR, and parents.

Referenced by replace().

Here is the caller graph for this function:

◆ removeAndLevelUpChildren()

bool NES::Node::removeAndLevelUpChildren ( NodePtr const &  node)

remove the given node and add its children to the children of the current node

Parameters
node
Returns
bool true if successful

References children, magic_enum::detail::n(), and removeChild().

Here is the call graph for this function:

◆ removeChild()

bool NES::Node::removeChild ( NodePtr const &  node)

remove a node from current children.

Parameters
node

References children, NES_DEBUG, and NES_ERROR.

Referenced by remove(), removeAndLevelUpChildren(), removeChildren(), and replace().

Here is the caller graph for this function:

◆ removeChildren()

void NES::Node::removeChildren ( )

Remove all children.

References children, NES_INFO, and removeChild().

Referenced by insertBetweenThisAndChildNodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeParent()

bool NES::Node::removeParent ( NodePtr const &  node)

remove a parent from vector of parents

Parameters
node

References NES_DEBUG, NES_ERROR, and parents.

Referenced by remove(), removeAllParent(), and replace().

Here is the caller graph for this function:

◆ replace() [1/2]

bool NES::Node::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)

Parameters
newNode
oldNode

References children, insertBetweenThisAndParentNodes(), NES_DEBUG, NES_ERROR, NES_WARNING, parents, removeAndJoinParentAndChildren(), removeChild(), and removeParent().

Referenced by replace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace() [2/2]

bool NES::Node::replace ( NodePtr  newNode)

replace current node with new node

Parameters
newNode
Returns

References backward::details::move(), and replace().

Here is the call graph for this function:

◆ split()

std::vector< NodePtr > NES::Node::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.

Returns
vector of multiple sub-graphs.

References findRecursively(), and NES_DEBUG.

Here is the call graph for this function:

◆ swap()

bool NES::Node::swap ( NodePtr const &  newNode,
NodePtr const &  oldNode 
)

swap given old node by new node

Parameters
newNodethe node to mount at oldNode parents instead of oldNode
oldNodethe node to remove from graph
Returns
true if swapping successfully otherwise false

References findRecursively().

Here is the call graph for this function:

◆ swapLeftAndRightBranch()

bool NES::Node::swapLeftAndRightBranch ( )

Swaps the left and right branch of binary nodes, by reversing the vector of children.

Returns
bool true if successful

References children, and NES_WARNING.

◆ toMultilineString()

std::vector< std::string > NES::Node::toMultilineString ( )
virtual

To multiline string method for the current node.

Returns
string

References toString().

Here is the call graph for this function:

◆ toString()

virtual std::string NES::Node::toString ( ) const
pure virtual

To string method for the current node.

Returns
string

Referenced by as(), and toMultilineString().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const NodePtr node 
)
friend

Member Data Documentation

◆ children

◆ parents

std::vector<NodePtr> NES::Node::parents {}
protected

The documentation for this class was generated from the following files: