| 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 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
|---|
| 17 | |
|---|
| 18 | #include "executor.h" |
|---|
| 19 | |
|---|
| 20 | #include "debug.h" |
|---|
| 21 | #include "class_list.h" |
|---|
| 22 | |
|---|
| 23 | #include "key_names.h" |
|---|
| 24 | #include <stdarg.h> |
|---|
| 25 | #include <stdio.h> |
|---|
| 26 | #include <string.h> |
|---|
| 27 | |
|---|
| 28 | using namespace std; |
|---|
| 29 | |
|---|
| 30 | //////////////////////// |
|---|
| 31 | // SHELL COMMAND BASE // |
|---|
| 32 | //////////////////////// |
|---|
| 33 | /** |
|---|
| 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 | */ |
|---|
| 39 | Executor::Executor(const MultiType& param0, |
|---|
| 40 | const MultiType& param1, |
|---|
| 41 | const MultiType& param2, |
|---|
| 42 | const MultiType& param3, |
|---|
| 43 | const MultiType& param4) |
|---|
| 44 | { |
|---|
| 45 | this->setClassID(CL_EXECUTOR, "Executor"); |
|---|
| 46 | |
|---|
| 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; |
|---|
| 53 | |
|---|
| 54 | this->paramCount = 0; |
|---|
| 55 | for (unsigned int i = 0; i < FUNCTOR_MAX_ARGUMENTS; i++) |
|---|
| 56 | { |
|---|
| 57 | if (this->defaultValue[i] == MT_NULL) |
|---|
| 58 | { |
|---|
| 59 | this->paramCount = i; |
|---|
| 60 | break; |
|---|
| 61 | } |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | /** |
|---|
| 66 | * deconstructs a Executor |
|---|
| 67 | */ |
|---|
| 68 | Executor::~Executor() |
|---|
| 69 | {} |
|---|
| 70 | |
|---|
| 71 | /** |
|---|
| 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++) |
|---|
| 79 | executor->defaultValue[i] = this->defaultValue[i]; |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | /** |
|---|
| 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 |
|---|
| 89 | * @returns itself |
|---|
| 90 | */ |
|---|
| 91 | Executor* Executor::defaultValues(const MultiType& value0, |
|---|
| 92 | const MultiType& value1, |
|---|
| 93 | const MultiType& value2, |
|---|
| 94 | const MultiType& value3, |
|---|
| 95 | const MultiType& value4) |
|---|
| 96 | { |
|---|
| 97 | if (this == NULL) |
|---|
| 98 | return NULL; |
|---|
| 99 | |
|---|
| 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; |
|---|
| 106 | |
|---|
| 107 | printf("%s ::: paramCount: %d\n", this->getName(), this->paramCount); |
|---|
| 108 | for (unsigned int i = 0; i < this->paramCount; i++) |
|---|
| 109 | { |
|---|
| 110 | if (*value[i] != MT_NULL) |
|---|
| 111 | { |
|---|
| 112 | printf("1:::: %d : %s \n",i, MultiType::MultiTypeToString(this->defaultValue[i].getType())); |
|---|
| 113 | |
|---|
| 114 | this->defaultValue[i].debug(); |
|---|
| 115 | //this->defaultValue[i].setValueOf(*value[i]); |
|---|
| 116 | //printf("2::::%s\n", MultiType::MultiTypeToString(this->defaultValue[i].getType())); |
|---|
| 117 | //this->defaultValue[i].debug(); |
|---|
| 118 | //this->defaultValue[i].setValueOf(*value[i]); |
|---|
| 119 | } |
|---|
| 120 | } |
|---|
| 121 | return this; |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | /** |
|---|
| 125 | * prints out nice information about the Executor |
|---|
| 126 | */ |
|---|
| 127 | void Executor::debug() |
|---|
| 128 | { |
|---|
| 129 | /* tIterator<ExecutorClass>* iteratorCL = ExecutorClass::commandClassList->getIterator(); |
|---|
| 130 | ExecutorClass* elemCL = iteratorCL->firstElement(); |
|---|
| 131 | while(elemCL != NULL) |
|---|
| 132 | { |
|---|
| 133 | PRINT(0)("Class:'%s' registered %d commands: \n", elemCL->className, elemCL->commandList->getSize()); |
|---|
| 134 | tIterator<Executor>* iterator = elemCL->commandList->getIterator(); |
|---|
| 135 | const Executor* elem = iterator->firstElement(); |
|---|
| 136 | while(elem != NULL) |
|---|
| 137 | { |
|---|
| 138 | PRINT(0)(" command:'%s' : params:%d: ", elem->getName(), elem->paramCount); |
|---|
| 139 | for (unsigned int i = 0; i< elem->paramCount; i++) |
|---|
| 140 | printf("%s ", Executor::paramToString(elem->parameters[i])); |
|---|
| 141 | if (elem->description != NULL) |
|---|
| 142 | printf("- %s", elem->description); |
|---|
| 143 | printf("\n"); |
|---|
| 144 | |
|---|
| 145 | elem = iterator->nextElement(); |
|---|
| 146 | } |
|---|
| 147 | delete iterator; |
|---|
| 148 | elemCL = iteratorCL->nextElement(); |
|---|
| 149 | } |
|---|
| 150 | delete iteratorCL;*/ |
|---|
| 151 | } |
|---|