Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

NullControl.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_NullControl_h_
00003 #define INCLUDED_NullControl_h_
00004 
00005 #include "ControlBase.h"
00006 
00007 //! when activated, this will return immediately  (handy for fake items in a menu)
00008 class NullControl : public ControlBase {
00009 public:
00010 
00011   //!Constructor
00012   explicit NullControl(ControlBase * inputRedirectTgt=NULL) : ControlBase(), inputRedirect(inputRedirectTgt) {}
00013   //!Constructor
00014   explicit NullControl(const std::string& n, ControlBase * inputRedirectTgt=NULL) : ControlBase(n), inputRedirect(inputRedirectTgt) {}
00015   //!Constructor
00016   NullControl(const std::string& n, const std::string& d, ControlBase * inputRedirectTgt=NULL) : ControlBase(n,d), inputRedirect(inputRedirectTgt) {}
00017 
00018   virtual void setInputRedirect(ControlBase* inputRedirectTgt) { inputRedirect=inputRedirectTgt; } //!< sets #inputRedirect
00019   virtual ControlBase* getInputRedirect() const { return inputRedirect; } //!< returns #inputRedirect
00020   
00021   //@{
00022   //! returns NULL
00023   virtual ControlBase * activate(MC_ID , Socket * ) { return NULL; }
00024 
00025   virtual ControlBase * doSelect()    { return NULL; }
00026   virtual ControlBase * doNextItem()  { return NULL; }
00027   virtual ControlBase * doPrevItem()  { return NULL; }
00028   virtual ControlBase * doReadStdIn(const std::string& /*prompt*/=std::string()) { return NULL; }
00029   //@}
00030 
00031   //! returns NULL unless #inputRedirect is set, in which case it will return inputRedirect->takeInput(msg)
00032   virtual ControlBase * takeInput(const std::string& msg) { return (inputRedirect==NULL) ? NULL : inputRedirect->takeInput(msg); }
00033 
00034 protected:
00035   //! the target to receiving forwarding of any calls to takeInput()
00036   /*! this is handy if this instance is some feedback to the user, and any input they
00037    *  enter with this control selected only makes sense to be handled by the parent */
00038   ControlBase* inputRedirect;
00039 
00040 private:
00041   NullControl(const NullControl&); //!< you can override, but don't call this...
00042   NullControl& operator=(const NullControl&); //!< you can override, but don't call this...
00043 };
00044 
00045 /*! @file
00046  * @brief Defines NullControl, which does absolutely nothing (handy for fake items in a menu)
00047  * @author ejt (Creator)
00048  */
00049 
00050 #endif

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