Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9861 in orxonox.OLD for branches/new_class_id


Ignore:
Timestamp:
Oct 1, 2006, 1:37:36 PM (18 years ago)
Author:
bensch
Message:

Changed the ShellBuffer to DebugBuffer, as the dependency is only one way, and it makes no sense for the rest of Orxonox Modules to know the Shell

Location:
branches/new_class_id/src
Files:
8 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/Makefile.am

    r9839 r9861  
    5757                defs/confincl.h \
    5858                defs/error.h \
    59                 defs/debug.h \
    6059                defs/globals.h \
    6160                defs/compiler.h \
  • branches/new_class_id/src/lib/shell/Makefile.am

    r9709 r9861  
    66libORXshell_a_SOURCES = \
    77                shell.cc \
    8                 shell_buffer.cc \
    98                shell_input.cc \
    109                shell_command.cc \
     
    1615noinst_HEADERS= \
    1716                shell.h \
    18                 shell_buffer.h \
    1917                shell_input.h \
    2018                shell_command_class.h \
  • branches/new_class_id/src/lib/shell/shell.cc

    r9715 r9861  
    1818#include "shell.h"
    1919#include "shell_command.h"
    20 #include "shell_buffer.h"
     20#include "debug_buffer.h"
    2121#include "shell_input.h"
    2222
     
    6565    this->setName("Shell");
    6666
    67     this->shellBuffer = ShellBuffer::getInstance();
     67    this->shellBuffer = DebugBuffer::getInstance();
    6868
    6969    // EVENT-Handler subscription of '`' to all States.
     
    446446  {
    447447    this->flush();
    448     ShellBuffer::addBufferLineStatic("orxonox - shell\n ==================== \n", NULL);
     448    DebugBuffer::addBufferLineStatic("orxonox - shell\n ==================== \n", NULL);
    449449  }
    450450
  • branches/new_class_id/src/lib/shell/shell.h

    r9715 r9861  
    1414
    1515#include "shell_input.h"
    16 #include "shell_buffer.h"
     16#include "debug_buffer.h"
    1717#include "material.h"
    1818
     
    9393  private:
    9494    // GENERAL
    95     ShellBuffer*                shellBuffer;            //!< The local ShellBuffer.
     95    DebugBuffer*                shellBuffer;            //!< The local ShellBuffer.
    9696
    9797    bool                        bActive;                //!< If the shell is active.
  • branches/new_class_id/src/lib/shell/shell_input.cc

    r9715 r9861  
    161161  bool ShellInput::executeCommand()
    162162  {
    163     ShellBuffer::addBufferLineStatic("Execute Command: %s\n", this->inputLine.c_str());
     163    DebugBuffer::addBufferLineStatic("Execute Command: %s\n", this->inputLine.c_str());
    164164
    165165    if (this->inputLine.empty())
  • branches/new_class_id/src/lib/util/Makefile.am

    r9856 r9861  
    1414                helper_functions.cc \
    1515                multi_type.cc \
     16                debug_buffer.cc \
    1617                \
    1718                loading/resource_manager.cc \
     
    3940                color.h \
    4041                helper_functions.h \
     42                debug.h \
     43                debug_buffer.h \
    4144                \
    4245                \
  • branches/new_class_id/src/lib/util/debug.h

    r9860 r9861  
    2727
    2828#include "defs/confincl.h"
    29 #ifndef NO_SHELL
    30 #include "lib/shell/shell_buffer.h"
    31 #endif /* NO_SHELL */
     29#ifndef NO_BUFFER
     30#include "debug_buffer.h"
     31#endif /* NO_BUFFER */
    3232
    3333#include <stdio.h>
     
    114114#endif
    115115#ifndef NO_SHELL
    116 #define PRINT_EXEC       OrxShell::ShellBuffer::addBufferLineStatic
     116#define PRINT_EXEC       DebugBuffer::addBufferLineStatic
    117117#define COUT_EXEC        std::cout
    118118#else /* NO_SHELL */
  • branches/new_class_id/src/lib/util/debug_buffer.cc

    r9859 r9861  
    1414*/
    1515
    16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SHELL
    17 
    18 #include "shell_buffer.h"
     16#include "debug_buffer.h"
    1917
    2018#include <stdarg.h>
     
    2220#include "debug.h"
    2321#include "compiler.h"
    24 #include "lib/util/threading.h"
     22#include "threading.h"
    2523
    26 namespace OrxShell
     24/**
     25 * @brief standard constructor
     26 */
     27DebugBuffer::DebugBuffer ()
    2728{
    28   /**
    29    * @brief standard constructor
    30    */
    31   ShellBuffer::ShellBuffer ()
    32   {
    33     ShellBuffer::singletonRef = this;
     29  DebugBuffer::singletonRef = this;
    3430
    35     this->lineCount = 0;
    36     this->bufferArray[0] = '\0';
     31  this->lineCount = 0;
     32  this->bufferArray[0] = '\0';
    3733
    38     this->setMaxBufferSize(100);
    39   }
     34  this->setMaxBufferSize(100);
     35}
    4036
    41   ShellBuffer* ShellBuffer::singletonRef = NULL;
    42   std::list<std::string> ShellBuffer::buffer;
    43   char ShellBuffer::bufferArray[SHELL_BUFFER_SIZE] = "";
     37DebugBuffer* DebugBuffer::singletonRef = NULL;
     38std::list<std::string> DebugBuffer::buffer;
     39char DebugBuffer::bufferArray[DEBUG_BUFFER_SIZE] = "";
    4440
    4541
    46   /**
    47    * @brief standard deconstructor
    48    */
    49   ShellBuffer::~ShellBuffer ()
    50   {
    51     ShellBuffer::singletonRef = NULL;
    52   }
     42/**
     43 * @brief standard deconstructor
     44 */
     45DebugBuffer::~DebugBuffer ()
     46{
     47  DebugBuffer::singletonRef = NULL;
     48}
    5349
    54   /**
    55    * @brief deletes all the Buffers
    56    */
    57   void ShellBuffer::flush()
    58   {
    59     this->buffer.clear();
    60   }
     50/**
     51 * @brief deletes all the Buffers
     52 */
     53void DebugBuffer::flush()
     54{
     55  this->buffer.clear();
     56}
    6157
    62   /**
    63    * @brief adds a new Line to the List of Buffers
    64    * @param line the Line as in the first argument in printf
    65    */
    66   void ShellBuffer::addBufferLineStatic(const char* line, ...)
    67   {
    68     static OrxThread::Mutex ShellBuffer__bufferMutex;
     58/**
     59 * @brief adds a new Line to the List of Buffers
     60 * @param line the Line as in the first argument in printf
     61 */
     62void DebugBuffer::addBufferLineStatic(const char* line, ...)
     63{
     64  static OrxThread::Mutex DebugBuffer__bufferMutex;
    6965
    70     OrxThread::MutexLock bufferLock(&ShellBuffer__bufferMutex);
     66  OrxThread::MutexLock bufferLock(&DebugBuffer__bufferMutex);
    7167
    72     va_list arguments;
    73     va_start(arguments, line);
    74     vsnprintf(ShellBuffer::bufferArray, SHELL_BUFFER_SIZE, line, arguments);
    75     va_end(arguments);
     68  va_list arguments;
     69  va_start(arguments, line);
     70  vsnprintf(DebugBuffer::bufferArray, DEBUG_BUFFER_SIZE, line, arguments);
     71  va_end(arguments);
    7672
    7773#if DEBUG_LEVEL < 3
    78     if (ShellBuffer::singletonRef == NULL)
     74  if (DebugBuffer::singletonRef == NULL)
    7975#endif
    80       printf(ShellBuffer::bufferArray);
     76    printf(DebugBuffer::bufferArray);
    8177#if DEBUG_LEVEL < 3
    82     else
     78  else
    8379#else
    84     if (ShellBuffer::singletonRef != NULL)
     80  if (DebugBuffer::singletonRef != NULL)
    8581#endif
    86       ShellBuffer::singletonRef->addBufferLine(ShellBuffer::bufferArray);
     82    DebugBuffer::singletonRef->addBufferLine(DebugBuffer::bufferArray);
     83}
     84
     85/**
     86 * @brief add a Line to the List of Buffers
     87 * @param line
     88 * @param arguments
     89 *
     90 * This function Adds one line to the buffer.
     91 * and displays the line as the First Line of the display-buffer
     92 */
     93void DebugBuffer::addBufferLine(const char* line)
     94{
     95  std::string inputBuffer = this->keepBuffer + line;
     96
     97  unsigned int lineBegin = 0;
     98  unsigned int lineEnd = 0;
     99  // adding all the new Lines
     100  while (lineEnd < inputBuffer.size())
     101  {
     102    lineBegin = lineEnd;
     103    lineEnd = inputBuffer.find('\n', (lineBegin == 0) ? 0: ++lineBegin);
     104    if (likely(lineEnd != std::string::npos ))
     105    {
     106      this->lineCount++;
     107      this->buffer.push_front(inputBuffer.substr(lineBegin, lineEnd - lineBegin));
     108    }
     109    else      // No end of Line reached.
     110    {
     111      this->keepBuffer = inputBuffer.substr(lineBegin, inputBuffer.size() - lineBegin);
     112      break;
     113    }
     114
     115    if (inputBuffer[lineBegin] == '\n')
     116      lineBegin++, lineEnd++;
     117
     118    if (this->buffer.size() > this->maxBufferSize)
     119      this->buffer.pop_back();
    87120  }
     121}
    88122
    89   /**
    90    * @brief add a Line to the List of Buffers
    91    * @param line
    92    * @param arguments
    93    *
    94    * This function Adds one line to the buffer.
    95    * and displays the line as the First Line of the display-buffer
    96    */
    97   void ShellBuffer::addBufferLine(const char* line)
    98   {
    99     std::string inputBuffer = this->keepBuffer + line;
     123/**
     124 * @brief displays some nice output from the Debug
     125 */
     126void DebugBuffer::debug() const
     127{
     128  PRINT(3)("Debugging output to console (not this debug)\n");
    100129
    101     unsigned int lineBegin = 0;
    102     unsigned int lineEnd = 0;
    103     // adding all the new Lines
    104     while (lineEnd < inputBuffer.size())
    105     {
    106       lineBegin = lineEnd;
    107       lineEnd = inputBuffer.find('\n', (lineBegin == 0) ? 0: ++lineBegin);
    108       if (likely(lineEnd != std::string::npos ))
    109       {
    110         this->lineCount++;
    111         this->buffer.push_front(inputBuffer.substr(lineBegin, lineEnd - lineBegin));
    112       }
    113       else      // No end of Line reached.
    114       {
    115         this->keepBuffer = inputBuffer.substr(lineBegin, inputBuffer.size() - lineBegin);
    116         break;
    117       }
    118 
    119       if (inputBuffer[lineBegin] == '\n')
    120         lineBegin++, lineEnd++;
    121 
    122       if (this->buffer.size() > this->maxBufferSize)
    123         this->buffer.pop_back();
    124     }
    125   }
    126 
    127   /**
    128    * @brief displays some nice output from the Shell
    129    */
    130   void ShellBuffer::debug() const
    131   {
    132     PRINT(3)("Debugging output to console (not this shell)\n");
    133 
    134     std::list<std::string>::const_iterator bufferLine;
    135     for (bufferLine = --this->buffer.end(); bufferLine != this->buffer.begin(); --bufferLine)
    136       printf((*bufferLine).c_str());
    137   }
    138 
     130  std::list<std::string>::const_iterator bufferLine;
     131  for (bufferLine = --this->buffer.end(); bufferLine != this->buffer.begin(); --bufferLine)
     132    printf((*bufferLine).c_str());
    139133}
  • branches/new_class_id/src/lib/util/debug_buffer.h

    r9859 r9861  
    11/*!
    2  * @file shell_buffer.h
    3  * @brief The Shell buffer Tasks
     2 * @file debug_buffer.h
     3 * @brief The Debug buffer Tasks
    44 * @see debug.h
    55*/
    66
    7 #ifndef _SHELL_BUFFER_H
    8 #define _SHELL_BUFFER_H
     7#ifndef _DEBUG_BUFFER_H
     8#define _DEBUG_BUFFER_H
    99
    1010#include <string>
    1111#include <list>
    12 #include <stdarg.h>
    1312
    14 #define      SHELL_BUFFER_SIZE       16384         //!< The Size of the input-buffers (should be large enough to carry any kind of input)
     13#define      DEBUG_BUFFER_SIZE       16384         //!< The Size of the input-buffers (should be large enough to carry any kind of input)
    1514
    16 namespace OrxShell
    17 {
    1815  //! A class handling output from orxonox via debug.h
    1916  /**
    20    * the ShellBuffer redirects output from PRINTF(x) to the Shell and STDOUT
    21    * the ShellBuffer is a front-filling queue of limited length, that has the
     17   * the DebugBuffer redirects output from PRINTF(x) to the Debug and STDOUT
     18   * the DebugBuffer is a front-filling queue of limited length, that has the
    2219   * youngest added Entry at the beginning, and the oldest at the end.
    2320   */
    24   class ShellBuffer
     21  class DebugBuffer
    2522  {
    2623  public:
    27     virtual ~ShellBuffer();
     24    virtual ~DebugBuffer();
    2825    /** @returns a Pointer to the only object of this Class */
    29     inline static ShellBuffer* getInstance() { if (!ShellBuffer::singletonRef) ShellBuffer::singletonRef = new ShellBuffer();  return ShellBuffer::singletonRef; };
     26    inline static DebugBuffer* getInstance() { if (!DebugBuffer::singletonRef) DebugBuffer::singletonRef = new DebugBuffer();  return DebugBuffer::singletonRef; };
    3027    /** @returns true if this class is instanciated, false otherwise */
    31     inline static bool isInstanciated() { return (ShellBuffer::singletonRef == NULL)?false:true; };
     28    inline static bool isInstanciated() { return (DebugBuffer::singletonRef == NULL)?false:true; };
    3229
    3330    static void addBufferLineStatic(const char* line, ...);
     
    4138    /** @returns the List of stings from the Buffer */
    4239    const std::list<std::string>& getBuffer() const { return this->buffer; };
    43     /** @returns the Count of lines processed by the Shell. */
     40    /** @returns the Count of lines processed by the Debug. */
    4441    inline unsigned long getLineCount() const { return this->lineCount; };
    4542    /** @returns the Current Buffer Size. */
     
    4946
    5047  private:
    51     ShellBuffer();
     48    DebugBuffer();
    5249
    5350  private:
    54     static ShellBuffer*           singletonRef;                       //!< The singleton-reference to the only memeber of this class.
    55     unsigned int                  maxBufferSize;                         //!< The Size of the buffer
     51    static DebugBuffer*           singletonRef;                       //!< The singleton-reference to the only memeber of this class.
     52    unsigned int                  maxBufferSize;                      //!< The Size of the buffer
    5653
    57     std::string                   keepBuffer;                         //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
     54    std::string                   keepBuffer;                         //!< a BUFFER to have multi-non-newLine commands be copied into the debug.
    5855
    5956    unsigned long                 lineCount;                          //!< how many Lines have been written out so far.
    6057
    6158    // The Beginning of buffer (buffer.front()) is the last added line.
    62     static char                   bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
     59    static char                   bufferArray[DEBUG_BUFFER_SIZE];     //!< a BUFFER for fast writing
    6360    static std::list<std::string> buffer;                             //!< A list of stored char-arrays(strings) to store the history
    6461  };
    6562
    66 }
    67 
    68 #endif /* _SHELL_BUFFER_H */
     63#endif /* _DEBUG_BUFFER_H */
  • branches/new_class_id/src/orxonox.cc

    r9855 r9861  
    5151#include "shell_command_class.h"
    5252#include "shell_command.h"
    53 #include "shell_buffer.h"
    5453
    5554#include "network_manager.h"
     
    138137  Resources::ResourceManager::deleteInstance();
    139138  // output-buffer
    140   delete OrxShell::ShellBuffer::getInstance();
     139  delete DebugBuffer::getInstance();
    141140
    142141  SDL_QuitSubSystem(SDL_INIT_TIMER);
     
    389388int Orxonox::initMisc()
    390389{
    391   OrxShell::ShellBuffer::getInstance();
     390  DebugBuffer::getInstance();
    392391
    393392  // start the collision detection engine
Note: See TracChangeset for help on using the changeset viewer.