Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6363 was 5784, checked in by bensch, 19 years ago

orxonox/trunk: shell without tList now

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