Homepage Demos Overview Downloads Tutorials Reference
Credits

BehaviorSwitchActivatorControl.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_BehaviorSwitchActivatorControl_h
00003 #define INCLUDED_BehaviorSwitchActivatorControl_h
00004 
00005 #include "ControlBase.h"
00006 #include "BehaviorSwitchControl.h"
00007 
00008 //! Upon activation, will tell the specified BehaviorSwitchControl to start or stop the behavior
00009 class BehaviorSwitchActivatorControl : public ControlBase {
00010 public:
00011   //! lets you tell it what action to perform
00012   enum Mode_t { start, stop, toggle };
00013 
00014   //!constructor
00015   BehaviorSwitchActivatorControl(const std::string& n, BehaviorSwitchControlBase* bscb, Mode_t m=toggle) : ControlBase(n), behswitch(bscb), mode(m) {}
00016 
00017   //!destructor
00018   virtual ~BehaviorSwitchActivatorControl() {}
00019 
00020   //! performs the action denoted by #mode
00021   virtual ControlBase * activate(MotionManager::MC_ID disp_id, Socket *) {
00022     switch(mode) {
00023     case start:
00024       behswitch->start();
00025       break;
00026     case stop:
00027       behswitch->stop();
00028       break;
00029     case toggle:
00030       behswitch->toggle();
00031       break;
00032     }
00033     if(disp_id!=MotionManager::invalid_MC_ID) {
00034       MMAccessor<LedMC> display(disp_id);
00035       display.mc()->flash(FaceLEDMask,100);
00036     }
00037     return NULL;
00038   }
00039 
00040   virtual std::string getName() const { return behswitch->getName(); }
00041   virtual std::string getDescription() const { return behswitch->getDescription(); }
00042 
00043 protected:
00044   BehaviorSwitchControlBase* behswitch; //!< The behavior switch to activate/deactivate
00045   Mode_t mode; //!< the mode this control is in
00046 
00047 private:
00048   BehaviorSwitchActivatorControl(const BehaviorSwitchActivatorControl&); //!< don't copy this class
00049   BehaviorSwitchActivatorControl operator=(const BehaviorSwitchActivatorControl&); //!< don't assign this class
00050 };
00051 
00052 /*! @file
00053  * @brief Defines BehaviorSwitchActivatorControl, which will tell the specified BehaviorSwitchControl to start or stop the behavior
00054  * @author ejt (Creator)
00055  *
00056  * $Author: ejt $
00057  * $Name: tekkotsu-2_2 $
00058  * $Revision: 1.3 $
00059  * $State: Rel $
00060  * $Date: 2003/09/25 15:26:10 $
00061  */
00062 
00063 #endif

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