DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
qdebugstream.cpp
Go to the documentation of this file.
2#include "streambuf"
3// using namespace daq::QTUtils;
4std::streamsize
5QDebugStream::xsputn(const char* p, std::streamsize n)
6{
7 QMutexLocker locker(m_mutex);
8 m_string.append(p, p + n);
9
10 uint pos = 0;
11 while (pos != std::string::npos) {
12 pos = m_string.find('\n');
13 if (pos != std::string::npos) {
14 std::string tmp(m_string.begin(), m_string.begin() + pos);
15 m_text.append(tmp.c_str()).append("\n");
16 m_string.erase(m_string.begin(), m_string.begin() + pos + 1);
17 }
18 }
19 QCoreApplication::postEvent(this, new QEvent(QEvent::User));
20 return n;
21}
22bool
24{
25 if (event->type() == QEvent::User) {
26 {
27 QMutexLocker locker(m_mutex);
28 if (!m_text.isEmpty())
29 log_window->append(m_text);
30 m_text.clear();
31 }
32 event->accept();
33 return true;
34 }
35 return false;
36}
37
38std::streambuf::int_type
40{
41 QMutexLocker locker(m_mutex);
42 if (v == '\n') {
43 m_text.append(m_string.c_str()).append("\n");
44 m_string.erase(m_string.begin(), m_string.end());
45 } else {
46 m_string += v;
47 }
48 QCoreApplication::postEvent(this, new QEvent(QEvent::User));
49 return v;
50}
virtual bool event(QEvent *event)
virtual std::streamsize xsputn(const char *p, std::streamsize n)
virtual int_type overflow(int_type v)