Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: shell without tList now

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