[4744] | 1 | /* |
---|
[1853] | 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. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
[5068] | 12 | main-programmer: Benjamin Grauer |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[3955] | 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
[1853] | 17 | |
---|
[5632] | 18 | #include "executor.h" |
---|
[1853] | 19 | |
---|
[9684] | 20 | |
---|
[9728] | 21 | template<> MT_Type ExecutorParamType<bool>() { return MT_BOOL; }; |
---|
| 22 | template<> MT_Type ExecutorParamType<int>() { return MT_INT; }; |
---|
| 23 | template<> MT_Type ExecutorParamType<unsigned int>() { return MT_UINT; }; |
---|
| 24 | template<> MT_Type ExecutorParamType<float>() { return MT_FLOAT; }; |
---|
| 25 | template<> MT_Type ExecutorParamType<char>() { return MT_CHAR; }; |
---|
| 26 | template<> MT_Type ExecutorParamType<const std::string&>() { return MT_STRING; }; |
---|
[9684] | 27 | |
---|
[9728] | 28 | |
---|
| 29 | |
---|
[5170] | 30 | /** |
---|
[7714] | 31 | * @brief constructs and registers a new Command |
---|
[5166] | 32 | * @param commandName the name of the Command |
---|
| 33 | * @param className the name of the class to apply this command to |
---|
| 34 | * @param paramCount the count of parameters this command takes |
---|
| 35 | */ |
---|
[9727] | 36 | ExecutorBase::ExecutorBase(bool hasRetVal, |
---|
| 37 | const MultiType& param0, |
---|
| 38 | const MultiType& param1, |
---|
| 39 | const MultiType& param2, |
---|
| 40 | const MultiType& param3, |
---|
| 41 | const MultiType& param4, |
---|
| 42 | const MultiType& param5, |
---|
| 43 | const MultiType& param6) |
---|
| 44 | : bRetVal(hasRetVal) |
---|
[3365] | 45 | { |
---|
[7197] | 46 | // What Parameters have we got |
---|
| 47 | this->defaultValue[0] = param0; |
---|
| 48 | this->defaultValue[1] = param1; |
---|
| 49 | this->defaultValue[2] = param2; |
---|
| 50 | this->defaultValue[3] = param3; |
---|
| 51 | this->defaultValue[4] = param4; |
---|
[8894] | 52 | this->defaultValue[5] = param5; |
---|
| 53 | this->defaultValue[6] = param6; |
---|
[5148] | 54 | |
---|
[7199] | 55 | this->paramCount = 0; |
---|
[9732] | 56 | for (unsigned int i = 0; i <= EXECUTOR_MAX_ARGUMENTS; i++) |
---|
[5659] | 57 | { |
---|
[9732] | 58 | if (this->defaultValue[i] == MT_NULL || i == EXECUTOR_MAX_ARGUMENTS) |
---|
[7197] | 59 | { |
---|
| 60 | this->paramCount = i; |
---|
| 61 | break; |
---|
| 62 | } |
---|
[9730] | 63 | else |
---|
| 64 | this->defaultValue[i].storeString(); |
---|
[5659] | 65 | } |
---|
[5068] | 66 | } |
---|
[4320] | 67 | |
---|
[5166] | 68 | /** |
---|
[5641] | 69 | * clones this element into executor. |
---|
[9727] | 70 | * @param executor the Executor to clone |
---|
[5641] | 71 | */ |
---|
[9727] | 72 | void ExecutorBase::cloning(ExecutorBase* executor) const |
---|
[5641] | 73 | { |
---|
| 74 | executor->functorType = this->functorType; |
---|
| 75 | executor->paramCount = this->paramCount; |
---|
| 76 | for (unsigned int i = 0; i < this->paramCount; i++) |
---|
[5659] | 77 | executor->defaultValue[i] = this->defaultValue[i]; |
---|
[5641] | 78 | } |
---|
| 79 | |
---|
| 80 | /** |
---|
[7198] | 81 | * @brief set the default values of the executor |
---|
| 82 | * @param value0 the first default value |
---|
| 83 | * @param value1 the second default value |
---|
| 84 | * @param value2 the third default value |
---|
| 85 | * @param value3 the fourth default value |
---|
| 86 | * @param value4 the fifth default value |
---|
[5207] | 87 | * @returns itself |
---|
| 88 | */ |
---|
[9727] | 89 | void ExecutorBase::defaultValues(const MultiType& value0, |
---|
[7198] | 90 | const MultiType& value1, |
---|
| 91 | const MultiType& value2, |
---|
| 92 | const MultiType& value3, |
---|
[8894] | 93 | const MultiType& value4, |
---|
| 94 | const MultiType& value5, |
---|
| 95 | const MultiType& value6) |
---|
[5207] | 96 | { |
---|
[7198] | 97 | const MultiType* value[5]; |
---|
| 98 | value[0] = &value0; |
---|
| 99 | value[1] = &value1; |
---|
| 100 | value[2] = &value2; |
---|
| 101 | value[3] = &value3; |
---|
| 102 | value[4] = &value4; |
---|
[8894] | 103 | value[5] = &value5; |
---|
| 104 | value[6] = &value6; |
---|
[7198] | 105 | for (unsigned int i = 0; i < this->paramCount; i++) |
---|
[5207] | 106 | { |
---|
[7198] | 107 | if (*value[i] != MT_NULL) |
---|
[7200] | 108 | { |
---|
[7221] | 109 | this->defaultValue[i].setValueOf(*value[i]); |
---|
[9730] | 110 | this->defaultValue[i].storeString(); |
---|
[7200] | 111 | } |
---|
[5207] | 112 | } |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | /** |
---|
[7742] | 116 | * @brief prints out nice information about the Executor |
---|
[5166] | 117 | */ |
---|
[9727] | 118 | void ExecutorBase::debug() |
---|
[5148] | 119 | { |
---|
| 120 | } |
---|