Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: Shell no more singleton, and ShellInput is now derive from Text correctly

File size: 2.8 KB
Line 
1/*!
2 * @file shell_buffer.h
3 * @brief The Shell buffer Tasks
4*/
5
6#ifndef _SHELL_BUFFER_H
7#define _SHELL_BUFFER_H
8
9#include <stdarg.h>
10
11#define      SHELL_BUFFER_SIZE       16384         //!< The Size of the input-buffers (should be large enough to carry any kind of input)
12
13// FORWARD DECLARATION
14class Shell;
15template<class T> class tList;
16template<class T> class tIterator;
17#ifndef NULL
18#define NULL 0            //!< a pointer to NULL
19#endif
20
21//! A class for ...
22class ShellBuffer {
23
24 public:
25  virtual ~ShellBuffer();
26  /** @returns a Pointer to the only object of this Class */
27  inline static ShellBuffer* getInstance() { if (!ShellBuffer::singletonRef) ShellBuffer::singletonRef = new ShellBuffer();  return ShellBuffer::singletonRef; };
28  /** @returns true if this class is instanciated, false otherwise */
29  inline static bool isInstanciated() { return (ShellBuffer::singletonRef == NULL)?false:true; };
30
31  void registerShell(Shell* shell);
32  void unregisterShell(Shell* shell);
33
34  // BUFFER //
35  /** @param bufferSize the new Buffer-Size */
36  void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; };
37  void flushBuffers();
38  static bool addBufferLineStatic(const char* line, ...);
39  void addBufferLine(const char* line, va_list arg);
40  void moveBuffer(unsigned int lineCount);
41// void moveBufferTo(unsigned int lineNumber);
42  const char* getBufferLine(unsigned int lineNumber);
43  /** @returns the Buffer Iterator, that enables externals to walk through the Buffer */
44  inline tIterator<char>* getBufferIterator() const { return bufferIterator; };
45  /** @returns the Count of lines processed by the Shell. */
46  inline long getLineCount() const { return this->lineCount; };
47
48  void debug() const;
49
50  private:
51    ShellBuffer();
52
53
54  private:
55   static ShellBuffer*      singletonRef;                       //!< The singleton-reference to the only memeber of this class.
56   unsigned int             bufferSize;                         //!< The Size of the buffer
57   tList<char>*             buffer;                             //!< A list of stored char-arrays(strings) to store the history
58   tIterator<char>*         bufferIterator;                     //!< An iterator for the Shells main buffer.
59
60   Shell*                   shell;                              //!< the Registered Shell.
61   char                     bufferArray[SHELL_BUFFER_SIZE];     //!< a BUFFER for fast writing
62   char                     keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
63   bool                     keepBuffer;                         //!< if the keepbuffer contains unfinished lines.
64
65   unsigned long            lineCount;                          //!< how many Lines have been written out so far.
66};
67
68#endif /* _SHELL_BUFFER_H */
Note: See TracBrowser for help on using the repository browser.