Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5207 in orxonox.OLD


Ignore:
Timestamp:
Sep 19, 2005, 10:00:45 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: default value can now be supplied as aditional arg of the SHELL_COMMAND-macro

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/shell/shell_command.cc

    r5204 r5207  
    572572  return this;
    573573}
     574
     575/**
     576 * sets default Values of the Commands
     577 * @param count how many default Values to set.
     578 * @param ... the default Values in order. They will be cast to the right type
     579 * @returns itself
     580 *
     581 * Be aware, that when you use this Function, you !!MUST!! match the input as
     582 * count, [EXACTLY THE SAME AS IF YOU WOULD CALL THE FUNCTION UP TO count ARGUMENTS]
     583 */
     584ShellCommandBase* ShellCommandBase::defaultValues(unsigned int count, ...)
     585{
     586  if (this == NULL)
     587    return NULL;
     588  if (count == 0)
     589    return this;
     590  if (count > this->paramCount)
     591    count = this->paramCount;
     592
     593  va_list defaultList;
     594  va_start(defaultList, count);
     595
     596  for (unsigned int i = 0; i < count; i++)
     597  {
     598    switch (this->parameters[i])
     599    {
     600      case ParameterBool:
     601        this->defaultBools[i] = va_arg(defaultList, int);
     602        break;
     603      case ParameterChar:
     604        this->defaultStrings[i] = new char[2];
     605        sprintf(this->defaultStrings[0], "%c",  va_arg(defaultList, int));
     606        break;
     607      case ParameterString:
     608        this->defaultStrings[i] = va_arg(defaultList, char*);
     609        break;
     610      case ParameterInt:
     611        this->defaultInts[i] = va_arg(defaultList, int);
     612        break;
     613      case ParameterUInt:
     614        this->defaultInts[i] = va_arg(defaultList, unsigned int);
     615        break;
     616      case ParameterFloat:
     617        this->defaultFloats[i] = va_arg(defaultList, double);
     618        break;
     619      case ParameterLong:
     620        this->defaultInts[i] = va_arg(defaultList, long);
     621        break;
     622      default:
     623        break;
     624    }
     625  }
     626
     627  return this;
     628}
     629
    574630
    575631/**
  • trunk/src/lib/shell/shell_command.h

    r5204 r5207  
    22 * @file shell_command.h
    33 * Definition of a on-screen-shell
    4  * @todo simple way to supply Default Values with the macro.
    54*/
    65
     
    8786    ShellCommandBase* describe(const char* description);
    8887    ShellCommandBase* setAlias(const char* alias);
     88    ShellCommandBase* defaultValues(unsigned int count, ...);
    8989
    9090    /** @returns the CommandList of the Shell */
  • trunk/src/lib/shell/shell_input.cc

    r5204 r5207  
    3636    ->describe("retrieve some help about the input mode")
    3737    ->setAlias("help");
    38 
    3938/**
    4039 * standard constructor
     
    179178void ShellInput::help(const char* className, const char* functionName)
    180179{
     180  printf("%s::%s\n", className, functionName);
     181
    181182  if (strlen(className) == 0)
    182183  {
  • trunk/src/lib/util/helper_functions.cc

    r5148 r5207  
    6363const char* isString(const char* STRING, const char* defaultValue)
    6464{
    65   if (STRING != NULL)
     65  if (STRING != NULL && strlen(STRING) > 0)
    6666    return STRING;
    6767  else
  • trunk/src/orxonox.cc

    r5183 r5207  
    5858
    5959using namespace std;
     60
     61SHELL_COMMAND(restart, Orxonox, restart);
    6062
    6163/**
     
    121123Orxonox* Orxonox::singletonRef = NULL;
    122124
     125// DANGEROUS
     126void Orxonox::restart()
     127{
     128//   int argc = this->argc;
     129//   char** argv = this->argv;
     130//
     131//   Orxonox *orx = Orxonox::getInstance();
     132//
     133//   delete orx;
     134//
     135//   orx = Orxonox::getInstance();
     136//
     137//   if((*orx).init(argc, argv) == -1)
     138//   {
     139//     PRINTF(1)("! Orxonox initialization failed\n");
     140//     return;
     141//   }
     142//
     143//   printf("finished inizialisation\n");
     144//   orx->start();
     145}
     146
    123147/**
    124148 *  this finds the config file
  • trunk/src/orxonox.h

    r5074 r5207  
    2525  int init (int argc, char** argv);
    2626
     27  void restart();
     28
    2729  void start();
    2830
     
    4042  int initNetworking ();
    4143  int initMisc ();
     44
    4245
    4346  const char* getConfigFile ();
Note: See TracChangeset for help on using the changeset viewer.