Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

Node Class Template Reference
[Node]

This class provides the basic interface to the node-classes. More...

#include <node.h>

Inheritance diagram for Node:

Inheritance graph
[legend]
Collaboration diagram for Node:

Collaboration graph
[legend]
List of all members.

Public Types

typedef _TContent value_type
typedef value_typereference
typedef const value_typeconst_reference
typedef value_typepointer
typedef const value_typeconst_pointer
typedef NodeIterator< Node<
value_type > > 
iterator
typedef NodeIterator< const
Node< value_type > > 
const_iterator
typedef AllNodeIterator< Node<
value_type > > 
all_iterator
typedef AllNodeIterator< const
Node< value_type > > 
const_all_iterator
typedef PostOrderNodeIterator<
Node< value_type > > 
post_iterator
typedef PostOrderNodeIterator<
const Node< value_type > > 
const_post_iterator
typedef VariableNodeIterator<
Node< value_type > > 
var_iterator
typedef VariableNodeIterator<
const Node< value_type > > 
const_var_iterator
typedef LeaveIterator< Node<
value_type > > 
leave_iterator
typedef LeaveIterator< const
Node< value_type > > 
const_leave_iterator
typedef size_t size_type
typedef ptrdiff_t difference_type
typedef std::reverse_iterator<
iterator
reverse_iterator
typedef std::reverse_iterator<
const_iterator
const_reverse_iterator

Public Methods

 Node ()
 Node (const Node< _TContent > &node)
 Copy Constructor.

 Node (const _TContent &content)
virtual ~Node ()
 Destructor.

virtual Node * construct () const=0
virtual Node * cloneTree () const=0
virtual Node * cloneNode () const=0
virtual Node< _TContent > * getParent ()
 Get the parent of this node.

virtual const Node< _TContent > * getParent () const
virtual Node< _TContent > * getRoot ()
 Get the enclosing (sub-)trees root.

virtual const Node< _TContent > * getRoot () const
virtual Node< _TContent > * getLeftSibling ()
 Get the left neighbor (or sister) of this node.

virtual const Node< _TContent > * getLeftSibling () const
virtual Node< _TContent > * getRightSibling ()
 Get the right neighbor (or sister) of this node.

virtual const Node< _TContent > * getRightSibling () const
virtual const std::list< Node<
_TContent > * > * 
getChildren () const
 Get a list of children of this node.

virtual const std::list< Node * > * getLeaves () const
 Get a list of leaves of this node.

virtual size_type getNumChildren () const
 Get the number of direct children of this node.

virtual size_type getNumDescendants () const
 Get the number of descendants of this node.

virtual int getDepth () const
 Get the maximal depth of the tree.

virtual std::string getName () const
 Get the name of the node.

virtual bool isFixed () const
 Return fixed state.

virtual void recalcLeaves ()
 Update the list of leaves of this node Does nothing for NormalNodes.

virtual void setFixed (bool b)
 Make the node fixed.

virtual void setName (std::string name)
 Set the name of the node.

virtual iterator begin ()
 Get a STL conform iterator to traverse the tree structure beginning with this node (nodes of subtrees n o t included).

virtual const_iterator begin () const
virtual iterator end ()
 Get the 'past the end' iterator.

virtual const_iterator end () const
virtual all_iterator beginAll ()
 Get an STL conform iterator to traverse the tree structure beginning with this node (nodes of subtrees included).

virtual const_all_iterator beginAll () const
virtual const_all_iterator beginAllConst () const
 don't have a glue why the compiler doesn't pick the right const function, so here is an explicit call to get the const iterator

virtual all_iterator endAll ()
 Get the 'past the end' iterator.

virtual const_all_iterator endAll () const
virtual bool addChildFront (Node *node)
 Add a pointer to a child to the node (insert in front).

virtual bool addChildBack (Node *node)
 Add a pointer to a child node to the node (add to back).

virtual bool addChild (Node *node)
 Add a pointer to a child node to the node (insert it where the last one was deleted).

virtual bool addChild (Node *node, unsigned int index)
 Add a pointer to a child to the node (insert it at position index) + index 0: push_front + index > number of children: push_back.

virtual bool addChild (Node *node, typename std::list< Node * >::iterator &iter)
 Add a child to the node (insert it before the position the iterator points to).

