Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7198 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Mar 8, 2006, 2:30:19 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: new Default Values… they now too are in MultiType instead of (count, …) or (count, va_arg) style

Location:
trunk/src/lib
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r7193 r7198  
    143143  LoadParam(root, "bind-node", this, Element2D, setBindNode)
    144144      .describe("sets a node, this 2D-Element should be shown upon (name of the node)")
    145       .defaultValues(1, NULL);
     145      .defaultValues(NULL);
    146146
    147147  LoadParam(root, "visibility", this, Element2D, setVisibility)
  • trunk/src/lib/lang/class_list.cc

    r7165 r7198  
    3131SHELL_COMMAND_STATIC(debug, ClassList, ClassList::debugS)
    3232    ->describe("Shows all registered classes, if param1: is a valid ClassName only values of this class are shown. param2: how much output")
    33     ->defaultValues(2, NULL, 1);
     33    ->defaultValues(NULL, 1);
    3434#endif
    3535
  • trunk/src/lib/particles/box_emitter.cc

    r7193 r7198  
    7878  LoadParam(root, "size", this, BoxEmitter, setSize)
    7979  .describe("The Size of the BoxEmitter: x, y, z")
    80   .defaultValues(3, 1.0f,1.0f,1.0f);
     80  .defaultValues(1.0f,1.0f,1.0f);
    8181}
    8282
  • trunk/src/lib/particles/dot_particles.cc

    r7193 r7198  
    3131
    3232SHELL_COMMAND(texture, DotParticles, setMaterialTexture)
    33     ->defaultValues(1, "maps/evil-flower.png");
     33    ->defaultValues("maps/evil-flower.png");
    3434
    3535using namespace std;
  • trunk/src/lib/particles/model_particles.cc

    r7193 r7198  
    3131
    3232SHELL_COMMAND(texture, ModelParticles, setMaterialTexture)
    33 ->defaultValues(1, "maps/evil-flower.png");
     33->defaultValues("maps/evil-flower.png");
    3434
    3535using namespace std;
  • trunk/src/lib/particles/particle_system.cc

    r7193 r7198  
    128128  LoadParam(root, "precache", this, ParticleSystem, precache)
    129129      .describe("Precaches the ParticleSystem for %1 seconds, %2 times per Second")
    130       .defaultValues(2, 1, 25);
     130      .defaultValues(1, 25);
    131131}
    132132
  • trunk/src/lib/particles/plane_emitter.cc

    r7193 r7198  
    7878  LoadParam(root, "size", this, PlaneEmitter, setSize)
    7979  .describe("The Size of the PlaneEmitter: x, y")
    80   .defaultValues(2, 1.0f,1.0f);
     80  .defaultValues(1.0f,1.0f);
    8181}
    8282
  • trunk/src/lib/particles/sprite_particles.cc

    r7193 r7198  
    3131
    3232SHELL_COMMAND(texture, SpriteParticles, setMaterialTexture)
    33     ->defaultValues(1, "maps/evil-flower.png");
     33    ->defaultValues("maps/evil-flower.png");
    3434
    3535using namespace std;
  • trunk/src/lib/physics/fields/field.cc

    r7193 r7198  
    6262  LoadParam(root, "magnitude", this, Field, setMagnitude)
    6363      .describe("sets the magnitude of this Field")
    64       .defaultValues(1, 1);
     64      .defaultValues(1);
    6565
    6666  LoadParam(root, "attenuation", this, Field, setAttenuation)
  • trunk/src/lib/shell/shell.cc

    r6780 r7198  
    4343SHELL_COMMAND(textsize, Shell, setTextSize)
    4444    ->describe("Sets the size of the Text size, linespacing")
    45     ->defaultValues(1, 15, 0);
     45    ->defaultValues(15, 0);
    4646SHELL_COMMAND(textcolor, Shell, setTextColor)
    4747    ->describe("Sets the Color of the Shells Text (red, green, blue, alpha)")
    48     ->defaultValues(4, SHELL_DEFAULT_TEXT_COLOR);
     48    ->defaultValues(SHELL_DEFAULT_TEXT_COLOR);
    4949SHELL_COMMAND(backgroundcolor, Shell, setBackgroundColor)
    5050    ->describe("Sets the Color of the Shells Background (red, green, blue, alpha)")
    51     ->defaultValues(4, SHELL_DEFAULT_BACKGROUND_COLOR);
     51    ->defaultValues(SHELL_DEFAULT_BACKGROUND_COLOR);
    5252SHELL_COMMAND(backgroundimage, Shell, setBackgroundImage)
    5353    ->describe("sets the background image to load for the Shell");
    5454SHELL_COMMAND(font, Shell, setFont)
    5555    ->describe("Sets the font of the Shell")
    56     ->defaultValues(1, SHELL_DEFAULT_FONT);
     56    ->defaultValues(SHELL_DEFAULT_FONT);
    5757
    5858/**
  • trunk/src/lib/shell/shell_command.cc

    r6222 r7198  
    292292
    293293/**
    294  * sets default Values of the Commands
    295  * @param count how many default Values to set.
    296  * @param ... the default Values in order. They will be cast to the right type
    297  * @returns itself
    298  *
    299  * Be aware, that when you use this Function, you !!MUST!! match the input as
    300  * count, [EXACTLY THE SAME AS IF YOU WOULD CALL THE FUNCTION UP TO count ARGUMENTS]
    301  */
    302 ShellCommand* ShellCommand::defaultValues(unsigned int count, ...)
     294 * @brief set the default values of the executor
     295 * @param value0 the first default value
     296 * @param value1 the second default value
     297 * @param value2 the third default value
     298 * @param value3 the fourth default value
     299 * @param value4 the fifth default value
     300 */
     301ShellCommand* ShellCommand::defaultValues(const MultiType& value0, const MultiType& value1,
     302                                          const MultiType& value2, const MultiType& value3,
     303                                          const MultiType& value4)
    303304{
    304305  if (this == NULL)
    305306    return NULL;
    306307
    307   va_list values;
    308   va_start(values, count);
    309 
    310   this->executor->defaultValues(count, values);
     308  this->executor->defaultValues(value0, value1, value2, value3, value4);
    311309
    312310  return this;
  • trunk/src/lib/shell/shell_command.h

    r5784 r7198  
    6565    ShellCommand* describe(const char* description);
    6666    ShellCommand* setAlias(const char* alias);
    67     ShellCommand* defaultValues(unsigned int count, ...);
     67    ShellCommand* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
     68                                const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
     69                                const MultiType& value4 = MT_NULL);
    6870
    6971    static ShellCommand* registerCommand(const char* commandName, const char* className, const Executor& executor);
  • trunk/src/lib/util/executor/executor.cc

    r7197 r7198  
    5555  for (unsigned int i = 0; i < FUNCTOR_MAX_ARGUMENTS; i++)
    5656  {
    57     printf("%d ", i);
    5857    if (this->defaultValue[i] == MT_NULL)
    5958    {
     
    6160      break;
    6261    }
    63 
    6462  }
    65   printf("%d\n", this->paramCount);
    66 
    6763  assert (paramCount <= FUNCTOR_MAX_ARGUMENTS);
    6864}
     
    8581}
    8682
    87 
    88 
    8983/**
    90  * sets default Values of the Commands
    91  * @param count how many default Values to set.
    92  * @param ... the default Values in order. They will be cast to the right type
     84 * @brief set the default values of the executor
     85 * @param value0 the first default value
     86 * @param value1 the second default value
     87 * @param value2 the third default value
     88 * @param value3 the fourth default value
     89 * @param value4 the fifth default value
    9390 * @returns itself
    94  *
    95  * Be aware, that when you use this Function, you !!MUST!! match the input as
    96  * count, [EXACTLY THE SAME AS IF YOU WOULD CALL THE FUNCTION UP TO count ARGUMENTS]
    9791 */
    98 Executor* Executor::defaultValues(unsigned int count, ...)
    99 {
    100   va_list values;
    101   va_start(values, count);
    102 
    103   this->defaultValues(count, values);
    104 }
    105 
    106 Executor* Executor::defaultValues(unsigned int count, va_list values)
     92Executor* Executor::defaultValues(const MultiType& value0,
     93                                  const MultiType& value1,
     94                                  const MultiType& value2,
     95                                  const MultiType& value3,
     96                                  const MultiType& value4)
    10797{
    10898  if (this == NULL)
    10999    return NULL;
    110   if (count == 0)
    111     return this;
    112   if (count > this->paramCount)
    113     count = this->paramCount;
    114100
     101  const MultiType* value[5];
     102  value[0] = &value0;
     103  value[1] = &value1;
     104  value[2] = &value2;
     105  value[3] = &value3;
     106  value[4] = &value4;
    115107
    116   for (unsigned int i = 0; i < count; i++)
     108  for (unsigned int i = 0; i < this->paramCount; i++)
    117109  {
    118     switch (this->defaultValue[i].getType())
     110    if (*value[i] != MT_NULL)
    119111    {
    120       case MT_BOOL:
    121         this->defaultValue[i].setInt(va_arg(values, int));
    122         break;
    123       case MT_CHAR:
    124         this->defaultValue[i].setChar((char)va_arg(values, int));
    125         break;
    126       case MT_STRING:
    127         this->defaultValue[i].setString(va_arg(values, char*));
    128         break;
    129       case MT_INT:
    130         this->defaultValue[i].setInt(va_arg(values, int));
    131         break;
    132         /*      case MT_UINT:
    133                 this->defaultValue[i].setInt((int)va_arg(values, unsigned int));
    134                 break;*/
    135       case MT_FLOAT:
    136         this->defaultValue[i].setFloat(va_arg(values, double));
    137         break;
    138         /*      case MT_LONG:
    139                 this->defaultValue[i].setInt((int) va_arg(values, long));
    140                 break;*/
    141       default:
    142         break;
     112      if (this->defaultValue[i].getType() == value[i]->getType())
     113      {
     114        this->defaultValue[i] = *value[i];
     115      }
     116      else
     117      {
     118        PRINTF(1)("Unable to set this Value, as it is not of type %s\n", MultiType::MultiTypeToString(this->defaultValue[i].getType()));
     119      }
    143120    }
    144121  }
  • trunk/src/lib/util/executor/executor.h

    r7197 r7198  
    4545    virtual Executor* clone () const = 0;
    4646
    47     Executor* defaultValues(unsigned int count, va_list values);
    48     Executor* defaultValues(unsigned int count, ...);
     47    Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
     48                            const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
     49                            const MultiType& value4 = MT_NULL);
    4950
    5051    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
     
    5960
    6061  protected:
    61     Executor(const MultiType& param0 = MT_NULL,
    62              const MultiType& param1 = MT_NULL,
    63              const MultiType& param2 = MT_NULL,
    64              const MultiType& param3 = MT_NULL,
     62    Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
     63             const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
    6564             const MultiType& param4 = MT_NULL);
    6665
  • trunk/src/lib/util/loading/load_param.cc

    r7193 r7198  
    6363    if (likely(this->object != NULL) &&
    6464        ( this->loadString != NULL ||
    65          ((this->executor->getType() & Executor_NoLoadString) == Executor_NoLoadString)))
     65          ((this->executor->getType() & Executor_NoLoadString) == Executor_NoLoadString)))
    6666    {
    6767      PRINTF(4)("Loading '%s' with Parameters '%s' onto: '%s'(%s)\n", this->paramName, this->loadString, this->object->getName(), this->object->getClassName());
     
    7373
    7474/**
    75  * set the default values of the executor
    76  * @param count how many default values to set.
    77  * @param ... the default values !! must be at least count parameters!!
    78  */
    79 CLoadParam& CLoadParam::defaultValues(unsigned int count, ...)
    80 {
    81   va_list values;
    82   va_start(values, count);
    83 
    84   assert(executor != NULL);
    85   this->executor->defaultValues(count, values);
     75 * @brief set the default values of the executor
     76 * @param value0 the first default value
     77 * @param value1 the second default value
     78 * @param value2 the third default value
     79 * @param value3 the fourth default value
     80 * @param value4 the fifth default value
     81 */
     82CLoadParam& CLoadParam::defaultValues(const MultiType& value0, const MultiType& value1,
     83                                      const MultiType& value2, const MultiType& value3,
     84                                      const MultiType& value4)
     85{
     86  assert(this->executor != NULL);
     87  this->executor->defaultValues(value0, value1, value2, value3, value4);
    8688
    8789  return *this;
     
    9799{
    98100  if (LoadClassDescription::parametersDescription && this->paramDesc && !this->paramDesc->getDescription())
    99     {
    100       this->paramDesc->setDescription(descriptionText);
    101     }
     101  {
     102    this->paramDesc->setDescription(descriptionText);
     103  }
    102104  return *this;
    103105}
     
    239241  node = element->FirstChild();
    240242  while( node != NULL)
    241     {
    242       if( node->ToText()) return node->Value();
    243       node = node->NextSibling();
    244     }
     243  {
     244    if( node->ToText()) return node->Value();
     245    node = node->NextSibling();
     246  }
    245247  return NULL;
    246248}
  • trunk/src/lib/util/loading/load_param.h

    r7130 r7198  
    9191
    9292    CLoadParam& describe(const char* descriptionText);
    93     CLoadParam& defaultValues(unsigned int count, ...);
     93    CLoadParam& defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
     94                              const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
     95                              const MultiType& value4 = MT_NULL);
    9496    CLoadParam& attribute(const char* attributeName, const Executor& executor);
    9597
Note: See TracChangeset for help on using the changeset viewer.