itom  4.1.0
qDebugStream.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet 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 
34 namespace ito {
35 
38 class QDebugStream : public QObject, public std::basic_streambuf<char>
39 {
40  Q_OBJECT
41 
42 public:
43 
44  QDebugStream(std::ostream &stream, ito::tStreamMessageType);
45  ~QDebugStream();
46 
47 signals:
48  void flushStream(QString, ito::tStreamMessageType);
50 protected:
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 
57 private:
58  std::ostream &m_stream;
59  std::streambuf *m_old_buf;
60  std::string m_string;
62  int m_randWaitThreshold;
63 };
64 
65 }; // namespace ito
66 
67 #endif
virtual std::basic_streambuf< char >::int_type overflow(int_type v)
this method overwrites a corresponding method in basic_streambuf class and is invoked, if buffer risks to overflow
Definition: qDebugStream.cpp:95
virtual std::streamsize xsputn(const char *p, std::streamsize n)
method invoked if new content has been added to stream
Definition: qDebugStream.cpp:76
void flushStream(QString, ito::tStreamMessageType)
std::streambuf * m_old_buf
Definition: qDebugStream.h:59
ito::tStreamMessageType msg_type
Definition: qDebugStream.h:61
Definition: apiFunctionsGraph.cpp:39
std::string m_string
Definition: qDebugStream.h:60
QDebugStream(std::ostream &stream, ito::tStreamMessageType)
constructor
Definition: qDebugStream.cpp:40
~QDebugStream()
destructor
Definition: qDebugStream.cpp:63
tStreamMessageType
Definition: typeDefs.h:76
std::ostream & m_stream
Definition: qDebugStream.h:58
Definition: qDebugStream.h:38