FSM Library - C++ version
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
TreeNode Class Reference
Inheritance diagram for TreeNode:
Inheritance graph
[legend]
Collaboration diagram for TreeNode:
Collaboration graph
[legend]

Public Member Functions

 TreeNode ()
 
void setParent (const std::weak_ptr< TreeNode > parent)
 
std::weak_ptr< TreeNodegetParent () const
 
void deleteNode ()
 
bool isDeleted () const
 
std::shared_ptr< std::vector< std::shared_ptr< TreeEdge > > > getChildren () const
 
void remove (const std::shared_ptr< TreeNode > node)
 
void calcLeaves (std::vector< std::shared_ptr< TreeNode >> &leaves)
 
void add (const std::shared_ptr< TreeEdge > edge)
 
bool isLeaf () const
 
int getIO (const std::shared_ptr< TreeNode > node) const
 
std::shared_ptr< TreeEdgehasEdge (const std::shared_ptr< TreeEdge > edge) const
 
std::vector< int > getPath ()
 
bool superTreeOf (const std::shared_ptr< TreeNode > otherNode) const
 
std::shared_ptr< TreeNodeadd (const int x)
 
void add (const IOListContainer &tcl)
 
void addToThisNode (const IOListContainer &tcl)
 
std::shared_ptr< TreeNodeafter (std::vector< int >::const_iterator lstIte, const std::vector< int >::const_iterator end)
 

Protected Member Functions

void add (std::vector< int >::const_iterator lstIte, const std::vector< int >::const_iterator end)
 

Protected Attributes

std::weak_ptr< TreeNodeparent
 
std::shared_ptr< std::vector< std::shared_ptr< TreeEdge > > > children
 
bool deleted
 

Friends

bool operator== (TreeNode const &treeNode1, TreeNode const &treeNode2)
 

Constructor & Destructor Documentation

TreeNode::TreeNode ( )

Create a new tree node

Member Function Documentation

void TreeNode::add ( const std::shared_ptr< TreeEdge edge)

Add and edge to this node children

Parameters
edgeThe edge to be added
std::shared_ptr< TreeNode > TreeNode::add ( const int  x)

Conditional addition of a new edge emanating from this node: If an edge labelled by x already exists, nothing is changed, otherwise a new edge is created, and a new leaf node is returned

Parameters
xFSM input
Returns
existing target node under this input, if no new edge has been created, or the new leaf node, if a new edge has been created.

Here is the call graph for this function:

void TreeNode::add ( const IOListContainer tcl)

First delegate the work to the children, then append each input sequence in tcl to this node, using the special strategy of the add(lstIte) operation

Parameters
tclThe IOListContainer to be added

Here is the call graph for this function:

void TreeNode::addToThisNode ( const IOListContainer tcl)

Append each input sequence in tcl to this node, using the special strategy of the add(lstIte) operation

Parameters
tclThe IOListContainer to be added

Here is the call graph for this function:

std::shared_ptr< TreeNode > TreeNode::after ( std::vector< int >::const_iterator  lstIte,
const std::vector< int >::const_iterator  end 
)

Return target TreeNode reached after following the inputs from a given trace in the Tree.

Parameters
lstIteIterator pointing to an element of an InputTrace
endIterator pointing to the last element of an InputTrace
Returns
nullptr if the input trace does not match with any path in the tree TreeNode reached after having successfully matched the whole input trace against the tree.

Here is the call graph for this function:

void TreeNode::calcLeaves ( std::vector< std::shared_ptr< TreeNode >> &  leaves)

Calc the list of leaves of this tree

Parameters
leavesAn empty list, it will be used to insert the leaves

Here is the call graph for this function:

void TreeNode::deleteNode ( )

Mark this node as deleted. If this is a leaf node, remove it from the parent's list of children. If the parent becomes a leaf as an effect of this operation and if the parent is also marked as deleted, remove it as well. This is continued recursively.

Here is the call graph for this function:

std::shared_ptr< std::vector< std::shared_ptr< TreeEdge > > > TreeNode::getChildren ( ) const

Getter for the children

Returns
The children

Here is the caller graph for this function:

int TreeNode::getIO ( const std::shared_ptr< TreeNode node) const

Get the input needed to reach a tree node from this one (the node need to be reacheable in one step)

Parameters
nodeThe node to be searched into the tree node's children target
Returns
The input needed to reach the tree node
std::weak_ptr< TreeNode > TreeNode::getParent ( ) const

Getter for the parent

Returns
The parent
std::vector< int > TreeNode::getPath ( )

Get the inputs needed to reach this specific tree node

Returns
The path
std::shared_ptr< TreeEdge > TreeNode::hasEdge ( const std::shared_ptr< TreeEdge edge) const

Check whether or not this tree node has a specific edge or not

Parameters
edgeThe edge to be searched into the tree node's children
Returns
The tree edge if found, nullptr otherwise
bool TreeNode::isDeleted ( ) const

Check whether or not this node is deleted

Returns
true if this node have been deleted, false otherwise
bool TreeNode::isLeaf ( ) const

Check whether or not this tree node had any child or not

Returns
true if it is a leaf, false otherwise

Here is the caller graph for this function:

void TreeNode::remove ( const std::shared_ptr< TreeNode node)

Remove a tree node from this node's children target

Parameters
nodeThe target to remove
void TreeNode::setParent ( const std::weak_ptr< TreeNode parent)

Set the node to this one parent

Parameters
pparentThe node which will be the parent of this one
bool TreeNode::superTreeOf ( const std::shared_ptr< TreeNode otherNode) const

Compare with an other three node to see if it is a super tree of this one or not

Parameters
otherNodeThe other tree node to compare
Returns
true if the other tree node is a super tree of this one, false otherwise

Friends And Related Function Documentation

bool operator== ( TreeNode const &  treeNode1,
TreeNode const &  treeNode2 
)
friend

Compare two tree node to check if they are the same or not

Parameters
treeNode1The first tree node to compare
treeNode2The second tree node to compare
Returns
true if they are the same, false otherwise

Member Data Documentation

std::shared_ptr<std::vector<std::shared_ptr<TreeEdge> > > TreeNode::children
protected

A list containing the children of this node

bool TreeNode::deleted
protected

Mark this node as deleted

std::weak_ptr<TreeNode> TreeNode::parent
protected

The parent of this node


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