[7728] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Benjamin Grauer |
---|
| 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include "executor.h" |
---|
[8894] | 17 | std::string ExecutorFunctional_returningString_from[7]; |
---|
[7728] | 18 | |
---|
| 19 | |
---|
| 20 | template<> MT_Type ExecutorParamType<bool>() { return MT_BOOL; }; |
---|
| 21 | template<> MT_Type ExecutorParamType<int>() { return MT_INT; }; |
---|
| 22 | template<> MT_Type ExecutorParamType<unsigned int>() { return MT_UINT; }; |
---|
| 23 | template<> MT_Type ExecutorParamType<float>() { return MT_FLOAT; }; |
---|
| 24 | template<> MT_Type ExecutorParamType<char>() { return MT_CHAR; }; |
---|
| 25 | template<> MT_Type ExecutorParamType<const std::string&>() { return MT_STRING; }; |
---|
| 26 | |
---|
| 27 | template<> bool fromString<bool>(const std::string& input, bool defaultValue) { return isBool(input, defaultValue); }; |
---|
| 28 | template<> int fromString<int>(const std::string& input, int defaultValue) { return isInt(input, defaultValue); }; |
---|
| 29 | template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue) { return isInt(input, defaultValue); }; |
---|
| 30 | template<> float fromString<float>(const std::string& input, float defaultValue) { return isFloat(input, defaultValue); }; |
---|
| 31 | template<> char fromString<char>(const std::string& input, char defaultValue) { return isInt(input, defaultValue); }; |
---|
[8408] | 32 | template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { return (input.size() > 0) ? input : defaultValue; }; |
---|
[7728] | 33 | |
---|
[8035] | 34 | |
---|
| 35 | template<> bool fromMulti<bool>(const MultiType& multi) { return multi.getBool(); }; |
---|
| 36 | template<> int fromMulti<int>(const MultiType& multi) { return multi.getInt(); } |
---|
| 37 | template<> unsigned int fromMulti<unsigned int>(const MultiType& multi) { return multi.getInt(); }; |
---|
| 38 | template<> float fromMulti<float>(const MultiType& multi) { return multi.getFloat(); }; |
---|
| 39 | template<> char fromMulti<char>(const MultiType& multi) { return multi.getChar(); }; |
---|
| 40 | template<> const std::string& fromMulti<const std::string&>(const MultiType& multi) { return multi.getConstString(); }; |
---|
| 41 | |
---|
| 42 | |
---|
[7728] | 43 | template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getBool(); }; |
---|
| 44 | template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); }; |
---|
| 45 | template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); }; |
---|
| 46 | template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getFloat(); }; |
---|
| 47 | template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); }; |
---|
[8408] | 48 | template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return ExecutorFunctional_returningString_from[i] = defaultValues[i].getString(); }; |
---|
[7728] | 49 | |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | |
---|
[8035] | 54 | |
---|
| 55 | |
---|
[7728] | 56 | /** |
---|
| 57 | * A LITTLE TESTING SUITE FOR THE EXECUTOR. |
---|
| 58 | * |
---|
| 59 | #include "executor/executor_functional.h" |
---|
| 60 | |
---|
| 61 | #define EXECUTOR_FUNCTIONAL_USE_STATIC |
---|
| 62 | #include "executor/executor_functional.h" |
---|
| 63 | |
---|
| 64 | class TestClass : public BaseObject |
---|
| 65 | { |
---|
| 66 | public: |
---|
| 67 | TestClass() {}; |
---|
| 68 | |
---|
| 69 | void printTest() { printf ("TEST\n"); }; |
---|
| 70 | void printTestInt(int i) { printf ("%d\n", i); }; |
---|
| 71 | void printTestBool(bool b) { printf("%d\n", (int)b); }; |
---|
| 72 | void printTwoVals(int b, int i) { printf ("%d %d\n", b, i); }; |
---|
| 73 | void printStrings(const std::string& name) { printf("String:: '%s'\n", name.c_str()); }; |
---|
| 74 | static void printStatic() { printf("STATIC\n");}; |
---|
| 75 | }; |
---|
| 76 | |
---|
| 77 | void TEST() |
---|
| 78 | { |
---|
| 79 | TestClass test; |
---|
| 80 | SubString testStrings("1 SCHEISSE, 2, 3", ",", SubString::WhiteSpaces, false); |
---|
| 81 | (*createExecutor<TestClass>(&TestClass::printTest))(&test, testStrings); |
---|
| 82 | (*createExecutor<TestClass>(&TestClass::printTestInt))(&test, testStrings); |
---|
| 83 | (*createExecutor<TestClass>(&TestClass::printTestBool))(&test, testStrings); |
---|
| 84 | (*createExecutor<TestClass>(&TestClass::printTwoVals))(&test, testStrings); |
---|
| 85 | (*createExecutor<TestClass>(&TestClass::printStatic))(&test, testStrings); |
---|
| 86 | (*createExecutor<TestClass>(&TestClass::printStrings))(&test, testStrings); |
---|
| 87 | |
---|
| 88 | } |
---|
| 89 | */ |
---|