Show / Hide Table of Contents

Class Viserator<TItem, TState, TNode, TComponent>

A Viserator is a scene visitor which returns an enumerator of a user defined type. Serves as a base class for use-cases where traversing a node-component-graph should yield a list (enumerator) of results.

Inheritance
System.Object
Visitor<TNode, TComponent>
ViseratorBase<TItem, TNode, TComponent>
Viserator<TItem, TState, TNode, TComponent>
ScenePicker
SceneRayCaster
Implements
System.Collections.Generic.IEnumerator<TItem>
System.Collections.IEnumerator
System.IDisposable
Inherited Members
ViseratorBase<TItem, TNode, TComponent>.Init(IEnumerable<TNode>)
ViseratorBase<TItem, TNode, TComponent>.MoveNext()
ViseratorBase<TItem, TNode, TComponent>.Reset()
ViseratorBase<TItem, TNode, TComponent>.Current
ViseratorBase<TItem, TNode, TComponent>.IEnumerator.Current
ViseratorBase<TItem, TNode, TComponent>.YieldItem(TItem)
ViseratorBase<TItem, TNode, TComponent>.Viserate()
ViseratorBase<TItem, TNode, TComponent>.Dispose()
ViseratorBase<TItem, TNode, TComponent>.Dispose(Boolean)
Visitor<TNode, TComponent>.IgnoreInactiveComponents
Visitor<TNode, TComponent>.Traverse(TNode)
Visitor<TNode, TComponent>.Traverse(IEnumerable<TNode>)
Visitor<TNode, TComponent>.InitState()
Visitor<TNode, TComponent>.PushState()
Visitor<TNode, TComponent>.PopState()
Visitor<TNode, TComponent>.CurrentNode
Visitor<TNode, TComponent>.CurrentComponent
Visitor<TNode, TComponent>.YieldOnCurrentNode
Visitor<TNode, TComponent>.YieldOnCurrentComponent
Visitor<TNode, TComponent>.YieldEnumeration
Visitor<TNode, TComponent>.EnumInit(IEnumerator<TNode>)
Visitor<TNode, TComponent>.EnumMoveNext()
Visitor<TNode, TComponent>.EnumMoveNextNoComponent()
Visitor<TNode, TComponent>.VisitorModules
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Fusee.Xene
Assembly: Fusee.Xene.dll
Syntax
public abstract class Viserator<TItem, TState, TNode, TComponent> : ViseratorBase<TItem, TNode, TComponent>, IEnumerator<TItem>, IEnumerator, IDisposable where TState : IStateStack, new()
    where TNode : class, INode where TComponent : class, IComponent
Type Parameters
Name Description
TItem

The type of the result yielded by the enumerator.

TState

The type of the state to use during traversal. See VisitorState how to implement your own state type.

TNode

The root type of nodes the trees passed to the constructor is built from.

TComponent

The root type of components used in the given trees.

Remarks

Very often you want to traverse a node-component-graph while maintaining a traversal state keeping track of individual values and their changes while traversing. At certain points during the traversal a result arises that should be promoted to the outside of the traversal. Typically the result is derived from the state at a certain time during traversal and some additional information of the tree object currently visited.

To implement your own Viserator you should consider which state information the Viserator must keep track of. Either you assemble your own State type by deriving from VisitorState or choose to use one of the standard state types like StandardState. Then you need to derive your own class from Viserator<TItem, TState, TNode, TComponent> with the TState replaced by your choice of State and TItem replaced by the type of the items you want your Viserator to yield during the traversal.

The word Viserator is a combination of a visitor and enumerator. Look up "to viscerate" in a dictionary and judge for yourself if a Viserator's operation resembles disemboweling the innards of a tree structure.

Constructors

Viserator()

Initializes a new instance of the Viserator<TItem, TState, TNode, TComponent> class.

Declaration
public Viserator()

Viserator(IEnumerable<TNode>)

Initializes a new instance of the Viserator<TItem, TState, TNode, TComponent> class.

Declaration
public Viserator(IEnumerable<TNode> rootList)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TNode> rootList

The root list.

Fields

State

The state to keep track of during traversal. You can use your own implementation (as long as it implements IStateStack or use one of the predefined implementations. See VisitorState how to implement your own state type.

Declaration
protected TState State
Field Value
Type Description
TState

Methods

Init(IEnumerable<TNode>)

Initializes this viserator using the specified root list.

Declaration
protected override void Init(IEnumerable<TNode> rootList)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TNode> rootList

The tree to traverse.

Overrides
Fusee.Xene.ViseratorBase<TItem, TNode, TComponent>.Init(System.Collections.Generic.IEnumerable<TNode>)

InitState()

This method is called when traversal starts to initialize the traversal state. Override this method in derived classes to initialize any state beyond the standard State. Most visitors will simply initialize the State and will thus NOT need to override this method. Make sure to call the base implementation in overridden versions.

Declaration
protected override void InitState()
Overrides
Fusee.Xene.Visitor<TNode, TComponent>.InitState()

PopState()

This method is called when going up one hierarchy level while traversing. Pops the traversal state stack State. Most visitors will simply perform pop on the State and will thus NOT need to override this method. Make sure to call the base implementation in overridden versions.

Declaration
protected override void PopState()
Overrides
Fusee.Xene.Visitor<TNode, TComponent>.PopState()

PushState()

This method is called when going down one hierarchy level while traversing. Pushes the traversal state stack State. Most visitors will simply push the State and will thus NOT need to override this method. Make sure to call the base implementation in overridden versions.

Declaration
protected override void PushState()
Overrides
Fusee.Xene.Visitor<TNode, TComponent>.PushState()

Implements

System.Collections.Generic.IEnumerator<T>
System.Collections.IEnumerator
System.IDisposable
Generated by DocFX
GitHub Repo
Back to top