[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 | |
---|
[5129] | 20 | #include "debug.h" |
---|
[5113] | 21 | #include "class_list.h" |
---|
| 22 | |
---|
| 23 | #include "key_names.h" |
---|
[5075] | 24 | #include <stdarg.h> |
---|
| 25 | #include <stdio.h> |
---|
[5174] | 26 | #include <string.h> |
---|
[5075] | 27 | |
---|
[1856] | 28 | using namespace std; |
---|
[1853] | 29 | |
---|
[5552] | 30 | //////////////////////// |
---|
| 31 | // SHELL COMMAND BASE // |
---|
| 32 | //////////////////////// |
---|
[5170] | 33 | /** |
---|
[5166] | 34 | * constructs and registers a new Command |
---|
| 35 | * @param commandName the name of the Command |
---|
| 36 | * @param className the name of the class to apply this command to |
---|
| 37 | * @param paramCount the count of parameters this command takes |
---|
| 38 | */ |
---|
[7197] | 39 | Executor::Executor(const MultiType& param0, |
---|
| 40 | const MultiType& param1, |
---|
| 41 | const MultiType& param2, |
---|
| 42 | const MultiType& param3, |
---|
| 43 | const MultiType& param4) |
---|
[3365] | 44 | { |
---|
[5632] | 45 | this->setClassID(CL_EXECUTOR, "Executor"); |
---|
[5141] | 46 | |
---|
[7197] | 47 | // What Parameters have we got |
---|
| 48 | this->defaultValue[0] = param0; |
---|
| 49 | this->defaultValue[1] = param1; |
---|
| 50 | this->defaultValue[2] = param2; |
---|
| 51 | this->defaultValue[3] = param3; |
---|
| 52 | this->defaultValue[4] = param4; |
---|
[5148] | 53 | |
---|
[7199] | 54 | this->paramCount = 0; |
---|
[7300] | 55 | for (unsigned int i = 0; i <= FUNCTOR_MAX_ARGUMENTS; i++) |
---|
[5659] | 56 | { |
---|
[7300] | 57 | if (this->defaultValue[i] == MT_NULL || i == FUNCTOR_MAX_ARGUMENTS) |
---|
[7197] | 58 | { |
---|
| 59 | this->paramCount = i; |
---|
| 60 | break; |
---|
| 61 | } |
---|
[5659] | 62 | } |
---|
[5068] | 63 | } |
---|
[4320] | 64 | |
---|
[5166] | 65 | /** |
---|
[5632] | 66 | * deconstructs a Executor |
---|
[5166] | 67 | */ |
---|
[5632] | 68 | Executor::~Executor() |
---|
[7197] | 69 | {} |
---|
[1853] | 70 | |
---|
[5166] | 71 | /** |
---|
[5641] | 72 | * clones this element into executor. |
---|
| 73 | */ |
---|
| 74 | void Executor::cloning(Executor* executor) const |
---|
| 75 | { |
---|
| 76 | executor->functorType = this->functorType; |
---|
| 77 | executor->paramCount = this->paramCount; |
---|
| 78 | for (unsigned int i = 0; i < this->paramCount; i++) |
---|
[5659] | 79 | executor->defaultValue[i] = this->defaultValue[i]; |
---|
[5641] | 80 | } |
---|
| 81 | |
---|
| 82 | /** |
---|
[7198] | 83 | * @brief set the default values of the executor |
---|
| 84 | * @param value0 the first default value |
---|
| 85 | * @param value1 the second default value |
---|
| 86 | * @param value2 the third default value |
---|
| 87 | * @param value3 the fourth default value |
---|
| 88 | * @param value4 the fifth default value |
---|
[5207] | 89 | * @returns itself |
---|
| 90 | */ |
---|
[7198] | 91 | Executor* Executor::defaultValues(const MultiType& value0, |
---|
| 92 | const MultiType& value1, |
---|
| 93 | const MultiType& value2, |
---|
| 94 | const MultiType& value3, |
---|
| 95 | const MultiType& value4) |
---|
[5207] | 96 | { |
---|
| 97 | if (this == NULL) |
---|
| 98 | return NULL; |
---|
| 99 | |
---|
[7198] | 100 | const MultiType* value[5]; |
---|
| 101 | value[0] = &value0; |
---|
| 102 | value[1] = &value1; |
---|
| 103 | value[2] = &value2; |
---|
| 104 | value[3] = &value3; |
---|
| 105 | value[4] = &value4; |
---|
[5207] | 106 | |
---|
[7198] | 107 | for (unsigned int i = 0; i < this->paramCount; i++) |
---|
[5207] | 108 | { |
---|
[7198] | 109 | if (*value[i] != MT_NULL) |
---|
[7200] | 110 | { |
---|
[7221] | 111 | this->defaultValue[i].setValueOf(*value[i]); |
---|
[7200] | 112 | } |
---|
[5207] | 113 | } |
---|
| 114 | return this; |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | /** |
---|
[5632] | 118 | * prints out nice information about the Executor |
---|
[5166] | 119 | */ |
---|
[5632] | 120 | void Executor::debug() |
---|
[5148] | 121 | { |
---|
[7197] | 122 | /* tIterator<ExecutorClass>* iteratorCL = ExecutorClass::commandClassList->getIterator(); |
---|
| 123 | ExecutorClass* elemCL = iteratorCL->firstElement(); |
---|
| 124 | while(elemCL != NULL) |
---|
[5170] | 125 | { |
---|
[7197] | 126 | PRINT(0)("Class:'%s' registered %d commands: \n", elemCL->className, elemCL->commandList->getSize()); |
---|
| 127 | tIterator<Executor>* iterator = elemCL->commandList->getIterator(); |
---|
| 128 | const Executor* elem = iterator->firstElement(); |
---|
| 129 | while(elem != NULL) |
---|
| 130 | { |
---|
| 131 | PRINT(0)(" command:'%s' : params:%d: ", elem->getName(), elem->paramCount); |
---|
| 132 | for (unsigned int i = 0; i< elem->paramCount; i++) |
---|
| 133 | printf("%s ", Executor::paramToString(elem->parameters[i])); |
---|
| 134 | if (elem->description != NULL) |
---|
| 135 | printf("- %s", elem->description); |
---|
| 136 | printf("\n"); |
---|
[5148] | 137 | |
---|
[7197] | 138 | elem = iterator->nextElement(); |
---|
| 139 | } |
---|
| 140 | delete iterator; |
---|
| 141 | elemCL = iteratorCL->nextElement(); |
---|
[5170] | 142 | } |
---|
[7197] | 143 | delete iteratorCL;*/ |
---|
[5148] | 144 | } |
---|