Homepage Demos Overview Downloads Tutorials 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.

Definition at line 35 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 void activate () __attribute__((deprecated))
 deprecated: use fire() instead (just a better name
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 () __attribute__((deprecated))
 deprecated, use the version of the constructor where you can pass a name
 Transition (const std::string &classname)
 constructor, pass your subclass type name as a string for the default name
 Transition (StateNode *destination) __attribute__((deprecated))
 deprecated, use the version of the constructor where you can pass a 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


Constructor & Destructor Documentation

virtual Transition::~Transition  )  [inline, virtual]
 

destructor

Definition at line 39 of file Transition.h.

Transition::Transition  )  [protected]
 

deprecated, use the version of the constructor where you can pass a name

Deprecated:
, use the version of the constructor where you can pass a name

Definition at line 7 of file Transition.cc.

Transition::Transition const std::string &  classname  )  [inline, explicit, protected]
 

constructor, pass your subclass type name as a string for the default name

Definition at line 64 of file Transition.h.

Transition::Transition StateNode destination  )  [explicit, protected]
 

deprecated, use the version of the constructor where you can pass a name

Deprecated:
, use the version of the constructor where you can pass a name

Definition at line 10 of file Transition.cc.

Transition::Transition const std::string &  classname,
StateNode destination
[inline, protected]
 

constructor, specify destination StateNode (ignores NULL)

Definition at line 68 of file Transition.h.

Transition::Transition const std::string &  classname,
const std::string &  instancename
[inline, protected]
 

constructor, pass your subclass type name as a string for the default name, and a separate instance name

Definition at line 72 of file Transition.h.

Transition::Transition const std::string &  classname,
const std::string &  instancename,
StateNode destination
[inline, protected]
 

constructor, specify names and destination StateNode (ignores NULL)

Definition at line 74 of file Transition.h.

Transition::Transition const Transition t  )  [inline, protected]
 

copy constructor, just in case you need it

Definition at line 78 of file Transition.h.


Member Function Documentation

void Transition::activate  )  [virtual]
 

deprecated: use fire() instead (just a better name

Deprecated:
: use fire() instead (just a better name)

Definition at line 18 of file Transition.cc.

virtual void Transition::addDestination StateNode destination  )  [inline, virtual]
 

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

Definition at line 50 of file Transition.h.

Referenced by Transition().

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 86 of file Transition.h.

Referenced by StateNode::addTransition().

void Transition::fire  )  [virtual]
 

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.

Definition at line 23 of file Transition.cc.

Referenced by activate(), VisualTargetTrans::processEvent(), VisualTargetCloseTrans::processEvent(), TimeOutTrans::processEvent(), NullTrans::processEvent(), EventTrans::processEvent(), CompletionTrans::processEvent(), and CompareTrans< T >::processEvent().

virtual const std::vector<StateNode*>& Transition::getDestinations  )  const [inline, virtual]
 

returns a const reference to the current destination list

Definition at line 52 of file Transition.h.

virtual std::vector<StateNode*>& Transition::getDestinations  )  [inline, virtual]
 

returns a user-modifiable reference to the current destination list

Definition at line 51 of file Transition.h.

std::string Transition::getName  )  const [virtual]
 

If instanceName == className, will autogenerate a name incorporating source and destination names.

Reimplemented from BehaviorBase.

Definition at line 42 of file Transition.cc.

virtual std::string Transition::getSound  )  [inline, virtual]
 

returns the current sound file

Definition at line 55 of file Transition.h.

virtual const std::vector<StateNode*>& Transition::getSources  )  const [inline, virtual]
 

returns a const reference to the current source list

Definition at line 48 of file Transition.h.

virtual std::vector<StateNode*>& Transition::getSources  )  [inline, virtual]
 

returns a user-modifiable reference to the current source list

Definition at line 47 of file Transition.h.

Referenced by CompletionTrans::DoStart(), and CompletionTrans::processEvent().

Transition& Transition::operator= const Transition t  )  [inline, protected]
 

assignment operator (only does shallow copy)

Definition at line 81 of file Transition.h.

virtual void Transition::setSound const std::string &  snd  )  [inline, virtual]
 

set a sound file to be played upon activation; you might want to preload this in the parent node; empty string to turn off

Definition at line 54 of file Transition.h.

Referenced by PaceTargetsMachine::setup().


Friends And Related Function Documentation

friend class StateNode [friend]
 

Definition at line 36 of file Transition.h.


Member Data Documentation

std::vector<StateNode*> Transition::dsts [protected]
 

the node being transitioned to

Definition at line 89 of file Transition.h.

Referenced by addDestination(), fire(), getName(), operator=(), and Transition().

std::string Transition::sound [protected]
 

sound to play on transitioning

Definition at line 90 of file Transition.h.

Referenced by fire(), operator=(), setSound(), and Transition().

std::vector<StateNode*> Transition::srcs [protected]
 

the node being transitioned from

Definition at line 88 of file Transition.h.

Referenced by addSource(), fire(), getName(), operator=(), and Transition().


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

Tekkotsu v2.2.1
Generated Tue Nov 23 16:37:53 2004 by Doxygen 1.3.9.1