#include <src/util/OutputBuffer.h>
Public Member Functions | |
template<class T> | |
void | add (T object) |
Does the same like operator<<: Assigns the object to the stream and calls the listeners. | |
template<class T> | |
void | addLine (T object) |
Assigns an object/value and adds std::endl. | |
void | flush () |
Flushes the stored text (~empties the OutputBuffer). | |
bool | getLine (std::string *output) |
Removes the first line from the stream and assigns it to a given string object. | |
std::stringstream & | getStream () |
Returns the internal stringstream object. | |
void | newline () |
Puts std::endl to the stream and calls the listeners. | |
OutputBuffer & | operator<< (std::ios_base &(*manipulator)(std::ios_base &)) |
Puts a stream manipulator to the stream. | |
OutputBuffer & | operator<< (std::ios &(*manipulator)(std::ios &)) |
Puts a stream manipulator to the stream. | |
OutputBuffer & | operator<< (std::ostream &(*manipulator)(std::ostream &)) |
Puts a stream manipulator to the stream. | |
template<const OutputBuffer & > | |
OutputBuffer & | operator<< (const OutputBuffer &object) |
Reads the stored text of the other OutputBuffer and calls the listeners. | |
template<class T> | |
OutputBuffer & | operator<< (T object) |
Puts some object/value to the OutputBuffer. The text gets assigned and the OutputBuffer calls it's listeners. | |
OutputBuffer () | |
void | registerListener (OutputBufferListener *listener) |
Adds a new listener to the list. | |
void | unregisterListener (OutputBufferListener *listener) |
Removes a listener from the list. | |
~OutputBuffer () | |
Private Member Functions | |
void | callListeners () |
Calls the outputChanged() function of all registered listeners. | |
Private Attributes | |
std::vector < OutputBufferListener * > | listeners_ |
A list of all listeners. | |
std::stringstream | stream_ |
The stringstream that stores the assigned text. |
If text gets assigned by using the << operator or another function, the OutputBuffer calls it's listeners, allowing them to retrieve the text line by line.
It's important to know that getLine actually removes the line from the OutputBuffer, so it's better to only have one "active" listener.
orxonox::OutputBuffer::OutputBuffer | ( | ) | [inline] |
orxonox::OutputBuffer::~OutputBuffer | ( | ) | [inline] |
void orxonox::OutputBuffer::add | ( | T | object | ) | [inline] |
Does the same like operator<<: Assigns the object to the stream and calls the listeners.
object | The object/value |
void orxonox::OutputBuffer::addLine | ( | T | object | ) | [inline] |
Assigns an object/value and adds std::endl.
object | The object/value |
void orxonox::OutputBuffer::callListeners | ( | ) | [private] |
Calls the outputChanged() function of all registered listeners.
References listeners_.
Referenced by operator<<().
void orxonox::OutputBuffer::flush | ( | ) | [inline] |
Flushes the stored text (~empties the OutputBuffer).
bool orxonox::OutputBuffer::getLine | ( | std::string * | output | ) |
Removes the first line from the stream and assigns it to a given string object.
output | The string object to assign the first line |
References stream_.
Referenced by orxonox::Shell::outputChanged().
std::stringstream& orxonox::OutputBuffer::getStream | ( | ) | [inline] |
void orxonox::OutputBuffer::newline | ( | ) | [inline] |
Puts std::endl to the stream and calls the listeners.
OutputBuffer & orxonox::OutputBuffer::operator<< | ( | std::ios_base &(*)(std::ios_base &) | manipulator | ) |
Puts a stream manipulator to the stream.
manipulator | The manipulator |
References callListeners(), and stream_.
OutputBuffer & orxonox::OutputBuffer::operator<< | ( | std::ios &(*)(std::ios &) | manipulator | ) |
Puts a stream manipulator to the stream.
manipulator | The manipulator |
References callListeners(), and stream_.
OutputBuffer & orxonox::OutputBuffer::operator<< | ( | std::ostream &(*)(std::ostream &) | manipulator | ) |
Puts a stream manipulator to the stream.
manipulator | The manipulator |
References callListeners(), and stream_.
OutputBuffer& orxonox::OutputBuffer::operator<< | ( | const OutputBuffer & | object | ) | [inline] |
Reads the stored text of the other OutputBuffer and calls the listeners.
object | The other OutputBuffer |
OutputBuffer& orxonox::OutputBuffer::operator<< | ( | T | object | ) | [inline] |
Puts some object/value to the OutputBuffer. The text gets assigned and the OutputBuffer calls it's listeners.
object | The object/value to assign |
void orxonox::OutputBuffer::registerListener | ( | OutputBufferListener * | listener | ) |
Adds a new listener to the list.
listener | The new listener |
References listeners_.
Referenced by orxonox::Shell::Shell().
void orxonox::OutputBuffer::unregisterListener | ( | OutputBufferListener * | listener | ) |
std::vector<OutputBufferListener*> orxonox::OutputBuffer::listeners_ [private] |
A list of all listeners.
Referenced by callListeners(), registerListener(), and unregisterListener().
std::stringstream orxonox::OutputBuffer::stream_ [private] |