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 preStart() {
00022     Transition::preStart();
00023     erouter->addTimer(this,0,32,true);
00024   }
00025 
00026   //!when timer event is received, fire() the transition
00027   virtual void doEvent() { 
00028     if(socket!=NULL && wireless->isConnected(socket->sock)) {
00029       fire();
00030     }
00031   }
00032 
00033 protected:
00034   //! constructor, only to be called by subclasses (which need to specify their own @a classname)
00035   ConnectionMadeTrans(const std::string &classname, const std::string &instancename, StateNode* destination, Socket* sock) :
00036     Transition(classname,instancename,destination), socket(sock) {}
00037   ConnectionMadeTrans(const ConnectionMadeTrans&);     //!< DON'T CALL THIS
00038   ConnectionMadeTrans& operator=(const ConnectionMadeTrans&);  //!< DON'T CALL THIS
00039   
00040 
00041 
00042   Socket* socket; //!< the socket to expect the connection on
00043 };
00044 
00045 /*! @file
00046  * @brief Defines ConnectionMadeTrans, which causes a transition as soon as a connection is made
00047  * @author klibby (Creator)
00048  */
00049 
00050 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:37 2016 by Doxygen 1.6.3