Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Transition Class Reference

#include <Transition.h>

Inheritance diagram for Transition:

Inheritance graph
[legend]
List of all members.

Detailed Description

Represents a transition between StateNodes.

This is an abstract class - you'll want to subclass it to put conditions on the transitions. Transitions are "smart" - they are behaviors in and of themselves and can listen for events and use the standard DoStart/DoStop interface. Based on the events they receive, they can fire() themselves and cause a state transition.

DoStart() will be called when this transition is 'active' - it should listen/monitor for the transition it represents until DoStop() is called.

If the conditions are satisified for a transition, you should call fire() to do the appropriate notifications.

Also note that a transition can have multiple sources and destinations. See fire().

When setting up, the flow of additions follows the flow of control. In other words, you add a transition to a source, and you add a destination to a transition. This makes the code simpler because it doesn't have to worry about recursive looping depending whether the source was added to the transition or the transition was added to the source. Confusing? Exactly.

A template file is available at project/templates/transition.h, which will help you get moving faster.

Definition at line 38 of file Transition.h.

Public Member Functions

virtual ~Transition ()
 destructor
virtual void fire ()
 call this when the transition should be made, base class version simply calls StateNode::DoStop() on each active of srcs and StateNode::DoStart() on each inactive of dsts, but you can override.
virtual std::vector< StateNode * > & getSources ()
 returns a user-modifiable reference to the current source list
virtual const std::vector<
StateNode * > & 
getSources () const
 returns a const reference to the current source list
virtual void addDestination (StateNode *destination)
 if destination is non-null, add it to the destination list
virtual std::vector< StateNode * > & getDestinations ()
 returns a user-modifiable reference to the current destination list
virtual const std::vector<
StateNode * > & 
getDestinations () const
 returns a const reference to the current destination list
virtual void setSound (const std::string &snd)
 set a sound file to be played upon activation; you might want to preload this in the parent node; empty string to turn off
virtual std::string getSound ()
 returns the current sound file
virtual std::string getName () const
 If instanceName == className, will autogenerate a name incorporating source and destination names.

Protected Member Functions

 Transition (const std::string &classname)
 constructor, pass your subclass type name as a string for the default name
 Transition (const std::string &classname, StateNode *destination)
 constructor, specify destination StateNode (ignores NULL)
 Transition (const std::string &classname, const std::string &instancename)
 constructor, pass your subclass type name as a string for the default name, and a separate instance name
 Transition (const std::string &classname, const std::string &instancename, StateNode *destination)
 constructor, specify names and destination StateNode (ignores NULL)
 Transition (const Transition &t)
 copy constructor, just in case you need it
Transitionoperator= (const Transition &t)
 assignment operator (only does shallow copy)
virtual void addSource (StateNode *source)
 if source is non-null, add it to the source list

Protected Attributes

std::vector< StateNode * > srcs
 the node being transitioned from
std::vector< StateNode * > dsts
 the node being transitioned to
std::string sound
 sound to play on transitioning

Friends

class StateNode


Member Function Documentation

virtual void Transition::addSource ( StateNode source  )  [inline, protected, virtual]

if source is non-null, add it to the source list

Only StateNodes should be calling this - you add a transition to a source, not a source to a transition.

See also:
StateNode::addTransition()

Definition at line 82 of file Transition.h.


The documentation for this class was generated from the following files:

Tekkotsu v3.0
Generated Fri May 11 20:08:54 2007 by Doxygen 1.4.7