Homepage Demos Overview Downloads Tutorials Reference
Credits

MCRepeater.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_MCRepeater_h_
00003 #define INCLUDED_MCRepeater_h_
00004 
00005 #include "Behaviors/BehaviorBase.h"
00006 #include "Shared/SharedObject.h"
00007 #include "Motion/MotionManager.h"
00008 #include "Events/EventRouter.h"
00009 
00010 //! Sends a given MotionCommand to MotionManager, waits until it autoprunes, and then sends it again.
00011 class MCRepeater : public BehaviorBase {
00012 public:
00013   //! constructor
00014   MCRepeater(const SharedObjectBase* sharedmc) : BehaviorBase(), mc(sharedmc) {}
00015 
00016   virtual void DoStart() {
00017     BehaviorBase::DoStart(); // do this first
00018     MotionManager::MC_ID id=motman->addPrunableMotion(*mc);
00019     erouter->addListener(this,EventBase::motmanEGID,id,EventBase::deactivateETID);
00020   }
00021 
00022   virtual void DoStop() {
00023     erouter->removeListener(this);
00024     BehaviorBase::DoStop(); // do this last
00025   }
00026 
00027   virtual void processEvent(const EventBase& /*e*/) {
00028     erouter->removeListener(this);
00029     MotionManager::MC_ID id=motman->addPrunableMotion(*mc);
00030     erouter->addListener(this,EventBase::motmanEGID,id,EventBase::deactivateETID);
00031   }
00032 
00033   virtual std::string getName() const { return "MCRepeater"; }
00034 
00035   static std::string getClassDescription() { return "Sends a given MotionCommand to MotionManager, waits until it autoprunes, and then sends it again."; }
00036   
00037 protected:
00038   const SharedObjectBase* mc; //!< the motion command being repeated
00039 
00040 private:
00041   MCRepeater(const MCRepeater&); //!< don't call
00042   MCRepeater operator=(const MCRepeater&); //!< don't call
00043 };
00044 
00045 /*! @file
00046  * @brief Defines MCRepeater, which sends a given MotionCommand to MotionManager, waits until it autoprunes, and then sends it again.
00047  * @author ejt (Creator)
00048  *
00049  * $Author: ejt $
00050  * $Name: tekkotsu-2_2 $
00051  * $Revision: 1.4 $
00052  * $State: Exp $
00053  * $Date: 2004/10/17 01:16:10 $
00054  */
00055 
00056 #endif

Tekkotsu v2.2
Generated Tue Oct 19 14:19:14 2004 by Doxygen 1.3.9.1