Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7740 was 7737, checked in by bensch, 19 years ago

Using MultiLine-Text in the Shell. This is much faster, and Nicer :)

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