00001 /* 00002 00003 ************************************************************************* 00004 00005 ArmageTron -- Just another Tron Lightcycle Game in 3D. 00006 Copyright (C) 2000 Manuel Moos (manuel@moosnet.de) 00007 00008 ************************************************************************** 00009 00010 This program is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU General Public License 00012 as published by the Free Software Foundation; either version 2 00013 of the License, or (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00023 00024 *************************************************************************** 00025 00026 */ 00027 00030 00031 #ifndef ARMAGETRON_vebLegacy_h 00032 #define ARMAGETRON_vebLegacy_h 00033 00034 #include "values/vCore.h" 00035 00036 class tConfItemBase; 00037 00038 namespace vValue { 00039 namespace Expr { 00040 namespace Bindings { 00041 namespace Legacy { 00042 00044 template<typename T> class Callback : public Base { 00045 public: 00046 typedef boost::shared_ptr<Base> (T::*cb_ptr)(void); 00047 private: 00048 cb_ptr m_value; 00049 T *m_cockpit; 00050 public: 00051 Callback(cb_ptr value, T *hud); 00052 Callback(Callback const &other); 00053 00054 void operator=(Callback const &other); 00055 Base *copy(void) const; 00056 virtual ~Callback() { }; 00057 00058 virtual Variant GetValue(void) const; 00059 virtual int GetInt(void) const; 00060 virtual float GetFloat(void) const; 00061 virtual tString GetString(Base const *other=0) const; 00062 00063 bool operator==(Base const &other) const; 00064 bool operator!=(Base const &other) const; 00065 bool operator>=(Base const &other) const; 00066 bool operator<=(Base const &other) const; 00067 bool operator> (Base const &other) const; 00068 bool operator< (Base const &other) const; 00069 }; 00070 00074 template<typename T> Callback<T>::Callback(cb_ptr value, T *hud): 00075 Base(), 00076 m_value(value), 00077 m_cockpit(hud) 00078 { } 00079 00082 template<typename T> Callback<T>::Callback(Callback const &other): 00083 Base(other), 00084 m_value(other.m_value), 00085 m_cockpit(other.m_cockpit) 00086 { } 00087 00090 template<typename T> Base *Callback<T>::copy(void) const { 00091 return new Callback(*this); 00092 } 00093 00096 template<typename T> void Callback<T>::operator=(Callback const &other) { 00097 this->Base::operator=(other); 00098 m_value=other.m_value; 00099 m_cockpit=other.m_cockpit; 00100 } 00101 00104 template<typename T> Variant Callback<T>::GetValue() const { 00105 return (m_cockpit->*m_value)()->GetValue(); 00106 } 00107 00110 template<typename T> tString Callback<T>::GetString(Base const *other) const { 00111 return (m_cockpit->*m_value)()->GetString(other == 0 ? this : other); 00112 } 00113 00116 template<typename T> int Callback<T>::GetInt(void) const { 00117 return (m_cockpit->*m_value)()->GetInt(); 00118 } 00119 00122 template<typename T> float Callback<T>::GetFloat(void) const { 00123 return (m_cockpit->*m_value)()->GetFloat(); 00124 } 00125 00126 template<typename T> bool Callback<T>::operator==(Base const &other) const { return *(m_cockpit->*m_value)() == other; } 00127 template<typename T> bool Callback<T>::operator!=(Base const &other) const { return *(m_cockpit->*m_value)() != other; } 00128 template<typename T> bool Callback<T>::operator>=(Base const &other) const { return *(m_cockpit->*m_value)() >= other; } 00129 template<typename T> bool Callback<T>::operator<=(Base const &other) const { return *(m_cockpit->*m_value)() <= other; } 00130 template<typename T> bool Callback<T>::operator> (Base const &other) const { return *(m_cockpit->*m_value)() > other; } 00131 template<typename T> bool Callback<T>::operator< (Base const &other) const { return *(m_cockpit->*m_value)() < other; } 00132 00133 //TODO: Find a better solution for this, this is a bit slow. 00134 00136 class ConfItem : public Base { 00137 tConfItemBase *m_value; 00138 tString Read() const; 00139 public: 00140 ConfItem(tString const &value); 00141 ConfItem(ConfItem const &other); 00142 void operator=(ConfItem const &other); 00143 00144 bool Good() const; 00145 00146 Base *copy(void) const; 00147 virtual ~ConfItem() { }; 00148 00149 virtual Variant GetValue(void) const; 00150 virtual tString GetString(Base const *other=0) const; 00151 }; 00152 00153 } 00154 } 00155 } 00156 } 00157 00158 #endif