virtual std::list< Node * > deleteChild (Node *node)
 Delete a child from the node Returns a list of the children of the deleted node.

virtual bool cutChild (Node *node)
 Delete a child from the node Doesn't delete the child.

virtual void acceptVisitor (NodeVisitorBase< Node< _TContent >, NormalNode< _TContent >, RootNode< _TContent > > *visitor)=0
virtual void acceptVisitor (NodeVisitorBase< const Node< _TContent >, const NormalNode< _TContent >, const RootNode< _TContent > > *visitor) const=0
virtual void reduce ()
 Reduce connected fixed parts of the tree to RootNodes.

virtual pointer getContent ()
virtual const_pointer getContent () const
virtual bool isRootNode () const
 Return true is the node is a RootNode This method is nescessary to distinguisch normal and super nodes inside node.


Protected Types

typedef std::map< const Node<
_TContent > *, Node< _TContent > * > 
OldNewMap

Protected Methods

virtual Node * copy (OldNewMap &nodeMap) const=0
virtual void linkSiblings ()
 Sets the sibling links of node's children right.

virtual void setParent (Node *node)
 Set the nodes parent.

virtual void deleteParent ()
 Delete the nodes parent.

virtual void disconnectChildren ()
 Delete references to the nodes children.

virtual void setProtected (bool)
 Set true to make the RootNode a unit in the enclosing tree Does nothing for NormalNodes.

virtual bool isProtected () const
 Returns protection state.

virtual bool isInner () const
 Check if the node is inner node of a protected tree.


Protected Attributes

Node * m_parent
 tree layout

Node * m_root
 tree layout

Node * m_right_sibling
 tree layout

Node * m_left_sibling
 tree layout

std::list< Node< _TContent > * > m_children
 tree layout

_TContent * m_content
 node configuration

bool m_protected
 node configuration

bool m_fixed
 node configuration : if m_fixed is true, connection to parent node cannot be removed

std::string m_name
 node configuration

std::list< Node * >::iterator m_repairIter
 this iterator points after every delete action to the child in front of which was deleted so its possible to use insert to repair


Friends

class NormalNode< _TContent >
class RootNode< _TContent >

Detailed Description

template<class _TContent>
class treecomp::Node< _TContent >

This class provides the basic interface to the node-classes.

Together with NormalNode and RootNode it implements the 'composite pattern' in an extended way, which means that any node could be a leave.

RootNodes are used as the root of a tree. Trees constructed in this way are recognized as a unit after insertion into another tree. NormalNodes are the basic parts of the tree.

Applicationspecific content of the node is added by the template-parameter _TContent (which must have a public constructor, destructor and copy-constructor).

For copying trees use the function cloneTree(), which gives back a pointer to the copied tree. The assignement operator is only the default version and should _never be used_. It only makes a copy of the data in the copied class, but doesn't copy, what the pointer point to. The Copy Contructor is made protected, so that it cannot be used.

Definition at line 82 of file node.h.


Member Typedef Documentation

typedef AllNodeIterator<Node<value_type> > all_iterator
 

Definition at line 94 of file node.h.

Referenced by Node< value_type >::endAll().

typedef AllNodeIterator<const Node<value_type> > const_all_iterator
 

Definition at line 95 of file node.h.

Referenced by Node< value_type >::endAll(), and Node::getDepth().

typedef NodeIterator<const Node<value_type> > const_iterator
 

Definition at line 93 of file node.h.

Referenced by Node< value_type >::begin(), and Node< value_type >::end().

typedef LeaveIterator<const Node<value_type> > const_leave_iterator
 

Definition at line 101 of file node.h.

typedef const value_type* const_pointer
 

Reimplemented in NormalNode, and RootNode.

Definition at line 90 of file node.h.

Referenced by Node< value_type >::getContent().

typedef PostOrderNodeIterator<const Node<value_type> > const_post_iterator
 

Definition at line 97 of file node.h.

typedef const value_type& const_reference
 

Reimplemented in NormalNode, and RootNode.

Definition at line 88 of file node.h.

typedef std::reverse_iterator<const_iterator> const_reverse_iterator
 

Definition at line 105 of file node.h.

