Changeset 8271 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- Jun 8, 2006, 4:50:50 PM (18 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/executor/executor.h
r8048 r8271 53 53 // EXECUTE 54 54 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 55 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const = 0;55 virtual void operator()(BaseObject* object, int& count, void* values) const = 0; 56 56 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ 57 57 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0; -
trunk/src/lib/util/executor/executor_functional.h
r8048 r8271 123 123 124 124 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 125 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const125 virtual void operator()(BaseObject* object, int& count, void* values) const 126 126 { 127 127 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); … … 163 163 164 164 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 165 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const165 virtual void operator()(BaseObject* object, int& count, void* values) const 166 166 { 167 167 const MultiType* mt = (const MultiType*)values; … … 227 227 228 228 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 229 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const229 virtual void operator()(BaseObject* object, int& count, void* values) const 230 230 { 231 231 const MultiType* mt = (const MultiType*)values; … … 282 282 283 283 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 284 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const284 virtual void operator()(BaseObject* object, int& count, void* values) const 285 285 { 286 286 const MultiType* mt = (const MultiType*)values; … … 340 340 341 341 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 342 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const342 virtual void operator()(BaseObject* object, int& count, void* values) const 343 343 { 344 344 const MultiType* mt = (const MultiType*)values; … … 400 400 401 401 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 402 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const402 virtual void operator()(BaseObject* object, int& count, void* values) const 403 403 { 404 404 const MultiType* mt = (const MultiType*)values; -
trunk/src/lib/util/executor/executor_lua.cc
r8057 r8271 18 18 #include "executor_lua.h" 19 19 20 template<> bool fromLua<bool>(lua_state* state, int index) { return lua_toboolean(state, index); }; 21 template<> int fromLua<int>(lua_state* state, int index) { return (int)lua_toumber(state, index); }; 22 template<> unsigned int fromLua<unsigned int>(lua_state* state, int index) { return (unsigned int)lua_tonumber(state, index); }; 23 template<> float fromLua<float>(lua_state* state, int index) { return (float)lua_tonumber(state, index); }; 24 template<> char fromLua<char>(lua_state* state, int index) { reutnr (char)lua_tonumber(state, index); }; 25 template<> const std::string& fromLua<const std::string&>(lua_state* state, int index) { return lua_tostring(state, index); }; 20 std::string temp; 21 22 template<> bool fromLua<bool>(lua_State* state, int index) { return lua_toboolean(state, index); }; 23 template<> int fromLua<int>(lua_State* state, int index) { return (int)lua_tonumber(state, index); }; 24 template<> unsigned int fromLua<unsigned int>(lua_State* state, int index) { return (unsigned int)lua_tonumber(state, index); }; 25 template<> float fromLua<float>(lua_State* state, int index) { return (float)lua_tonumber(state, index); }; 26 template<> char fromLua<char>(lua_State* state, int index) { return (char)lua_tonumber(state, index); }; 27 template<> const std::string& fromLua<const std::string&>(lua_State* state, int index) { temp = lua_tostring(state, index); return temp; }; 26 28 27 29 28 30 29 template<> void toLua<bool>(lua_ state* state, bool value) { lua_pushboolean(state, (int) value); };30 template<> void toLua<int>(lua_ state* state, int value) { lua_pushnumber(state, (lua_Number) value); };31 template<> void toLua<unsigned int>(lua_ state* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); };32 template<> void toLua<float>(lua_ state* state, float value) { lua_pushnumber(state, (lua_Number) value); };33 template<> void toLua<char>(lua_ state* state, char value) { lua_pushnumber(state, (lua_Number) value); };34 template<> void toLua<const std::string&>(lua_ state* state, const std::string& value) {lua_pushstring (state, value.c_str()); }31 template<> void toLua<bool>(lua_State* state, bool value) { lua_pushboolean(state, (int) value); }; 32 template<> void toLua<int>(lua_State* state, int value) { lua_pushnumber(state, (lua_Number) value); }; 33 template<> void toLua<unsigned int>(lua_State* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); }; 34 template<> void toLua<float>(lua_State* state, float value) { lua_pushnumber(state, (lua_Number) value); }; 35 template<> void toLua<char>(lua_State* state, char value) { lua_pushnumber(state, (lua_Number) value); }; 36 template<> void toLua<const std::string&>(lua_State* state, const std::string& value) {lua_pushstring (state, value.c_str()); } -
trunk/src/lib/util/executor/executor_lua.h
r8057 r8271 4 4 */ 5 5 6 #ifndef _EXECUTOR_ SPECIALS_H7 #define _EXECUTOR_ SPECIALS_H6 #ifndef _EXECUTOR_LUA_H 7 #define _EXECUTOR_LUA_H 8 8 9 9 #include "executor.h" 10 10 #include "compiler.h" 11 11 #include "debug.h" 12 12 #include "luaincl.h" 13 13 14 14 15 15 16 template<typename type> type fromLua(lua_ state* state, int index) { PRINTF(1)("NOT IMPLEMENTED\n"); };17 template<> bool fromLua<bool>(lua_ state* state, int index);18 template<> int fromLua<int>(lua_ state* state, int index);19 template<> unsigned int fromLua<unsigned int>(lua_ state* state, int index);20 template<> float fromLua<float>(lua_ state* state, int index);21 template<> char fromLua<char>(lua_ state* state, int index);22 template<> const std::string& fromLua<const std::string&>(lua_ state* state, int index);23 24 25 template<typename type> void toLua(lua_ state* state, type value) { PRINTF(1)("NOT IMPLEMENTED\n"); };26 template<> void toLua<bool>(lua_ state* state, bool value);27 template<> void toLua<int>(lua_ state* state, int value);28 template<> void toLua<unsigned int>(lua_ state* state, unsigned int value);29 template<> void toLua<float>(lua_ state* state, float value);30 template<> void toLua<char>(lua_ state* state, char value);31 template<> void toLua<const std::string&>(lua_ state* state, const std::string& value);16 template<typename type> type fromLua(lua_State* state, int index) { PRINTF(1)("NOT IMPLEMENTED\n"); }; 17 template<> bool fromLua<bool>(lua_State* state, int index); 18 template<> int fromLua<int>(lua_State* state, int index); 19 template<> unsigned int fromLua<unsigned int>(lua_State* state, int index); 20 template<> float fromLua<float>(lua_State* state, int index); 21 template<> char fromLua<char>(lua_State* state, int index); 22 template<> const std::string& fromLua<const std::string&>(lua_State* state, int index); 23 24 25 template<typename type> void toLua(lua_State* state, type value) { PRINTF(1)("NOT IMPLEMENTED\n"); }; 26 template<> void toLua<bool>(lua_State* state, bool value); 27 template<> void toLua<int>(lua_State* state, int value); 28 template<> void toLua<unsigned int>(lua_State* state, unsigned int value); 29 template<> void toLua<float>(lua_State* state, float value); 30 template<> void toLua<char>(lua_State* state, char value); 31 template<> void toLua<const std::string&>(lua_State* state, const std::string& value); 32 32 33 33 // FORWARD DECLARATION 34 34 35 /////////////////////// 36 ///// WITHOUT RET ///// 37 /////////////////////// 35 38 36 39 /////////// 37 40 //// 0 //// 38 41 /////////// 39 //! Executes a Function with a lua_ state* parameter.42 //! Executes a Function with a lua_State* parameter. 40 43 template<class T> class ExecutorLua0 : public Executor 41 44 { … … 62 65 } 63 66 64 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const67 virtual void operator()(BaseObject* object, int& count, void* values) const 65 68 { 66 69 (dynamic_cast<T*>(object)->*(functionPointer))(); 70 count = 0; 67 71 } 68 72 … … 72 76 virtual Executor* clone () const 73 77 { 74 return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); 75 } 78 return new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); 79 } 80 private: 81 void (T::*functionPointer)(); 76 82 }; 77 83 … … 81 87 //// 1 //// 82 88 /////////// 83 //! Executes a Function with a lua_ state* parameter.89 //! Executes a Function with a lua_State* parameter. 84 90 template<class T, typename type0> class ExecutorLua1 : public Executor 85 91 { … … 89 95 * @param function a Function to call 90 96 */ 91 ExecutorLua 0(void(T::*function)(type0))97 ExecutorLua1(void(T::*function)(type0)) 92 98 : Executor(ExecutorParamType<type0>()) 93 99 { … … 106 112 } 107 113 108 virtual void operator()(BaseObject* object, unsigned int count, void* values) const 109 { 110 lua_state* state = (lua_state*)values; 114 virtual void operator()(BaseObject* object, int& count, void* values) const 115 { 116 lua_State* state = (lua_State*)values; 117 count = 0; 111 118 112 119 (dynamic_cast<T*>(object)->*(functionPointer))(fromLua<type0>(state, 1)); … … 118 125 virtual Executor* clone () const 119 126 { 120 return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); 121 } 127 return new ExecutorLua1<T, type0>((this->functionPointer)); 128 } 129 private: 130 void (T::*functionPointer)(type0); 122 131 }; 123 132 … … 127 136 //// 2 //// 128 137 /////////// 129 //! Executes a Function with a lua_ state* parameter.130 template<class T, typename type0, typename type1> class ExecutorLua 1: public Executor131 { 132 public: 133 /** 134 * @brief Constructor of a ExecutorXML 135 * @param function a Function to call 136 */ 137 ExecutorLua 0(void(T::*function)(type0, type1))138 //! Executes a Function with a lua_State* parameter. 139 template<class T, typename type0, typename type1> class ExecutorLua2 : public Executor 140 { 141 public: 142 /** 143 * @brief Constructor of a ExecutorXML 144 * @param function a Function to call 145 */ 146 ExecutorLua2(void(T::*function)(type0, type1)) 138 147 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>()) 139 148 { … … 152 161 } 153 162 154 virtual void operator()(BaseObject* object, unsigned int count, void* values) const 155 { 156 lua_state* state = (lua_state*)values; 163 virtual void operator()(BaseObject* object, int& count, void* values) const 164 { 165 lua_State* state = (lua_State*)values; 166 count = 0; 157 167 158 168 (dynamic_cast<T*>(object)->*(functionPointer))( … … 166 176 virtual Executor* clone () const 167 177 { 168 return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); 169 } 170 }; 171 172 173 174 #endif /* _EXECUTOR_SPECIALS_H */ 178 return new ExecutorLua2<T, type0, type1>(this->functionPointer); 179 } 180 private: 181 void (T::*functionPointer)(type0, type1); 182 }; 183 184 185 186 187 188 189 190 //////////////////// 191 ///// WITH RET ///// 192 //////////////////// 193 194 195 /////////// 196 //// 0 //// 197 /////////// 198 //! Executes a Function with a lua_State* parameter. 199 template<class T, typename ret> class ExecutorLua0ret : public Executor 200 { 201 public: 202 /** 203 * @brief Constructor of a ExecutorXML 204 * @param function a Function to call 205 */ 206 ExecutorLua0ret(ret (T::*function)()) 207 : Executor() 208 { 209 this->functionPointer = function; 210 this->functorType = Executor_Objective | Executor_NoLoadString; 211 } 212 213 /** 214 * @brief executes the Command on BaseObject 215 * @param object the BaseObject to execute this Executor on 216 * @param loadString ignored in this case 217 */ 218 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 219 { 220 PRINTF(1)("no usefull executor\n"); 221 } 222 223 virtual void operator()(BaseObject* object, int& count, void* values) const 224 { 225 lua_State* state = (lua_State*)values; 226 count = 1; 227 228 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))()); 229 } 230 231 /** 232 * @returns a _new_ Copy of this Executor 233 */ 234 virtual Executor* clone () const 235 { 236 return new ExecutorLua0ret<T, ret>(this->functionPointer); 237 } 238 private: 239 ret (T::*functionPointer)(); 240 }; 241 242 243 244 /////////// 245 //// 1 //// 246 /////////// 247 //! Executes a Function with a lua_State* parameter. 248 template<class T, typename ret, typename type0> class ExecutorLua1ret : public Executor 249 { 250 public: 251 /** 252 * @brief Constructor of a ExecutorXML 253 * @param function a Function to call 254 */ 255 ExecutorLua1ret(ret (T::*function)(type0)) 256 : Executor(ExecutorParamType<type0>()) 257 { 258 this->functionPointer = function; 259 this->functorType = Executor_Objective | Executor_NoLoadString; 260 } 261 262 /** 263 * @brief executes the Command on BaseObject 264 * @param object the BaseObject to execute this Executor on 265 * @param loadString ignored in this case 266 */ 267 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 268 { 269 PRINTF(1)("no usefull executor\n"); 270 } 271 272 virtual void operator()(BaseObject* object, int& count, void* values) const 273 { 274 lua_State* state = (lua_State*)values; 275 count = 1; 276 277 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 278 fromLua<type0>(state, 1))); 279 } 280 281 /** 282 * @returns a _new_ Copy of this Executor 283 */ 284 virtual Executor* clone () const 285 { 286 return new ExecutorLua1ret<T, ret, type0>(this->functionPointer); 287 } 288 private: 289 ret (T::*functionPointer)(type0); 290 }; 291 292 /////////// 293 //// 2 //// 294 /////////// 295 //! Executes a Function with a lua_State* parameter. 296 template<class T, typename ret, typename type0, typename type1> class ExecutorLua2ret : public Executor 297 { 298 public: 299 /** 300 * @brief Constructor of a ExecutorXML 301 * @param function a Function to call 302 */ 303 ExecutorLua2ret(ret (T::*function)(type0, type1)) 304 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>()) 305 { 306 this->functionPointer = function; 307 this->functorType = Executor_Objective | Executor_NoLoadString; 308 } 309 310 /** 311 * @brief executes the Command on BaseObject 312 * @param object the BaseObject to execute this Executor on 313 * @param loadString ignored in this case 314 */ 315 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 316 { 317 PRINTF(1)("no usefull executor\n"); 318 } 319 320 virtual void operator()(BaseObject* object, int& count, void* values) const 321 { 322 lua_State* state = (lua_State*)values; 323 count = 1; 324 325 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 326 fromLua<type0>(state, 1), 327 fromLua<type1>(state, 2) )); 328 } 329 330 /** 331 * @returns a _new_ Copy of this Executor 332 */ 333 virtual Executor* clone () const 334 { 335 return new ExecutorLua2ret<T, ret, type0, type1>(this->functionPointer); 336 } 337 private: 338 ret (T::*functionPointer)(type0, type1); 339 }; 340 341 342 343 344 345 346 347 #endif /* _EXECUTOR_LUA_H */ -
trunk/src/lib/util/executor/executor_xml.h
r8051 r8271 1 1 /*! 2 * @file executor .h2 * @file executor_xml.h 3 3 * Definition of a on-screen-shell 4 4 */ 5 5 6 #ifndef _EXECUTOR_ SPECIALS_H7 #define _EXECUTOR_ SPECIALS_H6 #ifndef _EXECUTOR_XML_H 7 #define _EXECUTOR_XML_H 8 8 9 9 #include "executor.h" … … 65 65 } 66 66 67 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const67 virtual void operator()(BaseObject* object, int& count, void* values) const 68 68 { 69 69 PRINTF(1)("missuse of XML-operator, OR IMPLEMENT.\n"); … … 82 82 }; 83 83 84 #endif /* _EXECUTOR_ SPECIALS_H */84 #endif /* _EXECUTOR_XML_H */ -
trunk/src/lib/util/loading/resource.cc
r7195 r8271 26 26 Resource::Resource (const std::string& fileName) 27 27 { 28 this->setClassID(CL_RESOURCE, "Resource");28 // this->setClassID(CL_RESOURCE, "Resource"); 29 29 30 30 }
Note: See TracChangeset
for help on using the changeset viewer.