Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryDebugUtil.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 
18 #ifndef BERRYDEBUGUTIL_H_
19 #define BERRYDEBUGUTIL_H_
20 
21 #include <QHash>
22 #include <QSet>
23 #include <QList>
24 
26 
27 class QDir;
28 
29 namespace berry {
30 
31 class Object;
32 class DebugBreakpointManager;
33 struct IDebugObjectListener;
34 template <class T> class SmartPointer;
35 
37 {
38 
39 public:
40 
41  static DebugBreakpointManager* GetBreakpointManager();
42 
43  static void TraceObject(const Object*);
44  static void TraceObject(unsigned int traceId);
45  static void TraceClass(const QString& className);
46 
47  static void StopTracing(unsigned int traceId);
48  static void StopTracing(const Object* obj);
49  static void StopTracing(const QString& className);
50 
51  static bool IsTraced(const Object* object);
52  static bool IsTraced(unsigned int traceId);
53  static bool IsTraced(const QString& className);
54 
55  static QSet<unsigned int> GetTracedObjects();
56 
57  static const Object* GetObject(unsigned int traceId);
58 
59  static QList<unsigned int> GetSmartPointerIDs(const Object* objectPointer, const QList<unsigned int>& excludeList = QList<unsigned int>());
60  static QList<const Object*> GetRegisteredObjects();
61 
62  static void PrintSmartPointerIDs(const Object* objectPointer, const QList<unsigned int>& excludeList = QList<unsigned int>());
63 
64  static void ResetObjectSummary();
65  static bool PrintObjectSummary(bool details = false);
66  static bool PrintObjectSummary(const QString& className, bool details = false);
67 
68  static void AddObjectListener(IDebugObjectListener* listener);
69  static void RemoveObjectListener(IDebugObjectListener* listener);
70 
71  static void SaveState(const QDir& path);
72  static void RestoreState(const QDir& path);
73 
74  // ******* for internal use only *************
75  static unsigned int& GetSmartPointerCounter();
76  static void RegisterSmartPointer(unsigned int smartPointerId, const Object* objectPointer, bool recordStack = false);
77  static void UnregisterSmartPointer(unsigned int smartPointerId, const Object* objectPointer);
78  static void RegisterObject(const Object* objectPointer);
79  static void UnregisterObject(const Object* objectPointer);
80  // *******************************************
81 
82 private:
83 
84  static const QString DEBUG_UTIL_XML;
85 
86  static const QString DEBUGUTIL_TAG;
87  static const QString TRACEOBJECT_TAG;
88  static const QString TRACECLASS_TAG;
89 
90  static const QString ID_ATTR;
91  static const QString NAME_ATTR;
92 
93  static bool GetPersistencePath(QDir& path);
94 
95  static QHash<quint32, QList<unsigned int> > m_TraceIdToSmartPointerMap;
96  typedef QHash<quint32, const Object* > TraceIdToObjectType;
97  static TraceIdToObjectType m_TraceIdToObjectMap;
98  static QSet<unsigned int> m_TracedObjects;
99  static QSet<QString> m_TracedClasses;
100 };
101 
102 }
103 
104 
105 #endif /* BERRYDEBUGUTIL_H_ */
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:78
#define org_blueberry_core_runtime_EXPORT