itom
Loading...
Searching...
No Matches
qDebugStream.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************** */
22
23//################
24//# qdebugstream.h #
25//################
26
27#ifndef Q_DEBUG_STREAM_H
28#define Q_DEBUG_STREAM_H
29
30#include "../../common/typeDefs.h"
31#include <iostream>
32#include <qobject.h>
33
34namespace ito {
35
38class QDebugStream : public QObject, public std::basic_streambuf<char>
39{
40 Q_OBJECT
41
42public:
43
44 QDebugStream(std::ostream &stream, ito::tStreamMessageType);
46
47signals:
50protected:
51
53 virtual std::basic_streambuf<char>::int_type overflow(int_type v);
54
55 virtual std::streamsize xsputn(const char *p, std::streamsize n);
56
57private:
58 std::ostream &m_stream;
59 std::streambuf *m_old_buf;
60 std::string m_string;
63#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
64 // QRandomGenerator produces a value random value between 0 and 2**32-1
65 uint32 m_randWaitThreshold;
66#else
67 // qRand() produces a value between 0 and RAND_MAX
68 int m_randWaitThreshold;
69#endif
70};
71
72}; // namespace ito
73
74#endif
Definition qDebugStream.h:39
virtual std::basic_streambuf< char >::int_type overflow(int_type v)
this method overwrites a corresponding method in basic_streambuf class and is invoked,...
Definition qDebugStream.cpp:126
ito::tStreamMessageType msg_type
Definition qDebugStream.h:61
virtual std::streamsize xsputn(const char *p, std::streamsize n)
method invoked if new content has been added to stream
Definition qDebugStream.cpp:93
std::ostream & m_stream
Definition qDebugStream.h:58
~QDebugStream()
destructor
Definition qDebugStream.cpp:75
std::streambuf * m_old_buf
Definition qDebugStream.h:59
std::string m_string
Definition qDebugStream.h:60
QDebugStream(std::ostream &stream, ito::tStreamMessageType)
constructor
Definition qDebugStream.cpp:44
void flushStream(QString, ito::tStreamMessageType)
Definition apiFunctionsGraph.cpp:40
tStreamMessageType
Definition typeDefs.h:77