Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5206 in orxonox.OLD


Ignore:
Timestamp:
Sep 19, 2005, 12:31:56 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Shell no more singleton, and ShellInput is now derive from Text correctly

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r5190 r5206  
    8181  CL_WEAPON                     =    0x00120000,
    8282
    83   // subsuper-classes derivations taken : 1, a.     << THIS IS A LIST OF ALL THE DCL_MASK_SUBSUPERCLASS_ID's taken
     83  // subsuper-classes derivations taken : 1, a, b.     << THIS IS A LIST OF ALL THE DCL_MASK_SUBSUPERCLASS_ID's taken
    8484
    8585  // lowest level classes
     
    110110  CL_RENDER_2D                  =    0x00000f21,
    111111  CL_NULL_ELEMENT_2D            =    0x00000f22,
    112   CL_SHELL                      =    0x00000f31,
    113112  CL_SHELL_BUFFER               =    0x00000f32,
    114113
     
    160159
    161160  // graphical stuff (range from 0x00000800 to 0x000009ff)
    162   CL_TEXT                       =    0x00000801,
     161  CL_TEXT                       =    0x00b01801,
    163162  CL_FONT                       =    0x00000802,
    164163  CL_MATERIAL                   =    0x00000803,
     
    195194  CL_NUMBER                     =    0x00000b0c,
    196195  CL_FAST_FACTORY               =    0x00000c01,
     196  CL_SHELL                      =    0x00000c10,
    197197  CL_SHELL_COMMAND              =    0x00000c11,
    198198  CL_SHELL_COMMAND_CLASS        =    0x00000c12,
  • trunk/src/lib/shell/shell.cc

    r5204 r5206  
    5050  this->setName("Shell");
    5151
     52  // register the shell at the ShellBuffer
     53  ShellBuffer::getInstance()->registerShell(this);
     54
     55
    5256  // Element2D and generals
    5357  this->setAbsCoor2D(3, -400);
     
    7175}
    7276
    73 Shell* Shell::singletonRef = NULL;
    74 
    7577/**
    7678 * standard deconstructor
     
    8587  // delete the inputLine
    8688  delete this->shellInput;
    87 
    88   Shell::singletonRef = NULL;
     89  ShellBuffer::getInstance()->unregisterShell(this);
    8990}
    9091
     
    198199      this->bufferText[i]->setText(NULL, true);
    199200    }
    200 
    201 
    202     // BUFFER FLUSHING
     201  // BUFFER FLUSHING
    203202}
    204203
     
    240239}
    241240
    242 
    243 
    244241/**
    245242 * listens for some event
     
    322319}
    323320
    324 
    325 
    326321// void Shell::testI (int i)
    327322// {
  • trunk/src/lib/shell/shell.h

    r5204 r5206  
    3636
    3737  public:
     38    Shell();
    3839    virtual ~Shell();
    39     /** @returns a Pointer to the only object of this Class */
    40     inline static Shell* getInstance() { if (!Shell::singletonRef) Shell::singletonRef = new Shell();  return Shell::singletonRef; };
    41     /** @returns true if this class is instanciated, false otherwise */
    42     inline static bool isInstanciated() { return (Shell::singletonRef == NULL)?false:true; };
    4340
    4441    void activate();
     
    7572
    7673  private:
    77     Shell();
    78     static Shell*            singletonRef;           //!< The singleton-reference to the only memeber of this class.
    7974
    8075    // GENERAL
  • trunk/src/lib/shell/shell_buffer.cc

    r5183 r5206  
    3333{
    3434  ShellBuffer::singletonRef = this;
     35  this->shell = NULL;
    3536
    3637  this->lineCount = 0;
     
    5051ShellBuffer::~ShellBuffer ()
    5152{
    52   if (Shell::isInstanciated())
    53     delete Shell::getInstance();
     53  if (this->shell != NULL)
     54    delete this->shell;
    5455
    5556  this->flushBuffers();
     
    5859
    5960  ShellBuffer::singletonRef = NULL;
     61}
     62
     63/**
     64 * registers the Shell to the Buffer
     65 * @param shell the Shell to register.
     66 */
     67void ShellBuffer::registerShell(Shell* shell)
     68{
     69  if (this->shell == NULL)
     70    this->shell = shell;
     71  else
     72    PRINTF(1)("already registered a Shell to the ShellBuffer\n");
     73}
     74
     75/**
     76 * unregisters the Shell from the Buffer
     77 * @param shell the Shell to unregister.
     78 */
     79void ShellBuffer::unregisterShell(Shell* shell)
     80{
     81  if (this->shell == shell)
     82    this->shell = NULL;
     83  else
     84    PRINTF(1)("cannot unregister shell, because it is not registered to the ShellBuffer\n");
    6085}
    6186
     
    150175    this->lineCount++;
    151176    this->buffer->add(addLine);
    152     if (Shell::isInstanciated() && Shell::getInstance()->isActive())
    153       Shell::getInstance()->printToDisplayBuffer(addLine);
     177    if (likely (this->shell != NULL) && unlikely (this->shell->isActive()))
     178      this->shell->printToDisplayBuffer(addLine);
    154179
    155180    if (this->buffer->getSize() > this->bufferSize)
  • trunk/src/lib/shell/shell_buffer.h

    r5177 r5206  
    1212
    1313// FORWARD DECLARATION
     14class Shell;
    1415template<class T> class tList;
    1516template<class T> class tIterator;
     
    2728  /** @returns true if this class is instanciated, false otherwise */
    2829  inline static bool isInstanciated() { return (ShellBuffer::singletonRef == NULL)?false:true; };
     30
     31  void registerShell(Shell* shell);
     32  void unregisterShell(Shell* shell);
    2933
    3034  // BUFFER //
     
    5458   tIterator<char>*         bufferIterator;                     //!< An iterator for the Shells main buffer.
    5559
     60   Shell*                   shell;                              //!< the Registered Shell.
    5661   char                     bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
    5762   char                     keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
  • trunk/src/story_entities/world.cc

    r5205 r5206  
    119119World::~World ()
    120120{
    121   delete Shell::getInstance();
     121  delete this->shell;
    122122  PRINTF(3)("World::~World() - deleting current world\n");
    123123
     
    200200
    201201  /* init the world interface */
    202   Shell::getInstance();
     202  this->shell = new Shell();
    203203
    204204  LightManager::getInstance();
  • trunk/src/story_entities/world.h

    r5205 r5206  
    2424class PilotNode;
    2525
     26class Shell;
    2627class OggPlayer;
    2728
     
    9394  char* path;                         //!< The file from which this world is loaded
    9495
    95 
     96  Shell*     shell;
    9697  OggPlayer* music;
    9798
Note: See TracChangeset for help on using the changeset viewer.