Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/shell/shell_buffer.h @ 5678

Last change on this file since 5678 was 5246, checked in by bensch, 19 years ago

orxonox/trunk: minimalized the ShellBuffer

File size: 2.5 KB
RevLine 
[4838]1/*!
[5173]2 * @file shell_buffer.h
3 * @brief The Shell buffer Tasks
[5246]4 * @see debug.h
[3245]5*/
[1853]6
[5173]7#ifndef _SHELL_BUFFER_H
8#define _SHELL_BUFFER_H
[1853]9
[5173]10#include <stdarg.h>
11
12#define      SHELL_BUFFER_SIZE       16384         //!< The Size of the input-buffers (should be large enough to carry any kind of input)
13
[4838]14// FORWARD DECLARATION
[5206]15class Shell;
[5173]16template<class T> class tList;
[5175]17#ifndef NULL
18#define NULL 0            //!< a pointer to NULL
19#endif
[3543]20
[5246]21//! A class handling output from orxonox via debug.h
[5173]22class ShellBuffer {
[1853]23
[1904]24 public:
[5173]25  virtual ~ShellBuffer();
[5174]26  /** @returns a Pointer to the only object of this Class */
27  inline static ShellBuffer* getInstance() { if (!ShellBuffer::singletonRef) ShellBuffer::singletonRef = new ShellBuffer();  return ShellBuffer::singletonRef; };
[5175]28  /** @returns true if this class is instanciated, false otherwise */
[5176]29  inline static bool isInstanciated() { return (ShellBuffer::singletonRef == NULL)?false:true; };
[1853]30
[5206]31  void registerShell(Shell* shell);
32  void unregisterShell(Shell* shell);
33
[5173]34  // BUFFER //
35  /** @param bufferSize the new Buffer-Size */
36  void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
[5246]37  void flush();
[5173]38  static bool addBufferLineStatic(const char* line, ...);
39  void addBufferLine(const char* line, va_list arg);
[5246]40  /** @returns the List of stings from the Buffer */
41  const tList<char>* getBuffer() const { return this->buffer; };
42 /** @returns the Count of lines processed by the Shell. */
[5176]43  inline long getLineCount() const { return this->lineCount; };
[5173]44
[5177]45  void debug() const;
46
[5174]47  private:
48    ShellBuffer();
[5173]49
[5174]50  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
54
[5206]55   Shell*                   shell;                              //!< the Registered Shell.
[5173]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.
[5174]58   bool                     keepBuffer;                         //!< if the keepbuffer contains unfinished lines.
[5173]59
[5174]60   unsigned long            lineCount;                          //!< how many Lines have been written out so far.
[1853]61};
62
[5173]63#endif /* _SHELL_BUFFER_H */
Note: See TracBrowser for help on using the repository browser.