typedef VariableNodeIterator<const Node<value_type> > const_var_iterator
 

Definition at line 99 of file node.h.

typedef ptrdiff_t difference_type
 

Reimplemented in NormalNode, and RootNode.

Definition at line 103 of file node.h.

typedef NodeIterator<Node<value_type> > iterator
 

Definition at line 92 of file node.h.

Referenced by Node< value_type >::begin(), Node< value_type >::end(), and Node::setParent().

typedef LeaveIterator<Node<value_type> > leave_iterator
 

Definition at line 100 of file node.h.

typedef std::map<const Node<_TContent>*, Node<_TContent>*> OldNewMap [protected]
 

Reimplemented in NormalNode, and RootNode.

Definition at line 203 of file node.h.

typedef value_type* pointer
 

Reimplemented in NormalNode, and RootNode.

Definition at line 89 of file node.h.

Referenced by Node< value_type >::getContent().

typedef PostOrderNodeIterator<Node<value_type> > post_iterator
 

Definition at line 96 of file node.h.

typedef value_type& reference
 

Reimplemented in NormalNode, and RootNode.

Definition at line 87 of file node.h.

typedef std::reverse_iterator<iterator> reverse_iterator
 

Definition at line 104 of file node.h.

typedef size_t size_type
 

Reimplemented in NormalNode, and RootNode.

Definition at line 102 of file node.h.

Referenced by Node< value_type >::getNumChildren(), and Node< value_type >::getNumDescendants().

typedef _TContent value_type
 

Reimplemented in NormalNode, and RootNode.

Definition at line 86 of file node.h.

typedef VariableNodeIterator<Node<value_type> > var_iterator
 

Definition at line 98 of file node.h.


Constructor & Destructor Documentation

Node   [explicit]
 

Definition at line 370 of file node.h.

References Node::m_content.

Node const Node< _TContent > &    node [explicit]
 

Copy Constructor.

only content is a real copy. For parent, root and children only the pointer is copied. For a real copy use cloneTree()

Definition at line 397 of file node.h.

References Node::m_content.

Node const _TContent &    content [explicit]
 

Definition at line 381 of file node.h.

References Node::m_content.

~Node   [virtual]
 

Destructor.

Works recursivly.

Definition at line 415 of file node.h.

References Node::m_children, and Node::m_content.


Member Function Documentation

virtual void acceptVisitor NodeVisitorBase< const Node< _TContent >, const NormalNode< _TContent >, const RootNode< _TContent > > *    visitor const [pure virtual]
 

Implemented in NormalNode, and RootNode.

virtual void acceptVisitor NodeVisitorBase< Node< _TContent >, NormalNode< _TContent >, RootNode< _TContent > > *    visitor [pure virtual]
 

Implemented in NormalNode, and RootNode.

bool addChild Node< _TContent > *    node,
typename std::list< Node< _TContent > * >::iterator   iter
[virtual]
 

Add a child to the node (insert it before the position the iterator points to).

Parameters:
node  The node to add
iter  The iterator that gives the position

Definition at line 555 of file node.h.

References Node::addChildBack(), Node::addChildFront(), Node::isInner(), Node::m_children, Node::m_left_sibling, Node::m_right_sibling, Node::recalcLeaves(), Node::setParent(), and Node::setProtected().

bool addChild Node< _TContent > *    node,
unsigned int    index
[virtual]
 

Add a pointer to a child to the node (insert it at position index) + index 0: push_front + index > number of children: push_back.

Parameters:
node  The node to add
index  The position where to add, the child at that position is moved to the back

Definition at line 531 of file node.h.

References Node::addChild(), Node::addChildBack(), Node::addChildFront(), Node::isInner(), and Node::m_children.

bool addChild Node< _TContent > *    node [virtual]
 

Add a pointer to a child node to the node (insert it where the last one was deleted).

Parameters:
node  The node to add

Definition at line 508 of file node.h.

References Node::addChildBack(), Node::isInner(), and Node::m_repairIter.

Referenced by Node::addChild().

bool addChildBack Node< _TContent > *    node [virtual]
 

Add a pointer to a child node to the node (add to back).

Parameters:
node  The node to add

Definition at line 475 of file node.h.

