Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Transition.cc

Go to the documentation of this file.
00001 #include "Transition.h"
00002 #include "StateNode.h"
00003 #include "Wireless/Wireless.h"
00004 #include "Sound/SoundManager.h"
00005 #include "Events/EventRouter.h"
00006 
00007 void Transition::fire() {
00008   //serr->printf("%s fire() - enter %d\n",getName().c_str(),get_time());
00009 
00010   AddReference(); //just in case a side effect of this transition is to dereference the transition, we don't want to be deleted while still transitioning
00011 
00012   if(sound.size()!=0)
00013     sndman->PlayFile(sound);
00014 
00015   erouter->postEvent(EventBase::stateTransitionEGID,reinterpret_cast<int>(this),EventBase::statusETID,0,getName(),1);
00016 
00017   for(unsigned int i=0; i<srcs.size(); i++)
00018     if(srcs[i]->isActive()) //It's usually a bad idea to call DoStop/DoStart when it's already stopped/started...
00019       srcs[i]->DoStop();
00020   for(unsigned int i=0; i<dsts.size(); i++)
00021     if(!dsts[i]->isActive())
00022       dsts[i]->DoStart();
00023 
00024   //serr->printf("%s fire() - leave %d\n",getName().c_str(),get_time());
00025   RemoveReference();
00026 }
00027 
00028 std::string Transition::getName() const {
00029   if(instanceName != className) {
00030     return instanceName;
00031   } else {
00032     std::string ans;
00033     ans+='{';
00034     for(unsigned int i=0; i<srcs.size(); i++)
00035       ans+=srcs[i]->getName()+(i<srcs.size()-1?',':'}');
00036     ans+="--"+instanceName+"-->";
00037     ans+='{';
00038     for(unsigned int i=0; i<dsts.size(); i++)
00039       ans+=dsts[i]->getName()+(i<dsts.size()-1?',':'}');
00040     return ans;
00041   }
00042 } 
00043 
00044 /*! @file
00045  * @brief Implements Transition, represents a transition between StateNodes.
00046  * @author ejt (Creator)
00047  *
00048  * $Author: ejt $
00049  * $Name: tekkotsu-2_4_1 $
00050  * $Revision: 1.16 $
00051  * $State: Exp $
00052  * $Date: 2005/08/03 18:47:58 $
00053  */
00054 

Tekkotsu v2.4.1
Generated Tue Aug 16 16:32:49 2005 by Doxygen 1.4.4