Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Transition Class Reference

Represents a transition between StateNodes. More...

#include <Transition.h>

Inheritance diagram for Transition:

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

List of all members.

Public Member Functions

virtual ~Transition ()
 destructor
virtual void fire ()
 Call this when the transition should be made, will forward on to doFire().
virtual void fire (const EventBase &ev)
 Call this to fire with an event to be stored into the destinations' 'event' member while their start() is called.
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 void setSpeechText (const std::string &text)
 set the text to be spoken upon activation
virtual std::string getName () const
 If instanceName == className, will autogenerate a name incorporating source and destination names.

Static Public Member Functions

static void showFiring ()

Protected Member Functions

virtual void stop ()
 cancel buffered firing if deactivated (perhaps by transition which fired from earlier in the queue
virtual void doFire ()
 performs firing, stopping sources and activating destination
void fireDownCallStack ()
 Transition (StateNode *destination)
 constructor, specify destination StateNode (ignores NULL)
 Transition (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 &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 soundFile
 sound to play on transitioning
std::string speechText
 text to speak on transitioning
const EventBaseeventData

Static Protected Attributes

static std::list< Transition * > firing
 List of currently active transitions. Hopefully prevents re-entrant issues.

Friends

class StateNode

Constructor & Destructor Documentation

Transition::~Transition (  )  [virtual]

destructor

Definition at line 10 of file Transition.cc.

Transition::Transition ( StateNode destination  )  [protected]

constructor, specify destination StateNode (ignores NULL)

Definition at line 82 of file Transition.h.

Transition::Transition ( const std::string &  instancename  )  [protected]

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

Definition at line 86 of file Transition.h.

Transition::Transition ( const std::string &  instancename,
StateNode destination 
) [protected]

constructor, specify names and destination StateNode (ignores NULL)

Definition at line 88 of file Transition.h.

Transition::Transition ( const Transition t  )  [protected]

copy constructor, just in case you need it

Definition at line 92 of file Transition.h.


Member Function Documentation

virtual void Transition::addSource ( StateNode source  )  [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 101 of file Transition.h.

Referenced by StateNode::addTransition().

void Transition::doFire (  )  [protected, virtual]

performs firing, stopping sources and activating destination

Definition at line 60 of file Transition.cc.

void Transition::fire ( const EventBase ev  )  [virtual]

Call this to fire with an event to be stored into the destinations' 'event' member while their start() is called.

Definition at line 38 of file Transition.cc.

void Transition::fireDownCallStack (  )  [protected]

Definition at line 55 of file Transition.cc.

Referenced by fire().

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

returns a const reference to the current destination list

Definition at line 57 of file Transition.h.

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

returns a user-modifiable reference to the current destination list

Definition at line 56 of file Transition.h.

Referenced by EventLogger::processStateMachineEvent().

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

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

Reimplemented from BehaviorBase.

Definition at line 150 of file Transition.cc.

Referenced by doFire(), fire(), RandomTrans::fire(), EventLogger::processStateMachineEvent(), and ~Transition().

virtual std::string Transition::getSound (  )  [virtual]

returns the current sound file

Definition at line 60 of file Transition.h.

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

returns a const reference to the current source list

Definition at line 53 of file Transition.h.

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

returns a user-modifiable reference to the current source list

Definition at line 52 of file Transition.h.

Referenced by CompletionTrans::doEvent(), CompletionTrans::postStart(), and EventLogger::processStateMachineEvent().

Transition& Transition::operator= ( const Transition t  )  [protected]

assignment operator (only does shallow copy)

Definition at line 95 of file Transition.h.

virtual void Transition::setSound ( const std::string &  snd  )  [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 59 of file Transition.h.

virtual void Transition::setSpeechText ( const std::string &  text  )  [virtual]

set the text to be spoken upon activation

Definition at line 62 of file Transition.h.

void Transition::showFiring (  )  [static]

Definition at line 137 of file Transition.cc.

Referenced by fire().

void Transition::stop (  )  [protected, virtual]

cancel buffered firing if deactivated (perhaps by transition which fired from earlier in the queue

Reimplemented from BehaviorBase.

Reimplemented in CompletionTrans.

Definition at line 19 of file Transition.cc.

Referenced by doFire(), and RandomTrans::fire().


Friends And Related Function Documentation

friend class StateNode [friend]

Definition at line 41 of file Transition.h.


Member Data Documentation

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

the node being transitioned to

Definition at line 104 of file Transition.h.

Referenced by addDestination(), doFire(), RandomTrans::fire(), getDestinations(), getName(), and operator=().

const EventBase* Transition::eventData [protected]

Definition at line 107 of file Transition.h.

Referenced by doFire(), fire(), stop(), and ~Transition().

std::list< Transition * > Transition::firing [static, protected]

List of currently active transitions. Hopefully prevents re-entrant issues.

Definition at line 77 of file Transition.h.

Referenced by doFire(), fire(), fireDownCallStack(), showFiring(), stop(), and ~Transition().

std::string Transition::soundFile [protected]

sound to play on transitioning

Definition at line 105 of file Transition.h.

Referenced by doFire(), RandomTrans::fire(), getSound(), operator=(), and setSound().

std::string Transition::speechText [protected]

text to speak on transitioning

Definition at line 106 of file Transition.h.

Referenced by doFire(), operator=(), and setSpeechText().

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

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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:17 2016 by Doxygen 1.6.3