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