/*! * @file shell_buffer.h * @brief The Shell buffer Tasks */ #ifndef _SHELL_BUFFER_H #define _SHELL_BUFFER_H #include #define SHELL_BUFFER_SIZE 16384 //!< The Size of the input-buffers (should be large enough to carry any kind of input) // FORWARD DECLARATION template class tList; template class tIterator; #ifndef NULL #define NULL 0 //!< a pointer to NULL #endif //! A class for ... class ShellBuffer { public: virtual ~ShellBuffer(); /** @returns a Pointer to the only object of this Class */ inline static ShellBuffer* getInstance() { if (!ShellBuffer::singletonRef) ShellBuffer::singletonRef = new ShellBuffer(); return ShellBuffer::singletonRef; }; /** @returns true if this class is instanciated, false otherwise */ inline static bool isInstanciated() { return (ShellBuffer::singletonRef == NULL)?true:false; }; // BUFFER // /** @param bufferSize the new Buffer-Size */ void setBufferSize(unsigned int bufferSize) { this->bufferSize = bufferSize; }; void flushBuffers(); static bool addBufferLineStatic(const char* line, ...); void addBufferLine(const char* line, va_list arg); void moveBuffer(unsigned int lineCount); // void moveBufferTo(unsigned int lineNumber); const char* getBufferLine(unsigned int lineNumber); inline tIterator* getBufferIterator() const { return bufferIterator; }; private: ShellBuffer(); private: static ShellBuffer* singletonRef; //!< The singleton-reference to the only memeber of this class. unsigned int bufferSize; //!< The Size of the buffer tList* buffer; //!< A list of stored char-arrays(strings) to store the history tIterator* bufferIterator; //!< An iterator for the Shells main buffer. char bufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER for fast writing char keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell. bool keepBuffer; //!< if the keepbuffer contains unfinished lines. unsigned long lineCount; //!< how many Lines have been written out so far. }; #endif /* _SHELL_BUFFER_H */