Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/util/debug_buffer.h @ 10146

Last change on this file since 10146 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 2.6 KB
RevLine 
[4838]1/*!
[9861]2 * @file debug_buffer.h
3 * @brief The Debug buffer Tasks
[5246]4 * @see debug.h
[3245]5*/
[1853]6
[9861]7#ifndef _DEBUG_BUFFER_H
8#define _DEBUG_BUFFER_H
[1853]9
[7761]10#include <string>
[5781]11#include <list>
[5173]12
[9861]13#define      DEBUG_BUFFER_SIZE       16384         //!< The Size of the input-buffers (should be large enough to carry any kind of input)
[5173]14
[7374]15  //! A class handling output from orxonox via debug.h
[7744]16  /**
[9861]17   * the DebugBuffer redirects output from PRINTF(x) to the Debug and STDOUT
18   * the DebugBuffer is a front-filling queue of limited length, that has the
[7744]19   * youngest added Entry at the beginning, and the oldest at the end.
20   */
[9861]21  class DebugBuffer
[7374]22  {
23  public:
[9861]24    virtual ~DebugBuffer();
[7374]25    /** @returns a Pointer to the only object of this Class */
[9861]26    inline static DebugBuffer* getInstance() { if (!DebugBuffer::singletonRef) DebugBuffer::singletonRef = new DebugBuffer();  return DebugBuffer::singletonRef; };
[7374]27    /** @returns true if this class is instanciated, false otherwise */
[9861]28    inline static bool isInstanciated() { return (DebugBuffer::singletonRef == NULL)?false:true; };
[1853]29
[8145]30    static void addBufferLineStatic(const char* line, ...);
31    void addBufferLine(const char* line);
[7744]32
[7762]33    /// BUFFER
[7374]34    /** @param bufferSize the new Buffer-Size */
[7762]35    void setMaxBufferSize(unsigned int maxBufferSize) { this->maxBufferSize = maxBufferSize; };
[7374]36    void flush();
[7744]37
[7374]38    /** @returns the List of stings from the Buffer */
39    const std::list<std::string>& getBuffer() const { return this->buffer; };
[9861]40    /** @returns the Count of lines processed by the Debug. */
[7744]41    inline unsigned long getLineCount() const { return this->lineCount; };
[7762]42    /** @returns the Current Buffer Size. */
43    inline unsigned int getBufferSize() const { return this->buffer.size(); };
[5206]44
[7374]45    void debug() const;
[5173]46
[5174]47  private:
[9861]48    DebugBuffer();
[5173]49
[5174]50  private:
[9861]51    static DebugBuffer*           singletonRef;                       //!< The singleton-reference to the only memeber of this class.
52    unsigned int                  maxBufferSize;                      //!< The Size of the buffer
[5174]53
[9861]54    std::string                   keepBuffer;                         //!< a BUFFER to have multi-non-newLine commands be copied into the debug.
[5173]55
[7737]56    unsigned long                 lineCount;                          //!< how many Lines have been written out so far.
[7314]57
[7744]58    // The Beginning of buffer (buffer.front()) is the last added line.
[9861]59    static char                   bufferArray[DEBUG_BUFFER_SIZE];     //!< a BUFFER for fast writing
[7737]60    static std::list<std::string> buffer;                             //!< A list of stored char-arrays(strings) to store the history
[7374]61  };
[1853]62
[9861]63#endif /* _DEBUG_BUFFER_H */
Note: See TracBrowser for help on using the repository browser.