Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8710 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
Line 
1/*!
2 * @file shell_buffer.h
3 * @brief The Shell buffer Tasks
4 * @see debug.h
5*/
6
7#ifndef _SHELL_BUFFER_H
8#define _SHELL_BUFFER_H
9
10#include <string>
11#include <list>
12#include <stdarg.h>
13
14#define      SHELL_BUFFER_SIZE       16384         //!< The Size of the input-buffers (should be large enough to carry any kind of input)
15
16namespace OrxShell
17{
18  //! A class handling output from orxonox via debug.h
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   */
24  class ShellBuffer
25  {
26
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 */
32    inline static bool isInstanciated() { return (ShellBuffer::singletonRef == NULL)?false:true; };
33
34    static void addBufferLineStatic(const char* line, ...);
35    void addBufferLine(const char* line);
36
37    /// BUFFER
38    /** @param bufferSize the new Buffer-Size */
39    void setMaxBufferSize(unsigned int maxBufferSize) { this->maxBufferSize = maxBufferSize; };
40    void flush();
41
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. */
45    inline unsigned long getLineCount() const { return this->lineCount; };
46    /** @returns the Current Buffer Size. */
47    inline unsigned int getBufferSize() const { return this->buffer.size(); };
48
49    void debug() const;
50
51  private:
52    ShellBuffer();
53
54  private:
55    static ShellBuffer*           singletonRef;                       //!< The singleton-reference to the only memeber of this class.
56    unsigned int                  maxBufferSize;                         //!< The Size of the buffer
57
58    std::string                   keepBuffer;                         //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
59
60    unsigned long                 lineCount;                          //!< how many Lines have been written out so far.
61
62    // The Beginning of buffer (buffer.front()) is the last added line.
63    static char                   bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
64    static std::list<std::string> buffer;                             //!< A list of stored char-arrays(strings) to store the history
65  };
66
67}
68
69#endif /* _SHELL_BUFFER_H */
Note: See TracBrowser for help on using the repository browser.