Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Action.hpp

Go to the documentation of this file.
00001 /****************************************************************************\ 00002 * VRVis * 00003 * http://vrvis.sourceforge.net * 00004 * (C) 2004 by Alex Loeffler * 00005 * mailto:aloeffler@users.sourceforge.net * 00006 **************************************************************************** 00007 * License * 00008 * * 00009 * This library is free software; you can redistribute it and/or modify it * 00010 * under the terms of the GNU Library General Public License as published * 00011 * by the Free Software Foundation, version 2. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, but * 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Library General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Library General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00021 \****************************************************************************/ 00022 00023 #ifndef ACTION_HPP 00024 #define ACTION_HPP 00025 00026 #include <map> 00027 #include <string> 00028 #include <gadget/Type/Digital.h> 00029 #include "Common.hpp" 00030 00031 namespace vrvis 00032 { 00033 00034 class ActionSet; 00035 class Input; 00036 00037 /****************************************************************************\ 00038 * Action * 00039 \****************************************************************************/ 00040 00042 class Action 00043 { 00044 // ================================================================== PUBLIC 00045 00046 public: 00047 00048 // ------------------------------------------------------------- Destructor. 00050 00052 virtual ~Action(void); 00053 00055 // -------------------------------------------------------------- Accessors. 00057 00059 const std::string& getName(void) const; 00060 00062 // =============================================================== PROTECTED 00063 00064 protected: 00065 00066 // ------------------------------------------------------------ Constructor. 00068 00070 Action(const std::string& crName); 00071 00073 // ------------------------------------------------------------------ Input. 00075 00077 Input* getInput(void) const; 00078 00080 // ------------------------------------------------------------- Activation. 00082 00084 virtual void activate(void); 00085 00087 virtual void deactivate(void); 00088 00090 // ----------------------------------------------------------------- Search. 00091 00093 static Action* getByName(const std::string& crName); 00094 00095 // ================================================================= PRIVATE 00096 00097 private: 00098 00099 // ---------------------------------------------------------------- Friends. 00100 00102 friend class ActionSet; 00103 00104 // --------------------------------------------------------------- Typedefs. 00105 00107 typedef std::map<std::string, Action*> NameActionMap; 00108 00109 // ------------------------------------------------------------------ Input. 00110 00112 void setInput(Input* pInput); 00113 00114 // ---------------------------------------------------------------- Members. 00115 00116 std::string mName; 00117 Input* mpInput; 00118 00119 // --------------------------------------------------------- Static Members. 00120 00121 static NameActionMap sNameActionMap; 00122 }; 00123 00124 /****************************************************************************\ 00125 * AnalogAction * 00126 \****************************************************************************/ 00127 00129 class AnalogAction : public Action 00130 { 00131 // ================================================================== PUBLIC 00132 00133 public: 00134 00135 // ------------------------------------------------------------- Destructor. 00136 00138 virtual ~AnalogAction(void); 00139 00140 // -------------------------------------------------------------- Execution. 00141 00143 virtual void execute(const float cAnalogDataValue) = 0; 00144 00145 // --------------------------------------------------------- Static Members. 00146 00148 static const float THRESHOLD; 00149 00150 // =============================================================== PROTECTED 00151 00152 protected: 00153 00154 // ------------------------------------------------------------ Constructor. 00155 00157 AnalogAction(const std::string& crName); 00158 }; 00159 00160 /****************************************************************************\ 00161 * DigitalAction * 00162 \****************************************************************************/ 00163 00165 class DigitalAction : public Action 00166 { 00167 // ================================================================== PUBLIC 00168 00169 public: 00170 00171 // ------------------------------------------------------------- Destructor. 00172 00174 virtual ~DigitalAction(void); 00175 00176 // -------------------------------------------------------------- Execution. 00177 00179 virtual void execute(const gadget::Digital::State cButtonState) = 0; 00180 00181 // =============================================================== PROTECTED 00182 00183 protected: 00184 00185 // ------------------------------------------------------------ Constructor. 00186 00188 DigitalAction(const std::string& crName); 00189 }; 00190 00191 } // End namespace. 00192 00193 #endif // ACTION_HPP

Generated on Tue Sep 21 07:31:08 2004 for VRVis by doxygen 1.3.8