DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
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
5
QDebugStream::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
}
22
bool
23
QDebugStream::event
(QEvent*
event
)
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
38
std::streambuf::int_type
39
QDebugStream::overflow
(int_type v)
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
}
daq::QTUtils::QDebugStream::m_string
std::string m_string
Definition
qdebugstream.hpp:61
daq::QTUtils::QDebugStream::event
virtual bool event(QEvent *event)
Definition
qdebugstream.cpp:23
daq::QTUtils::QDebugStream::log_window
QTextEdit * log_window
Definition
qdebugstream.hpp:62
daq::QTUtils::QDebugStream::m_text
QString m_text
Definition
qdebugstream.hpp:64
daq::QTUtils::QDebugStream::m_mutex
QMutex * m_mutex
Definition
qdebugstream.hpp:63
daq::QTUtils::QDebugStream::xsputn
virtual std::streamsize xsputn(const char *p, std::streamsize n)
Definition
qdebugstream.cpp:5
daq::QTUtils::QDebugStream::overflow
virtual int_type overflow(int_type v)
Definition
qdebugstream.cpp:39
qdebugstream.hpp
Generated on
for DUNE-DAQ by
1.18.0