Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/hud/src/lib/util/debug_buffer.h @ 10647

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