Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7742 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
May 20, 2006, 3:53:37 PM (19 years ago)
Author:
bensch
Message:

trying to fix a strange bug of the static initialisation

Location:
trunk/src/lib
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/text_engine/text.cc

    r7726 r7742  
    3636  this->font = NULL;
    3737  this->size = textSize;
     38  this->blending = TEXT_DEFAULT_BLENDING;
     39  this->color = TEXT_DEFAULT_COLOR;
    3840
    3941  this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
    4042
    41   this->blending = TEXT_DEFAULT_BLENDING;
    42   this->color = TEXT_DEFAULT_COLOR;
    4343  this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
    44   this->setSize(TEXT_DEFAULT_SIZE);
    4544}
    4645
  • trunk/src/lib/shell/shell.cc

    r7738 r7742  
    248248  void Shell::applyTextSettings(Text* text)
    249249  {
     250    text->setSize(this->textSize);
    250251    text->setFont(this->fontFile, this->textSize);
    251     text->setSize(this->textSize);
    252252    text->setColor(this->textColor[0], this->textColor[1], this->textColor[2]);
    253253    text->setBlending(this->textColor[3]);
  • trunk/src/lib/shell/shell_command.cc

    r7722 r7742  
    2727namespace OrxShell
    2828{
    29   SHELL_COMMAND_STATIC(debug, ShellCommand, ShellCommand::debug);
     29  SHELL_COMMAND(debug, ShellCommandClass, help);
    3030
    3131
     
    9898    if (cmdClass != NULL)
    9999    {
    100       std::vector<ShellCommand*>::iterator cmd;
    101       for (cmd = cmdClass->commandList.begin(); cmd < cmdClass->commandList.end(); cmd++)
     100      CmdList::iterator cmd;
     101      for (cmd = cmdClass->commandList.begin(); cmd != cmdClass->commandList.end(); cmd++)
    102102        if (commandName == (*cmd)->getName())
    103103        {
     
    118118    assert(cmdClass != NULL);
    119119
    120     std::vector<ShellCommand*>::const_iterator elem;
     120    CmdList::const_iterator elem;
    121121    for (elem = cmdClass->commandList.begin(); elem != cmdClass->commandList.end(); elem++)
    122122      if (commandName == (*elem)->getName())
     
    379379  }
    380380
    381 
    382   /**
    383    * @brief prints out nice information about the Shells Commands
    384    */
    385   void ShellCommand::debug()
    386   {
    387     std::vector<ShellCommandClass*>::iterator classIT;
    388     for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++)
    389     {
    390       PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size());
    391 
    392       std::vector<ShellCommand*>::iterator cmdIT;
    393       for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++)
    394       {
    395         PRINT(0)("  command:'%s' : params:%d: ", (*cmdIT)->getName(), (*cmdIT)->executor->getParamCount());
    396         /// FIXME
    397         /*      for (unsigned int i = 0; i< elem->paramCount; i++)
    398          printf("%s ", ShellCommand::paramToString(elem->parameters[i]));*/
    399         if (!(*cmdIT)->description.empty())
    400           printf("- %s", (*cmdIT)->description.c_str());
    401         printf("\n");
    402 
    403       }
    404     }
     381  /**
     382   * @brief prints a Help string from this Command
     383   */
     384  void ShellCommand::help() const
     385  {
     386    PRINT(0)("%s ", this->getName());
    405387  }
    406388
  • trunk/src/lib/shell/shell_command.h

    r7722 r7742  
    8484    const CompletorPlugin* const getCompletorPlugin(unsigned int i) const { return this->completors[i]; };
    8585
    86     static void debug();
     86    void help() const;
    8787
    8888  protected:
  • trunk/src/lib/shell/shell_command_class.cc

    r7411 r7742  
    2424#include "compiler.h"
    2525
     26
     27
    2628namespace OrxShell
    2729{
    28   std::vector<ShellCommandClass*> ShellCommandClass::commandClassList;
     30  CmdClassList ShellCommandClass::commandClassList;
    2931
    3032  /**
     
    4042    this->classID = CL_NULL;
    4143
     44    printf("::: %d\n", commandClassList.size());
    4245    ShellCommandClass::commandClassList.push_back(this);
     46    printf("::: %d\n", commandClassList.size());
    4347  }
    4448
     
    5054    while(!this->commandList.empty())
    5155      delete this->commandList.back();
     56    CmdClassList::iterator delClass = std::find(ShellCommandClass::commandClassList.begin(), ShellCommandClass::commandClassList.end(), this);
     57    if (delClass != ShellCommandClass::commandClassList.end())
     58      ShellCommandClass::commandClassList.erase(delClass);
    5259  }
    5360
     
    5764  void ShellCommandClass::registerCommand(ShellCommand* command)
    5865  {
     66    printf("::::::::::: ADDED COMMAND:: '%s'\n", command->getName());
    5967    this->commandList.push_back(command);
    60   }
    61 
    62   /**
    63    * @brief unregister command.
     68    this->help();
     69  }
     70
     71  /**
     72   * @brief Unregisters a command.
    6473   * @param command the Command to unregister.
    6574   */
    6675  void ShellCommandClass::unregisterCommand(ShellCommand* command)
    6776  {
    68     std::vector<ShellCommand*>::iterator delC = std::find(this->commandList.begin(), this->commandList.end(), command);
     77    CmdList::iterator delC = std::find(this->commandList.begin(), this->commandList.end(), command);
    6978    if (delC != this->commandList.end())
    7079      this->commandList.erase(delC);
     
    7786  {
    7887    // unregister all commands and Classes
    79     std::vector<ShellCommandClass*>::iterator classIT;
    80     for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++)
    81       delete (*classIT);
     88    CmdClassList::iterator classIT;
     89
     90    while (!ShellCommandClass::commandClassList.empty())
     91      delete ShellCommandClass::commandClassList.back();
    8292  }
    8393
     
    91101  bool ShellCommandClass::getCommandListOfClass(const std::string& className, std::list<std::string>& stringList)
    92102  {
    93     std::vector<ShellCommandClass*>::iterator elem;
     103    CmdClassList::const_iterator elem;
    94104    for(elem = ShellCommandClass::commandClassList.begin(); elem != ShellCommandClass::commandClassList.end(); elem++)
    95105    {
    96106      if (className == (*elem)->getName())
    97107      {
    98         std::vector<ShellCommand*>::iterator command;
     108        CmdList::iterator command;
    99109        for(command = (*elem)->commandList.begin(); command != (*elem)->commandList.end(); command++)
    100110          stringList.push_back((*command)->getName());
     111        return true;
    101112      }
    102113    }
    103     return true;
     114    return false;
    104115  }
    105116
     
    110121   * @returns the CommandClass if found, NULL otherwise
    111122   */
    112   const ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className)
    113   {
    114     std::vector<ShellCommandClass*>::const_iterator classIT;
     123  ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className)
     124  {
     125    CmdClassList::const_iterator classIT;
    115126    for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++)
    116127      if (className == (*classIT)->className)
     
    144155  ShellCommandClass* ShellCommandClass::acquireCommandClass(const std::string& className)
    145156  {
    146     std::vector<ShellCommandClass*>::iterator classIT;
    147     for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++)
    148       if (className == (*classIT)->className)
    149         return (*classIT);
     157    ShellCommandClass* cmdClass = ShellCommandClass::getCommandClass(className);
     158    if (cmdClass != NULL)
     159      return (cmdClass);
    150160    return new ShellCommandClass(className);
    151161  }
     
    157167  void ShellCommandClass::help(const std::string& className)
    158168  {
    159     std::vector<ShellCommandClass*>::iterator classIT;
     169    if (className.empty())
     170      PRINT(0)("===== Displaying %d registered Classes:\n", ShellCommandClass::commandClassList.size());
     171
     172
     173    CmdClassList::iterator classIT;
    160174    for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++)
    161175    {
    162       if (className == (*classIT)->className)
     176      if (className.empty() || className == (*classIT)->className)
    163177      {
    164178        PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size());
    165         std::vector<ShellCommand*>::const_iterator cmdIT;
     179        CmdList::const_iterator cmdIT;
    166180        for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++)
    167181        {
     
    174188          PRINT(0)("\n");
    175189        }
    176         return;
     190        if (likely(!className.empty()))
     191          return;
    177192      }
    178193    }
    179     PRINTF(3)("Class %s not found in Command's classes\n", className.c_str());
    180   }
    181 
     194    PRINTF(3)("Class '%s' not found in Command's classes\n", className.c_str());
     195  }
    182196}
    183197
  • trunk/src/lib/shell/shell_command_class.h

    r7411 r7742  
    1010#include <vector>
    1111
    12 
    1312namespace OrxShell
    1413{
     
    1615  class ShellCommand;
    1716  class ShellCommandAlias;
     17  class ShellCommandClass;
     18
     19  typedef std::vector<ShellCommand*>      CmdList;
     20  typedef std::vector<ShellCommandClass*> CmdClassList;
     21
    1822
    1923  //! A class to hold all Classes that have (once) registered Commands.
     
    2125  {
    2226    friend class ShellCommand;
    23 
    2427  public:
    2528    /** @returns the CommandClassList */
    26     static const std::vector<ShellCommandClass*>& getCommandClassList() { return ShellCommandClass::commandClassList; };
     29    static const CmdClassList& getCommandClassList() { return ShellCommandClass::commandClassList; };
    2730
    2831    static bool getCommandListOfClass(const std::string& className, std::list<std::string>& stringList);
    2932
    3033    static void unregisterAllCommands();
    31     static const ShellCommandClass* getCommandClass(const std::string& className);
     34    static ShellCommandClass* getCommandClass(const std::string& className);
    3235    ClassID getClassID();
    3336    static bool exists(const std::string& className);
    3437
    35     static void help (const std::string& className);
     38    static void help (const std::string& className = "");
     39
     40    static void debug();
    3641
    3742  private:
     
    4752    const std::string                      className;                 //!< The Name of the Class. This should match the ClassName of the Commands Class.
    4853    ClassID                                classID;                   //!< The classID of this Class
    49     std::vector<ShellCommand*>             commandList;               //!< A list of Commands from this Class
     54    CmdList                                commandList;               //!< A list of Commands from this Class
    5055
    51     static std::vector<ShellCommandClass*> commandClassList;          //!< A list of Classes
     56    static CmdClassList                    commandClassList;          //!< A list of Classes
    5257  };
    5358
  • trunk/src/lib/util/executor/executor.cc

    r7721 r7742  
    106106
    107107/**
    108  * prints out nice information about the Executor
     108 * @brief prints out nice information about the Executor
    109109 */
    110110void Executor::debug()
    111111{
    112   /*  tIterator<ExecutorClass>* iteratorCL = ExecutorClass::commandClassList->getIterator();
    113     ExecutorClass* elemCL = iteratorCL->firstElement();
    114     while(elemCL != NULL)
    115     {
    116       PRINT(0)("Class:'%s' registered %d commands: \n", elemCL->className, elemCL->commandList->getSize());
    117       tIterator<Executor>* iterator = elemCL->commandList->getIterator();
    118       const Executor* elem = iterator->firstElement();
    119       while(elem != NULL)
    120       {
    121         PRINT(0)("  command:'%s' : params:%d: ", elem->getName(), elem->paramCount);
    122         for (unsigned int i = 0; i< elem->paramCount; i++)
    123          printf("%s ", Executor::paramToString(elem->parameters[i]));
    124         if (elem->description != NULL)
    125          printf("- %s", elem->description);
    126         printf("\n");
    127112
    128         elem = iterator->nextElement();
    129       }
    130       delete iterator;
    131       elemCL = iteratorCL->nextElement();
    132     }
    133     delete iteratorCL;*/
    134113}
Note: See TracChangeset for help on using the changeset viewer.