forked from Kitware/VTK
/
vtkQtDebugLeaksModel.h
100 lines (73 loc) · 2.75 KB
/
vtkQtDebugLeaksModel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*=========================================================================
Program: Visualization Toolkit
Module: vtkQtDebugLeaksModel.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkQtDebugLeaksModel
* @brief model class that observes the vtkDebugLeaks singleton
*
*
* This class is used internally by the vtkQtDebugLeaksView. It installs an
* observer on the vtkDebugLeaks singleton and uses the observer to maintain
* a model of all vtkObjectBase dervied objects that are alive in memory.
*/
#ifndef vtkQtDebugLeaksModel_h
#define vtkQtDebugLeaksModel_h
#include "vtkGUISupportQtModule.h" // For export macro
#include <QStandardItemModel>
#include "vtkConfigure.h" //for VTK_OVERRIDE
class vtkObjectBase;
class VTKGUISUPPORTQT_EXPORT vtkQtDebugLeaksModel : public QStandardItemModel
{
Q_OBJECT
public:
vtkQtDebugLeaksModel(QObject* p=0);
~vtkQtDebugLeaksModel() VTK_OVERRIDE;
/**
* Get the list of objects in the model that have the given class name
*/
QList<vtkObjectBase*> getObjects(const QString& className);
/**
* Return an item model that contains only objects with the given class name.
* The model has two columns: object address (string), object reference count (integer)
* The caller is allowed to reparent or delete the returned model.
*/
QStandardItemModel* referenceCountModel(const QString& className);
protected slots:
void addObject(vtkObjectBase* object);
void removeObject(vtkObjectBase* object);
void registerObject(vtkObjectBase* object);
void processPendingObjects();
void onAboutToQuit();
// Inherited method from QAbstractItemModel
Qt::ItemFlags flags(const QModelIndex &index) const VTK_OVERRIDE;
private:
class qInternal;
qInternal* Internal;
class qObserver;
qObserver* Observer;
Q_DISABLE_COPY(vtkQtDebugLeaksModel);
};
// TODO - move to private
//-----------------------------------------------------------------------------
class ReferenceCountModel : public QStandardItemModel
{
Q_OBJECT
public:
ReferenceCountModel(QObject* p=0);
~ReferenceCountModel() VTK_OVERRIDE;
void addObject(vtkObjectBase* obj);
void removeObject(vtkObjectBase* obj);
QString pointerAsString(void* ptr);
// Inherited method from QAbstractItemModel
Qt::ItemFlags flags(const QModelIndex &index) const VTK_OVERRIDE;
protected slots:
void updateReferenceCounts();
};
#endif