QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RDebug.h
Go to the documentation of this file.
1
20#ifndef RDEBUG_H
21#define RDEBUG_H
22
23#include "core_global.h"
24
25#include <QString>
26#include <QMetaType>
27
28#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
29#include <CoreServices/CoreServices.h>
30#include <mach/mach.h>
31#include <mach/mach_time.h>
32#undef check
33#endif
34
35// These only work because the corresponding "member" variables are static
36class QElapsedTimer;
37class QMutex;
38template <class Key, class T> class QMap;
39
40#ifndef RDEFAULT_QSTRING
41#define RDEFAULT_QSTRING QString()
42#endif
43
67public:
68 static void printBacktrace(const QString& prefix = RDEFAULT_QSTRING);
69
73 static void startTimer(int id=0);
74
79 static uint stopTimer(int id, const QString& msg, uint msThreshold = 0);
80
85 static uint stopTimer(const QString& msg) {
86 return stopTimer(0, msg);
87 }
88
89 static void timeStamp();
90
91 static void hexDump(const QString& str);
92
93 static void incCounter(const QString& id = RDEFAULT_QSTRING);
94 static void decCounter(const QString& id = RDEFAULT_QSTRING);
95 static int getCounter(const QString& id = RDEFAULT_QSTRING);
96 static void printCounter(const QString& id = RDEFAULT_QSTRING);
97 static void printCounters(const QString& prefix = RDEFAULT_QSTRING);
98
99 static void setPrefix(const QString& p) {
100 prefix = p;
101 }
102 static QString getPrefix() {
103 return prefix;
104 }
105
106private:
107#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
108 static QMap<int, uint64_t> timerMac;
109#else
111#endif
113 static QString prefix;
114
115 static QMutex mutexCounter;
116};
117
119
120#endif
#define RDEFAULT_QSTRING
Definition RDebug.h:41
Q_DECLARE_METATYPE(RMath *)
Definition RDebug.h:38
This class provides some static methods for printing debugging information to stderr.
Definition RDebug.h:66
static QMap< QString, int > counter
Definition RDebug.h:112
static QMutex mutexCounter
Definition RDebug.h:115
static uint stopTimer(const QString &msg)
Stops the timer with ID 0 and prints the given message together with the time that has elapsed.
Definition RDebug.h:85
static QString prefix
Definition RDebug.h:113
static QString getPrefix()
Definition RDebug.h:102
static void setPrefix(const QString &p)
Definition RDebug.h:99
static QMap< int, QElapsedTimer > timer
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RDebug.h:110
#define QCADCORE_EXPORT
Definition core_global.h:10