Click or drag to resize

ViseratorTItem, TState Class

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 Hierarchy
SystemObject
  Fusee.XeneSceneVisitor
    Fusee.XeneViseratorBaseTItem
      Fusee.XeneViseratorTItem, TState
        Fusee.Engine.CoreLightSetup
        Fusee.Engine.CoreScenePicker

Namespace:  Fusee.Xene
Assembly:  Fusee.Xene (in Fusee.Xene.dll) Version: 0.7.0.0 (0.7.0.0)
Syntax
C#
public abstract class Viserator<TItem, TState> : ViseratorBase<TItem>
where TState : new(), IStateStack

Type Parameters

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.

The ViseratorTItem, TState type exposes the following members.

Constructors
  NameDescription
Public methodViseratorTItem, TState
Initializes a new instance of the ViseratorTItem, TState class.
Public methodViseratorTItem, TState(IEnumeratorSceneNodeContainer)
Initializes a new instance of the ViseratorTItem, TState class.
Top
Properties
  NameDescription
Public propertyCurrent
Gets the element in the collection at the current position of the enumerator.
(Inherited from ViseratorBaseTItem.)
Protected propertyCurrentComponent
Returns the currently visited component during a traversal.
(Inherited from SceneVisitor.)
Protected propertyCurrentNode
Returns currently visited node during a traversal.
(Inherited from SceneVisitor.)
Protected propertyYieldEnumeration
Gets a value indicating whether the current enumeration should yield.
(Inherited from SceneVisitor.)
Protected propertyYieldOnCurrentComponent
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.
(Inherited from SceneVisitor.)
Protected propertyYieldOnCurrentNode
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.
(Inherited from SceneVisitor.)
Top
Methods
  NameDescription
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from ViseratorBaseTItem.)
Protected methodEnumInit
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.
(Inherited from SceneVisitor.)
Protected methodEnumMoveNext
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 ViseratorTItem, TState
(Inherited from SceneVisitor.)
Protected methodEnumMoveNextNoComponent
Continue a currently active enumeration. Call all registered Visit methods. Visitor methods may set YieldOnCurrentComponent or YieldOnCurrentNode to true to signal the enumration to yield.
(Inherited from SceneVisitor.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodInit (Overrides ViseratorBaseTItemInit(IEnumeratorSceneNodeContainer).)
Protected methodInitState
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.
(Overrides SceneVisitorInitState.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodMoveNext
Advances the enumerator to the next element of the collection.
(Inherited from ViseratorBaseTItem.)
Protected methodPopState
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.
(Overrides SceneVisitorPopState.)
Protected methodPushState
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.
(Overrides SceneVisitorPushState.)
Public methodReset
Sets the enumerator to its initial position, which is before the first element in the collection.
(Inherited from ViseratorBaseTItem.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTraverse(SceneNodeContainer)
Start traversing a scene graph starting with the given root node. Performs a recursive depth-first traversal from the speciefiedd root.
(Inherited from SceneVisitor.)
Public methodTraverse(IEnumerableSceneNodeContainer)
Start traversing a list of nodes. Performs a recursive depth-first traversal over the list starting with the first node in the list.
(Inherited from SceneVisitor.)
Public methodViserate (Inherited from ViseratorBaseTItem.)
Protected methodYieldItem
Call this method in visitor methods of derived Viserator classes to signal that an item should be propagated to the traversal's result enumeration.
(Inherited from ViseratorBaseTItem.)
Top
Fields
  NameDescription
Protected fieldState
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 pre-defined implementations. See VisitorState how to implement your own state type.
Top
Remarks
Very often you want to traverse a node-component-graph while maintaining a traversal state keeping track of inividual 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 ViseratorTItem, TState 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 and enumerator. Look up "to viscerate" in a dictionary and judge for yourself if a Viserator's operation resembles disembowelling the innards of a tree structure.

See Also