Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8745 was 8145, checked in by bensch, 19 years ago

trunk: merged the gui back
merged with command:
svn merge -r8114:HEAD https://svn.orxonox.net/orxonox/branches/gui .
→ no conflicts

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