Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ConnectionMadeTrans.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_ConnectionMadeTrans_h_
00003 #define INCLUDED_ConnectionMadeTrans_h_
00004 
00005 #include "Behaviors/Transition.h"
00006 #include "Events/EventRouter.h"
00007 #include "Wireless/Wireless.h"
00008 
00009 //! a transition that occurs as soon as a connection is made
00010 class ConnectionMadeTrans : public Transition {
00011 public:
00012 
00013   //! constructor
00014   ConnectionMadeTrans(StateNode* destination, Socket* sock) : Transition("ConnectionMadeTrans",destination), socket(sock) {}
00015   
00016   //! constructor
00017   ConnectionMadeTrans(const std::string& name, StateNode* destination, Socket* sock) : 
00018     Transition("ConnectionMadeTrans",name,destination), socket(sock) {}
00019   
00020   //!starts 32 msec timer with sid=0
00021   virtual void DoStart() {
00022     Transition::DoStart();
00023     erouter->addTimer(this,0,32,true);
00024   }
00025 
00026   //!stops timer
00027   virtual void DoStop() { erouter->removeListener(this); Transition::DoStop(); }
00028 
00029   //!when timer event is received, fire() the transition
00030   virtual void processEvent(const EventBase&) { 
00031     if(socket!=NULL && wireless->isConnected(socket->sock)) {
00032       fire();
00033     }
00034   }
00035 
00036 protected:
00037   //! constructor, only to be called by subclasses (which need to specify their own @a classname)
00038   ConnectionMadeTrans(const std::string &classname, const std::string &instancename, StateNode* destination, Socket* sock) :
00039     Transition(classname,instancename,destination), socket(sock) {}
00040   ConnectionMadeTrans(const ConnectionMadeTrans&);     //!< DON'T CALL THIS
00041   ConnectionMadeTrans& operator=(const ConnectionMadeTrans&);  //!< DON'T CALL THIS
00042   
00043 
00044 
00045   Socket* socket; //!< the socket to expect the connection on
00046 };
00047 
00048 /*! @file
00049  * @brief Defines ConnectionMadeTrans, which causes a transition as soon as a connection is made
00050  * @author klibby (Creator)
00051  *
00052  * $Author: ejt $
00053  * $Name: tekkotsu-4_0 $
00054  * $Revision: 1.3 $
00055  * $State: Exp $
00056  * $Date: 2005/08/07 04:11:03 $
00057  */
00058 
00059 #endif

Tekkotsu v4.0
Generated Thu Nov 22 00:54:52 2007 by Doxygen 1.5.4