7 #ifndef QTOPENGL_LOG_STREAM_H
8 #define QTOPENGL_LOG_STREAM_H
11 class CQTOpenGLLogStream;
15 #include <argos3/core/simulator/simulator.h>
16 #include <argos3/core/simulator/space/space.h>
17 #include <argos3/core/utility/string_utilities.h>
26 QTextEdit* c_textedit) :
28 m_pcTextEdit(c_textedit),
29 m_cSpace(
CSimulator::GetInstance().GetSpace()) {
31 m_pcOldStream = m_cStream.rdbuf();
33 m_cStream.rdbuf(
this);
38 m_cStream.rdbuf(m_pcOldStream);
42 if (t_value ==
'\n') {
43 std::string strTmp(m_strBuffer);
47 m_pcTextEdit->append(strTmp.c_str());
48 m_strBuffer.erase(m_strBuffer.begin(), m_strBuffer.end());
51 m_strBuffer += t_value;
56 virtual std::streamsize
xsputn(
const char* pc_message,
57 std::streamsize un_size) {
59 m_strBuffer.append(pc_message, pc_message + un_size);
63 nPos = m_strBuffer.find(
'\n');
64 if (nPos != std::string::npos) {
67 std::string strTmp(m_strBuffer.begin(), m_strBuffer.begin() + nPos);
73 m_pcTextEdit->append(strTmp.c_str());
75 m_strBuffer.erase(m_strBuffer.begin(), m_strBuffer.begin() + nPos + 1);
77 }
while (nPos != std::string::npos);
84 std::ostream& m_cStream;
85 std::streambuf* m_pcOldStream;
86 std::string m_strBuffer;
87 QTextEdit* m_pcTextEdit;
The namespace containing all the ARGoS related code.
void Replace(std::string &str_buffer, const std::string &str_original, const std::string &str_new)
Searches into str_buffer for occurrences of str_original and substitutes them with str_new.
std::string ToString(const T &t_value)
Converts the given parameter to a std::string.
UInt32 GetSimulationClock() const
Returns the current value of the simulation clock.
virtual std::streamsize xsputn(const char *pc_message, std::streamsize un_size)
virtual int_type overflow(int_type t_value)
CQTOpenGLLogStream(std::ostream &c_stream, QTextEdit *c_textedit)
virtual ~CQTOpenGLLogStream()