Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7747 was 7747, checked in by bensch, 18 years ago

trunk: added missing header inclusion

File size: 2.8 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
[5781]10#include <list>
[7747]11#include <stdarg.h>
[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
[7374]15namespace OrxShell
16{
17  // FORWARD DECLARATION
18  class Shell;
[5784]19
[7374]20  //! A class handling output from orxonox via debug.h
[7744]21  /**
22   * the ShellBuffer redirects output from PRINTF(x) to the Shell and STDOUT
23   * the ShellBuffer is a front-filling queue of limited length, that has the
24   * youngest added Entry at the beginning, and the oldest at the end.
25   */
[7374]26  class ShellBuffer
27  {
[3543]28
[7374]29  public:
30    virtual ~ShellBuffer();
31    /** @returns a Pointer to the only object of this Class */
32    inline static ShellBuffer* getInstance() { if (!ShellBuffer::singletonRef) ShellBuffer::singletonRef = new ShellBuffer();  return ShellBuffer::singletonRef; };
33    /** @returns true if this class is instanciated, false otherwise */
[7744]34    inline static bool isInstanciated() { return (ShellBuffer::singletonRef == NULL)?false:true; };
[1853]35
[7374]36    void registerShell(Shell* shell);
37    void unregisterShell(Shell* shell);
[1853]38
[7744]39    static bool addBufferLineStatic(const char* line, ...);
40    void addBufferLine(const char* line, va_list arg);
41
[7374]42    // BUFFER //
43    /** @param bufferSize the new Buffer-Size */
44    void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
45    void flush();
[7744]46
[7374]47    /** @returns the List of stings from the Buffer */
48    const std::list<std::string>& getBuffer() const { return this->buffer; };
49    /** @returns the Count of lines processed by the Shell. */
[7744]50    inline unsigned long getLineCount() const { return this->lineCount; };
[5206]51
[7374]52    void debug() const;
[5173]53
[5174]54  private:
55    ShellBuffer();
[5173]56
[5174]57  private:
[7737]58    static ShellBuffer*           singletonRef;                       //!< The singleton-reference to the only memeber of this class.
59    unsigned int                  bufferSize;                         //!< The Size of the buffer
[5174]60
[7737]61    Shell*                        shell;                              //!< the Registered Shell.
62    char                          bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
63    char                          keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
64    bool                          keepBuffer;                         //!< if the keepbuffer contains unfinished lines.
[5173]65
[7737]66    unsigned long                 lineCount;                          //!< how many Lines have been written out so far.
[7314]67
[7744]68    // The Beginning of buffer (buffer.front()) is the last added line.
[7737]69    static std::list<std::string> buffer;                             //!< A list of stored char-arrays(strings) to store the history
[7374]70  };
[1853]71
[7374]72}
73
[5173]74#endif /* _SHELL_BUFFER_H */
Note: See TracBrowser for help on using the repository browser.