References Node::isInner(), Node::m_children, Node::m_left_sibling, Node::m_right_sibling, Node::recalcLeaves(), Node::setParent(), and Node::setProtected().

Referenced by Node::addChild().

bool addChildFront Node< _TContent > *    node [virtual]
 

Add a pointer to a child to the node (insert in front).

Parameters:
node  The node to add

Definition at line 442 of file node.h.

References Node::isInner(), Node::m_children, Node::m_left_sibling, Node::m_right_sibling, Node::recalcLeaves(), Node::setParent(), and Node::setProtected().

Referenced by Node::addChild().

virtual const_iterator begin   const [inline, virtual]
 

Definition at line 162 of file node.h.

virtual iterator begin   [inline, virtual]
 

Get a STL conform iterator to traverse the tree structure beginning with this node (nodes of subtrees n o t included).

Definition at line 161 of file node.h.

Referenced by Node::setParent().

virtual const_all_iterator beginAll   const [inline, virtual]
 

Definition at line 170 of file node.h.

virtual all_iterator beginAll   [inline, virtual]
 

Get an STL conform iterator to traverse the tree structure beginning with this node (nodes of subtrees included).

Definition at line 169 of file node.h.

Referenced by LayoutVisitor::calculatePosition().

virtual const_all_iterator beginAllConst   const [inline, virtual]
 

don't have a glue why the compiler doesn't pick the right const function, so here is an explicit call to get the const iterator

Definition at line 173 of file node.h.

virtual Node* cloneNode   const [pure virtual]
 

Implemented in NormalNode, and RootNode.

virtual Node* cloneTree   const [pure virtual]
 

Implemented in NormalNode, and RootNode.

virtual Node* construct   const [pure virtual]
 

Implemented in NormalNode, and RootNode.

virtual Node* copy OldNewMap   nodeMap const [protected, pure virtual]
 

Implemented in NormalNode, and RootNode.

bool cutChild Node< _TContent > *    node [virtual]
 

Delete a child from the node Doesn't delete the child.

Parameters:
node  The node to delete

Definition at line 637 of file node.h.

References Node::deleteParent(), Node::isFixed(), Node::m_children, Node::m_left_sibling, Node::m_repairIter, and Node::m_right_sibling.

Referenced by Node::deleteChild().

std::list< Node< _TContent > * > deleteChild Node< _TContent > *    node [virtual]
 

Delete a child from the node Returns a list of the children of the deleted node.

(the list is empty if node is fixed and therefore not deleted, or if the node was a leave)

Parameters:
node  The node to delete

Definition at line 604 of file node.h.

References Node::cutChild(), Node::disconnectChildren(), Node::getLeaves(), Node::isRootNode(), and Node::m_children.

void deleteParent   [protected, virtual]
 

Delete the nodes parent.

This method is called if the node as child is removed.

Reimplemented in RootNode.

Definition at line 701 of file node.h.

References Node::isRootNode(), Node::m_parent, and Node::m_root.

Referenced by Node::cutChild(), and Node::setParent().

void disconnectChildren   [protected, virtual]
 

Delete references to the nodes children.

This method is called if the node as child is removed.

Definition at line 716 of file node.h.

References Node::m_children.

Referenced by Node::deleteChild().

virtual const_iterator end   const [inline, virtual]
 

Definition at line 165 of file node.h.

virtual iterator end   [inline, virtual]
 

Get the 'past the end' iterator.

Definition at line 164 of file node.h.

Referenced by Node::setParent().

virtual const_all_iterator endAll   const [inline, virtual]
 

Definition at line 176 of file node.h.

virtual all_iterator endAll   [inline, virtual]
 

Get the 'past the end' iterator.

Definition at line 175 of file node.h.

Referenced by LayoutVisitor::calculatePosition().

virtual const std::list<Node<_TContent>*>* getChildren   const [inline, virtual]
 

Get a list of children of this node.

Definition at line 132 of file node.h.

Referenced by LayoutVisitor::calculatePosition().

virtual const_pointer getContent   const [inline, virtual]
 

Definition at line 196 of file node.h.

virtual pointer getContent   [inline, virtual]
 

Definition at line 195 of file node.h.

int getDepth   const [virtual]
 

Get the maximal depth of the tree.

