CompositeNode Class Reference

#include <CompositeNode.h>

Inherited by VisComponent.

Inheritance diagram for CompositeNode:

Inheritance graph
[legend]
Collaboration diagram for CompositeNode:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void addChild (CompositeNode *node)
void addChildren (std::list< CompositeNode * > nodes)
void removeChild (CompositeNode *child)
void removeAllChildren ()
void moveChildToFront (CompositeNode *child)
void moveNodeToFront ()
void moveNodeTo (CompositeNode *parentNode)
CompositeNodegetParent ()
void setParent (CompositeNode *node)
std::list< CompositeNode * > getChildren ()
void setChildren (std::list< CompositeNode * > nodes)
bool isLeaf ()
void setLeaf (bool state)

Protected Attributes

CompositeNodeparent
std::list< CompositeNode * > children
bool leaf

Detailed Description

This class implements a node in a composite design pattern.

Author:
Fabricio Anastacio - fabriciocfa@yahoo.com
Since:
June 25, 2007


Member Function Documentation

void CompositeNode::addChild ( CompositeNode node  )  [inline]

Adds the given node as a child to this one and updates the parent pointer in the child node. If this node is marked as a leaf or is the same as the this one, nothing is done.

Parameters:
node the node to be added as a child.

void CompositeNode::addChildren ( std::list< CompositeNode * >  nodes  ) 

Adds the given list of nodes as children of this node. If this node is marked as a leaf, nothing is done.

Parameters:
nodes a list of nodes to be made children of this node.

void CompositeNode::removeChild ( CompositeNode child  )  [inline]

Removes the child at the given index. If this node is marked as a leaf, nothing is done.

Parameters:
child the child to be removed.

void CompositeNode::removeAllChildren (  )  [inline]

Removes all children of this node. If this node is marked as a leaf, nothing is done.

void CompositeNode::moveChildToFront ( CompositeNode child  )  [inline]

Moves the specified child to the front of the children list. if the given component is not a child, it is added at the front of the children list. If this node is marked as a leaf, nothing is done.

Parameters:
child the child to be moved to the front of the children list.

void CompositeNode::moveNodeToFront (  ) 

Moves this node to the front of its parent children list and propagates this change up to the root of composition.

void CompositeNode::moveNodeTo ( CompositeNode parentNode  ) 

Moves this node to be a child of the given parent. It is different from the addChild() method in the sense that this method removes this node from its previous parent children list, adds it to new parent children list, and updates this node parent link. If the given parent node is NULL or if the given parent node is the same as this node current parent, nothing is done.

Parameters:
parentNode the node that will be made the parent of this one.

CompositeNode* CompositeNode::getParent (  )  [inline]

Returns a pointer to the parent of this node.

Returns:
a pointer to the parent of this node.

void CompositeNode::setParent ( CompositeNode node  )  [inline]

Sets the parent of this node, as long as the given node is not this one.

Parameters:
node a pointer to the node to be made the parent of this one.

std::list<CompositeNode*> CompositeNode::getChildren (  )  [inline]

Returns the list of children of this node.

Returns:
the list of children of this node.

void CompositeNode::setChildren ( std::list< CompositeNode * >  nodes  )  [inline]

Sets the children of this node. If this node is marked as a leaf, nothing is done.

Parameters:
nodes the list of nodes to be set as the children of this node.

bool CompositeNode::isLeaf (  )  [inline]

Returns true if this node is a leaf.

Returns:
true if this node is a leaf, false otherwise.

void CompositeNode::setLeaf ( bool  state  )  [inline]

Sets this node to be a leaf or not.

Parameters:
state true if this node is supposed to be a leaf, false otherwise.


Member Data Documentation

CompositeNode* CompositeNode::parent [protected]

The parent of this node. NULL if this is a root node.

std::list<CompositeNode*> CompositeNode::children [protected]

The list of children of this node. NULL if this is a leaf node.

bool CompositeNode::leaf [protected]

Flag indicating if this node is a leaf.


The documentation for this class was generated from the following files:
Generated on Fri Dec 21 17:43:49 2007 for LargeDisplayFramework by  doxygen 1.5.2