Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/cd/src/lib/util/executor/executor.cc @ 7588

Last change on this file since 7588 was 7300, checked in by bensch, 19 years ago

orxonox/trunk: the most evil for (int i=0; i <'=' …) bug ever…

File size: 3.8 KB
Line 
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
28using 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 */
39Executor::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 || i == FUNCTOR_MAX_ARGUMENTS)
58    {
59      this->paramCount = i;
60      break;
61    }
62  }
63}
64
65/**
66 * deconstructs a Executor
67 */
68Executor::~Executor()
69{}
70
71/**
72 * clones this element into executor.
73 */
74void 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 */
91Executor* 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  for (unsigned int i = 0; i < this->paramCount; i++)
108  {
109    if (*value[i] != MT_NULL)
110    {
111      this->defaultValue[i].setValueOf(*value[i]);
112    }
113  }
114  return this;
115}
116
117/**
118 * prints out nice information about the Executor
119 */
120void Executor::debug()
121{
122  /*  tIterator<ExecutorClass>* iteratorCL = ExecutorClass::commandClassList->getIterator();
123    ExecutorClass* elemCL = iteratorCL->firstElement();
124    while(elemCL != NULL)
125    {
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");
137
138        elem = iterator->nextElement();
139      }
140      delete iterator;
141      elemCL = iteratorCL->nextElement();
142    }
143    delete iteratorCL;*/
144}
Note: See TracBrowser for help on using the repository browser.