Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

VisitorCore< N > Class Template Reference

Core visitor functionality. More...

#include <Composite.h>

Inheritance diagram for VisitorCore< N >:

VisitorBase Referenced List of all members.

Public Types

typedef CompositeBase< N > Node
 Base class type for nodes in the graph.

enum  TraversalMode { TRAVERSE_NONE, TRAVERSE_CHILDREN, TRAVERSE_PARENTS }
 Composite traversal modes. More...


Public Methods

TraversalMode getTraversalMode () const
 Get the mode for traversing the composite graph.

virtual void apply (Node &node)
 Visit a node and propagate.

 VisitorCore (TraversalMode mode=TRAVERSE_CHILDREN)
 Constructor.


Protected Methods

void traverse (Node &node)
 Propagate from a given node based on the current traversal mode.

void setTraversalMode (TraversalMode mode)
 Change the traversal mode.


Detailed Description

template<class N>
class VisitorCore< N >

Core visitor functionality.

N is a context specific visitable node type.


Member Typedef Documentation

template<class N>
typedef CompositeBase<N> VisitorCore< N >::Node
 

Base class type for nodes in the graph.


Member Enumeration Documentation

template<class N>
enum VisitorCore::TraversalMode
 

Composite traversal modes.

Enumeration values:
TRAVERSE_NONE 
TRAVERSE_CHILDREN 
TRAVERSE_PARENTS 


Constructor & Destructor Documentation

template<class N>
VisitorCore< N >::VisitorCore TraversalMode    mode = TRAVERSE_CHILDREN [inline]
 

Constructor.

Parameters:
mode  The initial traversal mode. The default is TRAVERSE_CHILDREN.


Member Function Documentation

template<class N>
virtual void VisitorCore< N >::apply Node   node [inline, virtual]
 

Visit a node and propagate.

This method is overloaded in the actual visitor classes to apply distinct operations to each type of node. Apply methods should generally conclude with a call to traverse(node) to continue progagation of the visitor through the graph.

template<class N>
TraversalMode VisitorCore< N >::getTraversalMode   const [inline]
 

Get the mode for traversing the composite graph.

template<class N>
void VisitorCore< N >::setTraversalMode TraversalMode    mode [inline, protected]
 

Change the traversal mode.

The initial traversal mode can be set as a contructor parameter. This method allows the traversal mode to be changed on the fly, for example to abort traversal of a graph once a condition is met (such as finding a matching node during a search).

template<class N>
void VisitorCore< N >::traverse Node   node [inline, protected]
 

Propagate from a given node based on the current traversal mode.

TRAVERSE_CHILDREN will visit the subgraph of the node (depth first), while TRAVERSE_PARENTS will visit all parents until the root of the graph is reached.


The documentation for this class was generated from the following file:
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:42 2003, using Doxygen 1.2.18.

[SF.net]