Definition at line 428 of file node.h.

References Node::const_all_iterator, and DepthVisitor::getDepth().

virtual const std::list<Node*>* getLeaves   const [inline, virtual]
 

Get a list of leaves of this node.

The list differs from the list obtained by 'getChildren()' only if the node is root of a (sub-) tree (= RootNode).

Reimplemented in RootNode.

Definition at line 136 of file node.h.

Referenced by Node::deleteChild(), and Node::isInner().

virtual const Node<_TContent>* getLeftSibling   const [inline, virtual]
 

Definition at line 127 of file node.h.

virtual Node<_TContent>* getLeftSibling   [inline, virtual]
 

Get the left neighbor (or sister) of this node.

Definition at line 126 of file node.h.

virtual std::string getName   const [inline, virtual]
 

Get the name of the node.

Definition at line 146 of file node.h.

Referenced by TEXGraphOutputStrategy::writeFooter(), TEXGraphOutputStrategy::writeNormalNode(), DefaultOutputStrategy::writeNormalNode(), TEXGraphOutputStrategy::writeRootNode(), and DefaultOutputStrategy::writeRootNode().

virtual size_type getNumChildren   const [inline, virtual]
 

Get the number of direct children of this node.

Definition at line 138 of file node.h.

Referenced by DepthVisitor::measure().

virtual size_type getNumDescendants   const [inline, virtual]
 

Get the number of descendants of this node.

The number differs from the number obtained by 'getNumChildren()' only if the node is root of a (sub-) tree (= RootNode).

Reimplemented in RootNode.

Definition at line 142 of file node.h.

virtual const Node<_TContent>* getParent   const [inline, virtual]
 

Definition at line 121 of file node.h.

virtual Node<_TContent>* getParent   [inline, virtual]
 

Get the parent of this node.

Definition at line 120 of file node.h.

Referenced by LayoutVisitor::calculatePosition(), DepthVisitor::measure(), TEXGraphOutputStrategy::writeEdge(), and TEXGraphOutputStrategy::writeFooter().

virtual const Node<_TContent>* getRightSibling   const [inline, virtual]
 

Definition at line 130 of file node.h.

virtual Node<_TContent>* getRightSibling   [inline, virtual]
 

Get the right neighbor (or sister) of this node.

Definition at line 129 of file node.h.

virtual const Node<_TContent>* getRoot   const [inline, virtual]
 

Definition at line 124 of file node.h.

virtual Node<_TContent>* getRoot   [inline, virtual]
 

Get the enclosing (sub-)trees root.

Definition at line 123 of file node.h.

Referenced by Node::setParent().

virtual bool isFixed   const [inline, virtual]
 

Return fixed state.

Definition at line 148 of file node.h.

Referenced by Node::cutChild(), and TEXGraphOutputStrategy::writeEdge().

bool isInner   const [protected, virtual]
 

Check if the node is inner node of a protected tree.

Returns 'True' if yes, 'False' if not.

Definition at line 584 of file node.h.

References Node::getLeaves(), Node::isProtected(), and Node::m_root.

Referenced by Node::addChild(), Node::addChildBack(), and Node::addChildFront().

virtual bool isProtected   const [inline, protected, virtual]
 

Returns protection state.

Definition at line 214 of file node.h.

Referenced by Node::isInner(), and Node::setParent().

virtual bool isRootNode   const [inline, virtual]
 

Return true is the node is a RootNode This method is nescessary to distinguisch normal and super nodes inside node.

Reimplemented in RootNode.

Definition at line 200 of file node.h.

Referenced by Node::deleteChild(), Node::deleteParent(), and Node::setParent().

void linkSiblings   [protected, virtual]
 

Sets the sibling links of node's children right.

Definition at line 733 of file node.h.

References Node::m_children, and Node::m_left_sibling.

Referenced by RootNode::cloneTree(), NormalNode::cloneTree(), RootNode::copy(), and NormalNode::copy().

virtual void recalcLeaves   [inline, virtual]
 

Update the list of leaves of this node Does nothing for NormalNodes.

Reimplemented in RootNode.

Definition at line 152 of file node.h.

Referenced by Node::addChild(), Node::addChildBack(), and Node::addChildFront().

void reduce   [virtual]
 

