Homepage Demos Overview Downloads Tutorials Reference
Credits

Transition.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_Transition_h_
00003 #define INCLUDED_Transition_h_
00004 
00005 #include "BehaviorBase.h"
00006 
00007 class StateNode;
00008 
00009 //! Represents a transition between StateNodes.
00010 /*! This is an abstract class - you'll want to subclass it to put
00011  *  conditions on the transitions
00012  *
00013  *  DoStart() will be called when this transition is 'active' - it should
00014  *  listen/monitor for the transition it represents until DoStop() is called.
00015  *  
00016  *  If the conditions are satisified for a transition, you should call activate()
00017  *  to do the appropriate notifications. */
00018 class Transition : public BehaviorBase {
00019 public:
00020   //!constructor, specifies source and destination StateNode's
00021   Transition(StateNode* source, StateNode* destination) : BehaviorBase(), src(source), dst(destination) {}
00022   //!copy constructor, just in case you need it
00023   Transition(const Transition& t) : BehaviorBase(t), src(t.src), dst(t.dst) {}
00024   //!destructor
00025   virtual ~Transition() {}
00026 
00027   //!call this when the transition should be made, base class version simply calls StateNode::DoStop() on #src and StateNode::DoStart() on #dst, but you can override.
00028   virtual void activate();
00029 
00030   //!assignment operator (only does shallow copy)
00031   Transition& operator=(const Transition& t) { BehaviorBase::operator=(t); src=t.src; dst=t.dst; return *this; }
00032 protected:
00033   StateNode* src; //!< the node being transitioned from
00034   StateNode* dst; //!< the node being transitioned to
00035 };
00036 
00037 /*! @file
00038  * @brief Describes Transition, represents a transition between StateNodes.
00039  * @author ejt (Creator)
00040  *
00041  * $Author: ejt $
00042  * $Name: tekkotsu-1_5 $
00043  * $Revision: 1.2 $
00044  * $State: Rel $
00045  * $Date: 2003/08/21 22:32:41 $
00046  */
00047 
00048 #endif

Tekkotsu v1.5
Generated Fri Oct 10 15:52:00 2003 by Doxygen 1.3.4