Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5781 in orxonox.OLD


Ignore:
Timestamp:
Nov 26, 2005, 4:17:20 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: more stl::list

Location:
trunk/src/lib/shell
Files:
5 edited

Legend:

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

    r5767 r5781  
    7575  this->bufferDisplaySize = 10;
    7676  this->bufferOffset = 0;
    77   this->bufferIterator = ShellBuffer::getInstance()->getBuffer()->getIterator();
     77  this->bufferIterator = ShellBuffer::getInstance()->getBuffer()->begin();
    7878
    7979  // INPUT LINE
     
    111111    delete this->bufferText[i];
    112112  delete[] this->bufferText;
    113   delete this->bufferIterator;
    114113  delete[] this->fontFile;
    115114  // delete the inputLine
     
    132131  this->setRelCoorSoft2D(0, 0, 1, 5);
    133132
    134   tIterator<char>* bufferIT = ShellBuffer::getInstance()->getBuffer()->getIterator();
    135   bufferIT->lastElement();
     133  list<char*>::const_reverse_iterator textLine = ShellBuffer::getInstance()->getBuffer()->rbegin();
    136134  for (int i = 0; i < this->bufferDisplaySize; i++)
    137135  {
    138     this->bufferText[i]->setText(bufferIT->getCurrent(), true);
     136    this->bufferText[i]->setText((*textLine), true);
    139137    this->bufferText[i]->setVisibility(true);
    140     bufferIT->prevStep();
    141   }
    142   delete bufferIT;
     138    textLine--;
     139  }
    143140}
    144141
     
    156153  this->setRelCoorSoft2D(0, -(int)this->shellHeight, 1, 5);
    157154
    158   tIterator<char>* bufferIT = ShellBuffer::getInstance()->getBuffer()->getIterator();
    159   bufferIT->lastElement();
     155  list<char*>::const_reverse_iterator textLine = ShellBuffer::getInstance()->getBuffer()->rbegin();
    160156  for (int i = 0; i < this->bufferDisplaySize; i++)
    161157  {
    162     this->bufferText[i]->setText(bufferIT->getCurrent(), false);
    163     bufferIT->prevStep();
     158    this->bufferText[i]->setText((*textLine), false);
    164159    this->bufferText[i]->setVisibility(false);
    165   }
    166   delete bufferIT;
    167 
     160    textLine--;
     161  }
    168162  this->bufferOffset = 0;
    169163}
     
    307301  }
    308302
    309   tIterator<char>* it = ShellBuffer::getInstance()->getBuffer()->getIterator();
    310   char* text = it->lastElement();
     303  list<char*>::const_reverse_iterator textLine = ShellBuffer::getInstance()->getBuffer()->rbegin();
    311304  bufferText = new Text*[bufferDisplaySize];
    312305  for (unsigned int i = 0; i < bufferDisplaySize; i++)
     
    314307    bufferText[i] = new Text(this->fontFile, this->textSize);
    315308    bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);
    316     bufferText[i]->setText(text);
     309    bufferText[i]->setText(*textLine);
    317310    bufferText[i]->setParent2D(this);
    318     text = it->prevElement();
    319   }
    320   delete it;
     311    textLine--;
     312  }
    321313  this->bufferDisplaySize = bufferDisplaySize;
    322314
     
    386378void Shell::moveDisplayBuffer(int lineCount)
    387379{
    388   if (!this->bufferIterator->compareListPointer(ShellBuffer::getInstance()->getBuffer()))
    389   {
    390     delete this->bufferIterator;
    391     this->bufferIterator = ShellBuffer::getInstance()->getBuffer()->getIterator();
    392   }
    393 
    394   if (this->bufferOffset == 0)
    395    {
    396      this->bufferIterator->lastElement();
    397 //     for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
     380  /// FIXME
     381//   if (!this->bufferIterator->compareListPointer(ShellBuffer::getInstance()->getBuffer()))
     382//   {
     383//     delete this->bufferIterator;
     384//     this->bufferIterator = ShellBuffer::getInstance()->getBuffer()->getIterator();
     385//   }
     386//
     387//   if (this->bufferOffset == 0)
     388//    {
     389//      this->bufferIterator->lastElement();
     390// //     for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
     391// //       this->bufferIterator->prevStep();
     392//    }
     393//
     394//   // boundraries
     395//   if (this->bufferOffset + lineCount > (int)ShellBuffer::getInstance()->getBuffer()->getSize())
     396//     lineCount = (int)ShellBuffer::getInstance()->getBuffer()->getSize()- this->bufferOffset;
     397//   else if (this->bufferOffset + lineCount < 0)
     398//     lineCount = -bufferOffset;
     399//   this->bufferOffset += lineCount;
     400//
     401//   // moving the iterator to the right position
     402//   int move = 0;
     403//   while (move != lineCount)
     404//   {
     405//     if (move < lineCount)
     406//     {
     407//       ++move;
    398408//       this->bufferIterator->prevStep();
    399    }
    400 
    401   // boundraries
    402   if (this->bufferOffset + lineCount > (int)ShellBuffer::getInstance()->getBuffer()->getSize())
    403     lineCount = (int)ShellBuffer::getInstance()->getBuffer()->getSize()- this->bufferOffset;
    404   else if (this->bufferOffset + lineCount < 0)
    405     lineCount = -bufferOffset;
    406   this->bufferOffset += lineCount;
    407 
    408   // moving the iterator to the right position
    409   int move = 0;
    410   while (move != lineCount)
    411   {
    412     if (move < lineCount)
    413     {
    414       ++move;
    415       this->bufferIterator->prevStep();
    416     }
    417     else
    418     {
    419       --move;
    420       this->bufferIterator->nextStep();
    421     }
    422   }
    423   // redisplay the buffers
    424   tIterator<char> it = *this->bufferIterator;
    425   for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
    426   {
    427     this->bufferText[i]->setText(it.getCurrent(), false);
    428     it.prevStep();
    429   }
     409//     }
     410//     else
     411//     {
     412//       --move;
     413//       this->bufferIterator->nextStep();
     414//     }
     415//   }
     416//   // redisplay the buffers
     417//   tIterator<char> it = *this->bufferIterator;
     418//   for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
     419//   {
     420//     this->bufferText[i]->setText(it.getCurrent(), false);
     421//     it.prevStep();
     422//   }
    430423}
    431424
  • trunk/src/lib/shell/shell.h

    r5513 r5781  
    9191  private:
    9292    // GENERAL
    93     bool                     bActive;                //!< If the shell is active.
    94     unsigned int             shellHeight;            //!< The hight of the Shell in Pixels.
    95     unsigned int             lineSpacing;            //!< The Spacing between lines.
    96     unsigned int             textSize;               //!< The size of the text.
    97     float                    textColor[4];           //!< The text's color [r,g,b,a].
    98     char*                    fontFile;               //!< The file containing the font.
    99     Material*                backgroundMaterial;     //!< A material for the background.
     93    bool                        bActive;                //!< If the shell is active.
     94    unsigned int                shellHeight;            //!< The hight of the Shell in Pixels.
     95    unsigned int                lineSpacing;            //!< The Spacing between lines.
     96    unsigned int                textSize;               //!< The size of the text.
     97    float                       textColor[4];           //!< The text's color [r,g,b,a].
     98    char*                       fontFile;               //!< The file containing the font.
     99    Material*                   backgroundMaterial;     //!< A material for the background.
    100100
    101101    // HANDLING TEXT INPUT
    102     ShellInput*              shellInput;             //!< The inputLine of the Shell.
     102    ShellInput*                 shellInput;             //!< The inputLine of the Shell.
    103103    // BUFFER
    104     unsigned int             bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
    105     Text**                   bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
    106     int                      bufferOffset;           //!< how many lines from the bottom up we display the Buffer.
    107     tIterator<char>*         bufferIterator;         //!< used to move through and print the Buffer
     104    unsigned int                bufferDisplaySize;      //!< The Size of the Display-buffer, in lines (not in characters).
     105    Text**                      bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
     106    int                         bufferOffset;           //!< how many lines from the bottom up we display the Buffer.
     107    std::list<char*>::const_iterator  bufferIterator;         //!< used to move through and print the Buffer
    108108};
    109109
  • trunk/src/lib/shell/shell_buffer.cc

    r5290 r5781  
    3838  this->bufferArray[0] = '\0';
    3939  this->keepBuffer = false;
    40   this->buffer = new tList<char>;
    4140
    4241  this->setBufferSize(100);
     
    5453
    5554  this->flush();
    56   delete buffer;
    5755
    5856  ShellBuffer::singletonRef = NULL;
     
    8987{
    9088  // delete all the Chars in the Buffers
    91   tIterator<char>* bufferIterator = this->buffer->getIterator();
    92   char* charElem = bufferIterator->firstElement();
    93   while (charElem != NULL)
     89  list<char*>::iterator bufferLine;
     90  for (bufferLine = this->buffer.begin(); bufferLine != this->buffer.end(); bufferLine++)
    9491  {
    95     delete[] charElem;
    96     charElem = bufferIterator->nextElement();
     92    delete[] (*bufferLine);
    9793  }
    98   delete bufferIterator;
    99   delete this->buffer;
    100   this->buffer = new tList<char>;
     94  this->buffer.erase(this->buffer.begin(), this->buffer.end());
    10195}
    10296
     
    178172
    179173    this->lineCount++;
    180     this->buffer->add(addLine);
     174    this->buffer.push_back(addLine);
    181175    if (likely (this->shell != NULL) && unlikely (this->shell->isActive()))
    182176      this->shell->printToDisplayBuffer(addLine);
    183177
    184     if (this->buffer->getSize() > this->bufferSize)
     178    if (this->buffer.size() > this->bufferSize)
    185179    {
    186       delete[] this->buffer->firstElement();
    187       this->buffer->remove(this->buffer->firstElement());
     180      delete[] this->buffer.front();
     181      this->buffer.pop_front();
    188182    }
    189183
     
    199193  PRINT(3)("Debugging output to console (not this shell)\n");
    200194
    201   tIterator<char>* charIterator = this->buffer->getIterator();
    202   char* tmpChar = charIterator->firstElement();
    203   while(tmpChar != NULL)
    204   {
    205     printf(tmpChar);
    206     tmpChar = charIterator->nextElement();
    207   }
    208   delete charIterator;
     195  list<char*>::const_iterator bufferLine;
     196  for (bufferLine = this->buffer.begin(); bufferLine != this->buffer.end(); bufferLine++)
     197    printf(*bufferLine);
    209198}
  • trunk/src/lib/shell/shell_buffer.h

    r5246 r5781  
    99
    1010#include <stdarg.h>
     11#include <list>
    1112
    1213#define      SHELL_BUFFER_SIZE       16384         //!< The Size of the input-buffers (should be large enough to carry any kind of input)
     
    3940  void addBufferLine(const char* line, va_list arg);
    4041  /** @returns the List of stings from the Buffer */
    41   const tList<char>* getBuffer() const { return this->buffer; };
     42  const std::list<char*>* getBuffer() const { return &this->buffer; };
    4243 /** @returns the Count of lines processed by the Shell. */
    4344  inline long getLineCount() const { return this->lineCount; };
     
    4950
    5051  private:
    51    static ShellBuffer*      singletonRef;                       //!< The singleton-reference to the only memeber of this class.
    52    unsigned int             bufferSize;                         //!< The Size of the buffer
    53    tList<char>*             buffer;                             //!< A list of stored char-arrays(strings) to store the history
     52    static ShellBuffer*      singletonRef;                       //!< The singleton-reference to the only memeber of this class.
     53    unsigned int             bufferSize;                         //!< The Size of the buffer
     54    std::list<char*>         buffer;                             //!< A list of stored char-arrays(strings) to store the history
    5455
    55    Shell*                   shell;                              //!< the Registered Shell.
    56    char                     bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
    57    char                     keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
    58    bool                     keepBuffer;                         //!< if the keepbuffer contains unfinished lines.
     56    Shell*                   shell;                              //!< the Registered Shell.
     57    char                     bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
     58    char                     keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
     59    bool                     keepBuffer;                         //!< if the keepbuffer contains unfinished lines.
    5960
    60    unsigned long            lineCount;                          //!< how many Lines have been written out so far.
     61    unsigned long            lineCount;                          //!< how many Lines have been written out so far.
    6162};
    6263
  • trunk/src/lib/shell/shell_command_class.h

    r5779 r5781  
    1212
    1313// FORWARD DECLARATION
    14 template<class T> class tList;
    1514
    1615////////////////
Note: See TracChangeset for help on using the changeset viewer.