Class Visitor<TNode, TComponent>
This class tries to serve three goals
- As a base class for visitor patterns. Users can add visitor methods and provide code for different types of visited items.
 - As building block for enumerators. Visitor methods can yield an enumeration.
 - As a tool set to implement transformations on scenes. Transformations operate on scenes and alter their structure.
 
Visitors derived from this class may implement their own Visit methods for all kinds of scene graph elements. Visitor methods can be defined for scene nodes (although many implementations will most likely NOT have a very big inheritance tree for nodes) as well as for scene components. A Visitor method can be any instance method (not static) taking one parameter either derived from INode or derived from IComponent. To mark such a method as a Visitor method it needs to be decorated with the VisitMethodAttribute attribute. Visitor methods can have arbitrary names and don't necessarily need to be virtual.
Inheritance
Inherited Members
Namespace: Fusee.Xene
Assembly: Fusee.Xene.dll
Syntax
public class Visitor<TNode, TComponent>
    where TNode : class, INode where TComponent : class, IComponent
  Type Parameters
| Name | Description | 
|---|---|
| TNode | |
| TComponent | 
Fields
IgnoreInactiveComponents
Set this to true if the visitor should skip inactive Components.
Declaration
public bool IgnoreInactiveComponents
  Field Value
| Type | Description | 
|---|---|
| System.Boolean | 
VisitorModules
Declaration
public List<IVisitorModule> VisitorModules
  Field Value
| Type | Description | 
|---|---|
| System.Collections.Generic.List<IVisitorModule> | 
Properties
CurrentComponent
Returns the currently visited component during a traversal.
Declaration
protected TComponent CurrentComponent { get; }
  Property Value
| Type | Description | 
|---|---|
| TComponent | The current component.  | 
      
CurrentNode
Returns currently visited node during a traversal.
Declaration
protected TNode CurrentNode { get; }
  Property Value
| Type | Description | 
|---|---|
| TNode | The current node.  | 
      
YieldEnumeration
Gets a value indicating whether the current enumeration should yield.
Declaration
protected bool YieldEnumeration { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
  | 
      
YieldOnCurrentComponent
Can be called in derived visitors. Set this property to true during traversals to make the visitor yield the current component when used as an enumerator.
Declaration
protected bool YieldOnCurrentComponent { get; set; }
  Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
  | 
      
YieldOnCurrentNode
Can be called in derived visitors. Set this property to true during traversals to make the visitor yield the current node when used as an enumerator.
Declaration
protected bool YieldOnCurrentNode { get; set; }
  Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
  | 
      
Methods
EnumInit(IEnumerator<TNode>)
Enumerator Building Block to be called in derived Visitors acting as enumerators. Use this to initialize the traversing enumeration on a list of (root) nodes.
Declaration
protected void EnumInit(IEnumerator<TNode> nodes)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerator<TNode> | nodes | The list of nodes.  | 
      
EnumMoveNext()
This method implements a re-entrant (in terms of yield, not multi-threading) non-recursive traversal over combined node and component trees. Call this method in derived classes implementing enumerators, like in the various find extension methods or the Viserator<TItem, TState, TNode, TComponent>
Declaration
protected bool EnumMoveNext()
  Returns
| Type | Description | 
|---|---|
| System.Boolean | 
  | 
      
EnumMoveNextNoComponent()
Continue a currently active enumeration. Call all registered Visit methods. Visitor methods may set YieldOnCurrentComponent or YieldOnCurrentNode to true to signal the enumeration to yield.
Declaration
protected bool EnumMoveNextNoComponent()
  Returns
| Type | Description | 
|---|---|
| System.Boolean | true if the enumeration is not finished yet (i.e. if components/nodes are still unvisited). false otherwise.  | 
      
InitState()
Method is called when traversal starts to initialize the traversal state. Override this method in derived classes to initialize any state.
Declaration
protected virtual void InitState()
  PopState()
Method is called when going up one hierarchy level while traversing. Override this method to perform pop on any self-defined state.
Declaration
protected virtual void PopState()
  PushState()
Method is called when going down one hierarchy level while traversing. Override this method to push any self-defined state.
Declaration
protected virtual void PushState()
  Traverse(TNode)
Start traversing a scene graph starting with the given root node. Performs a recursive depth-first traversal from the specified root.
Declaration
public void Traverse(TNode rootNode)
  Parameters
| Type | Name | Description | 
|---|---|---|
| TNode | rootNode | The root node where to start the traversal.  | 
      
Traverse(IEnumerable<TNode>)
Start traversing a list of nodes. Performs a recursive depth-first traversal over the list starting with the first node in the list.
Declaration
public void Traverse(IEnumerable<TNode> children)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<TNode> | children | The list of nodes to traverse over.  |