Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
ValueSetControl.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_ValueSetControl_h 00003 #define INCLUDED_ValueSetControl_h 00004 00005 #include "ControlBase.h" 00006 00007 //! Upon activation, this control will set the target pointer to the specified value 00008 template < class T > 00009 class ValueSetControl : public ControlBase { 00010 public: 00011 /*!@name Constructors/Destructors*/ 00012 //!constructor 00013 ValueSetControl() : ControlBase(), target(NULL) {} 00014 ValueSetControl(const std::string& n, T* t) : ControlBase(n), target(t) {} 00015 ValueSetControl(const std::string& n, T* t, const T& d) : ControlBase(n), target(t), def(d) {} 00016 ValueSetControl(const ValueSetControl& vsc) : target(vsc.target), def(vsc.def) {} //!<copy constructor 00017 ValueSetControl operator=(const ValueSetControl& vsc) { ControlBase::operator=(vsc); target=vsc.target; def=vsc.def; return *this; } //!<assignment operator 00018 virtual ~ValueSetControl() {} //!< destructor 00019 //@} 00020 00021 //! assigns #def to object pointed to by #target 00022 virtual ControlBase * activate(MC_ID display) { 00023 *target=def; 00024 if(display!=invalid_MC_ID) { 00025 //!@todo make the leds flash 00026 } 00027 return NULL; 00028 } 00029 00030 /*!@name Target 00031 * accessors for the target pointer */ 00032 virtual T* getTarget() const { return target; } //!< returns the target pointer 00033 virtual ValueSetControl& setTarget(T* t) { target=t; return *this; } //!< sets the target pointer - the object pointed to will be overwritten on activate(); returns @c *this 00034 //@} 00035 00036 /*!@name Value 00037 * accessors for the default value assigned when activated */ 00038 virtual T& getDefault() { return def; } //!< gets reference to default value 00039 virtual const T& getDefault() const { return def; } //!< gets reference to default value 00040 virtual ValueSetControl& setDefault(const T& d) { def=d; return *this; } //!< assigns d to the default value (not to the target, yet); returns @c *this 00041 //@} 00042 00043 protected: 00044 T* target; //!< the target that will be set to the default value (#def) 00045 T def; //!< the value that will be assigned to #target upon a call to activate() 00046 }; 00047 00048 /*! @file 00049 * @brief Defines ValueSetControl class, which will assign a value through a pointer upon activation 00050 * @author ejt (Creator) 00051 */ 00052 00053 #endif |
Tekkotsu v5.1CVS |
Generated Mon May 9 04:58:52 2016 by Doxygen 1.6.3 |