source: trunk/src/3rdparty/phonon/mmf/objectdump.h

Last change on this file was 561, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.1 sources.

  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1/* This file is part of the KDE project.
2
3Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
5This library is free software: you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation, either version 2.1 or 3 of the License.
8
9This library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU Lesser General Public License for more details.
13
14You should have received a copy of the GNU Lesser General Public License
15along with this library. If not, see <http://www.gnu.org/licenses/>.
16
17*/
18
19#ifndef OBJECTDUMP_H
20#define OBJECTDUMP_H
21
22#include <QObject>
23#include <QList>
24#include <QByteArray>
25#include <QScopedPointer>
26
27QT_BEGIN_NAMESPACE
28
29namespace ObjectDump
30{
31
32/**
33 * Abstract base for annotator classes invoked by QVisitor.
34 */
35class QAnnotator : public QObject
36{
37 Q_OBJECT
38public:
39 virtual ~QAnnotator();
40 virtual QList<QByteArray> annotation(const QObject& object) = 0;
41};
42
43/**
44 * Annotator which replicates QObject::dumpObjectTree functionality.
45 */
46class QAnnotatorBasic : public QAnnotator
47{
48 Q_OBJECT
49public:
50 QList<QByteArray> annotation(const QObject& object);
51};
52
53/**
54 * Annotator which returns widget information.
55 */
56class QAnnotatorWidget : public QAnnotator
57{
58 Q_OBJECT
59public:
60 QList<QByteArray> annotation(const QObject& object);
61};
62
63
64class QDumperPrivate;
65
66/**
67 * Class used to dump information about individual QObjects.
68 */
69class QDumper : public QObject
70{
71 Q_OBJECT
72 Q_DECLARE_PRIVATE(QDumper)
73
74public:
75 QDumper();
76 ~QDumper();
77
78 /**
79 * Specify a prefix, to be printed on each line of output.
80 */
81 void setPrefix(const QString& prefix);
82
83 /**
84 * Takes ownership of annotator.
85 */
86 void addAnnotator(QAnnotator* annotator);
87
88 /**
89 * Invoke each annotator on the object and write to debug output.
90 */
91 void dumpObject(const QObject& object);
92
93private:
94 QScopedPointer<QDumperPrivate> d_ptr;
95
96};
97
98
99class QVisitorPrivate;
100
101/**
102 * Visitor class which dumps information about nodes in the object tree.
103 */
104class QVisitor : public QObject
105{
106 Q_OBJECT
107 Q_DECLARE_PRIVATE(QVisitor)
108
109public:
110 QVisitor();
111 ~QVisitor();
112
113 /**
114 * Specify a prefix, to be printed on each line of output.
115 */
116 void setPrefix(const QString& prefix);
117
118 /**
119 * Set number of spaces by which each level of the tree is indented.
120 */
121 void setIndent(unsigned indent);
122
123 /**
124 * Called by the visitor algorithm before starting the visit.
125 */
126 void visitPrepare();
127
128 /**
129 * Called by the visitor algorithm as each node is visited.
130 */
131 void visitNode(const QObject& object);
132
133 /**
134 * Called by the visitor algorithm when the visit is complete.
135 */
136 void visitComplete();
137
138 /**
139 * Takes ownership of annotator.
140 */
141 void addAnnotator(QAnnotator* annotator);
142
143private:
144 QScopedPointer<QVisitorPrivate> d_ptr;
145
146};
147
148
149//-----------------------------------------------------------------------------
150// Utility functions
151//-----------------------------------------------------------------------------
152
153void addDefaultAnnotators(QDumper& dumper);
154void addDefaultAnnotators(QVisitor& visitor);
155
156void dumpTreeFromRoot(const QObject& root, QVisitor& visitor);
157void dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor);
158void dumpAncestors(const QObject& leaf, QVisitor& visitor);
159
160} // namespace ObjectDump
161
162QT_END_NAMESPACE
163
164#endif
Note: See TracBrowser for help on using the repository browser.