Changeset 1791 for code/trunk/src/util/OutputBuffer.h
- Timestamp:
- Sep 16, 2008, 3:46:25 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/util/OutputBuffer.h
r1747 r1791 27 27 */ 28 28 29 /** 30 @file OutputBuffer.h 31 @brief Declaration of the OutputBuffer class. 32 33 The OutputBuffer acts almost like std::ostream. You can put text and other values to the 34 OutputBuffer by using the << operator. The OutputBuffer stores the text and calls registerd 35 listeners if new text gets assigned. 36 The listeners are then able to retrieve the text line by line. 37 38 It's important to know that getLine actually removes the line from the OutputBuffer, so it's 39 better to only have one "active" listener. 40 */ 41 29 42 #ifndef _OutputBuffer_H__ 30 43 #define _OutputBuffer_H__ … … 38 51 namespace orxonox 39 52 { 53 /** 54 @brief A pure virtual baseclass for classes that want to register as listener to an OutputBuffer. 55 56 This class is pure virtual, so an inheriting class has to implement the function on it's own. 57 The function get's called, if an instance of the inheriting class registers as a listener at 58 an OutputBuffer and this buffer changes. 59 */ 40 60 class _UtilExport OutputBufferListener 41 61 { … … 49 69 }; 50 70 71 /** 72 @brief The OutputBuffer acts almost like std::ostream and stores the assigned text. 73 74 If text gets assigned by using the << operator or another function, the OutputBuffer 75 calls it's listeners, allowing them to retrieve the text line by line. 76 77 It's important to know that getLine actually removes the line from the OutputBuffer, so it's 78 better to only have one "active" listener. 79 */ 51 80 class _UtilExport OutputBuffer 52 81 { … … 55 84 ~OutputBuffer() {} 56 85 86 /** 87 @brief Puts some object/value to the OutputBuffer. The text gets assigned and the OutputBuffer calls it's listeners. 88 @param object The object/value to assign 89 */ 57 90 template <class T> 58 91 inline OutputBuffer& operator<<(T object) … … 63 96 } 64 97 98 /** 99 @brief Reads the stored text of the other OutputBuffer and calls the listeners. 100 @param object The other OutputBuffer 101 */ 65 102 template <const OutputBuffer&> 66 103 inline OutputBuffer& operator<<(const OutputBuffer& object) … … 75 112 OutputBuffer& operator<<(std::ios_base& (*manipulator)(std::ios_base&)); 76 113 114 /** 115 @brief Does the same like operator<<: Assigns the object to the stream and calls the listeners. 116 @param object The object/value 117 */ 77 118 template <class T> 78 119 inline void add(T object) … … 82 123 } 83 124 125 /** 126 @brief Assigns an object/value and adds std::endl. 127 @param object The object/value 128 */ 84 129 template <class T> 85 130 inline void addLine(T object) … … 89 134 } 90 135 136 /** 137 @brief Puts std::endl to the stream and calls the listeners. 138 */ 91 139 inline void newline() 92 140 { … … 95 143 } 96 144 145 /** 146 @brief Flushes the stored text (~empties the OutputBuffer). 147 */ 97 148 inline void flush() 98 149 { … … 105 156 void unregisterListener(OutputBufferListener* listener); 106 157 158 /** 159 @brief Returns the internal stringstream object. 160 */ 107 161 inline std::stringstream& getStream() 108 { return this->stream_; } 162 { 163 return this->stream_; 164 } 109 165 110 166 private: 111 167 void callListeners(); 112 168 113 std::stringstream stream_; 114 std::list<OutputBufferListener*> listeners_; 169 std::stringstream stream_; //! The stringstream that stores the assigned text 170 std::list<OutputBufferListener*> listeners_; //! A list of all listeners 115 171 }; 116 172 }
Note: See TracChangeset
for help on using the changeset viewer.