QXRD  0.11.16
qcepdebug.cpp
Go to the documentation of this file.
1 #include "qcepdebug.h"
2 #include <stdio.h>
3 
4 QSharedPointer<QcepDebugDictionary> g_DebugLevel;
5 
7  m_DebugLevel(0)
8 {
9  setMessage(DEBUG_NOMESSAGES, "Disable All Debug Messages");
10  setMessage(DEBUG_APP, "Application startup and shutdown");
11  setMessage(DEBUG_PROPERTIES, "Properties");
12  setMessage(DEBUG_WINDOW, "Window Operations");
13  setMessage(DEBUG_PREFS, "Settings/Prefs Operations");
14  setMessage(DEBUG_DISPLAY, "Display Operations");
15  setMessage(DEBUG_CONSTRUCTORS, "Object Constructors/Destructors");
16  setMessage(DEBUG_ALLOCATOR, "Memory Allocation");
17  setMessage(DEBUG_THREADS, "Thread Initialization");
18  setMessage(DEBUG_QUEUES, "Queue Operations");
19  setMessage(DEBUG_IMAGE_CONSTRUCTORS, "Image Object Constructors/Destructors");
20  setMessage(DEBUG_LOCKING, "Debug Mutex Lock Operations");
21  setMessage(DEBUG_SERVER, "Server Commands");
22  setMessage(DEBUG_DATABROWSER, "Data Browser Operations");
23  setMessage(DEBUG_DRAGDROP, "Drag and Drop Operations");
24 }
25 
26 qint64 qcepDebug(int cond)
27 {
28  if (g_DebugLevel == NULL) {
29  printf("No Debug Dictionary Allocated\n");
30 
31  return 0;
32  } else {
33  qint64 mask = 1;
34 
35  mask <<= cond;
36 
37  return g_DebugLevel->debugLevel() & (mask);
38  }
39 }
40 
42 {
43  return m_DebugLevel;
44 }
45 
47 {
48  m_DebugLevel = level;
49 }
50 
51 QString QcepDebugDictionary::message(int val) const
52 {
53  return m_Messages.value(val);
54 }
55 
56 void QcepDebugDictionary::setMessage(int val, QString msg)
57 {
58  if (m_Messages.contains(val)) {
59  printf("Warning: duplicate messages for value %x\nExisting: %s\nNew:%s\n",
60  val, qPrintable(message(val)), qPrintable(msg));
61  }
62 
63  m_Messages.insert(val, msg);
64 }
65 
67 {
68 #if (QT_POINTER_SIZE==4)
69  return tr("0x%1").arg((quint32)p, 8, 16, QLatin1Char('0'));
70 #else
71  return tr("0x%1").arg((quint64)p, 16, 16, QLatin1Char('0'));
72 #endif
73 }
74 
void setMessage(int val, QString msg)
Definition: qcepdebug.cpp:56
QString message(int val) const
Definition: qcepdebug.cpp:51
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QMap< int, QString > m_Messages
Definition: qcepdebug.h:43
static QString hexArg(void *p)
Definition: qcepdebug.cpp:66
void setDebugLevel(qint64 level)
Definition: qcepdebug.cpp:46
QSharedPointer< QcepDebugDictionary > g_DebugLevel
Definition: qcepdebug.cpp:4
qint64 debugLevel() const
Definition: qcepdebug.cpp:41