Reduce connected fixed parts of the tree to RootNodes.

Definition at line 725 of file node.h.

virtual void setFixed bool    b [inline, virtual]
 

Make the node fixed.

Protect from deleting.

em b True/False

Definition at line 155 of file node.h.

virtual void setName std::string    name [inline, virtual]
 

Set the name of the node.

Definition at line 157 of file node.h.

void setParent Node< _TContent > *    node [protected, virtual]
 

Set the nodes parent.

This method is called if the node is added as child.

Parameters:
node  The node to add as parent

Definition at line 668 of file node.h.

References Node::begin(), Node::deleteParent(), Node::end(), Node::getRoot(), Node::isProtected(), Node::isRootNode(), Node::iterator, Node::m_parent, and Node::m_root.

Referenced by Node::addChild(), Node::addChildBack(), and Node::addChildFront().

virtual void setProtected bool    [inline, protected, virtual]
 

Set true to make the RootNode a unit in the enclosing tree Does nothing for NormalNodes.

Reimplemented in RootNode.

Definition at line 212 of file node.h.

Referenced by Node::addChild(), Node::addChildBack(), and Node::addChildFront().


Friends And Related Function Documentation

friend class NormalNode< _TContent > [friend]
 

Definition at line 107 of file node.h.

friend class RootNode< _TContent > [friend]
 

Definition at line 108 of file node.h.


Member Data Documentation

std::list<Node<_TContent>*> m_children [protected]
 

tree layout

Definition at line 226 of file node.h.

Referenced by Node::addChild(), Node::addChildBack(), Node::addChildFront(), RootNode::cloneTree(), NormalNode::cloneTree(), RootNode::copy(), NormalNode::copy(), Node::cutChild(), Node::deleteChild(), Node::disconnectChildren(), Node< value_type >::getChildren(), Node< value_type >::getLeaves(), Node< value_type >::getNumChildren(), Node< value_type >::getNumDescendants(), Node::linkSiblings(), and Node::~Node().

_TContent* m_content [protected]
 

node configuration

Definition at line 229 of file node.h.

Referenced by RootNode::cloneNode(), Node< value_type >::getContent(), Node::Node(), and Node::~Node().

bool m_fixed [protected]
 

node configuration : if m_fixed is true, connection to parent node cannot be removed

Definition at line 233 of file node.h.

Referenced by Node< value_type >::isFixed(), and Node< value_type >::setFixed().

Node* m_left_sibling [protected]
 

tree layout

Definition at line 224 of file node.h.

Referenced by Node::addChild(), Node::addChildBack(), Node::addChildFront(), Node::cutChild(), Node< value_type >::getLeftSibling(), and Node::linkSiblings().

std::string m_name [protected]
 

node configuration

Definition at line 235 of file node.h.

Referenced by Node< value_type >::getName(), and Node< value_type >::setName().

Node* m_parent [protected]
 

tree layout

Definition at line 218 of file node.h.

Referenced by RootNode::copy(), NormalNode::copy(), RootNode::deleteParent(), Node::deleteParent(), Node< value_type >::getParent(), and Node::setParent().

bool m_protected [protected]
 

node configuration

Definition at line 231 of file node.h.

Referenced by Node< value_type >::isProtected(), and RootNode::setProtected().

std::list<Node*>::iterator m_repairIter [protected]
 

this iterator points after every delete action to the child in front of which was deleted so its possible to use insert to repair

Definition at line 240 of file node.h.

Referenced by Node::addChild(), and Node::cutChild().

Node* m_right_sibling [protected]
 

tree layout

Definition at line 222 of file node.h.

Referenced by Node::addChild(), Node::addChildBack(), Node::addChildFront(), Node::cutChild(), and Node< value_type >::getRightSibling().

Node* m_root [protected]
 

tree layout

Definition at line 220 of file node.h.

Referenced by RootNode::cloneTree(), RootNode::copy(), NormalNode::copy(), RootNode::deleteParent(), Node::deleteParent(), Node< value_type >::getRoot(), Node::isInner(), RootNode::RootNode(), and Node::setParent().


The documentation for this class was generated from the following file:
Generated on Mon Jan 6 12:02:22 2003 for TreeComp by doxygen1.2.17