d/control: Recommend gdb
[gammaray-debian.git] / toolfactory.h
blob84fa55c7b651bcdf6ee694baeb718526a81c9b92
1 /*
2 toolfactory.h
4 This file is part of GammaRay, the Qt application inspection and
5 manipulation tool.
7 Copyright (C) 2010-2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
8 Author: Volker Krause <volker.krause@kdab.com>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef GAMMARAY_TOOLFACTORY_H
25 #define GAMMARAY_TOOLFACTORY_H
27 #include <QtPlugin>
28 #include <QtCore/QStringList>
29 #include <QMetaType>
31 namespace GammaRay {
33 class ProbeInterface;
35 /**
36 * Abstract interface for probe tools.
38 class ToolFactory
40 public:
41 virtual inline ~ToolFactory() {}
43 /**
44 * Unique id of this tool
46 virtual QString id() const = 0;
48 /**
49 * Human readable name of this tool.
51 virtual QString name() const = 0;
53 /**
54 * Class names of types this tool can handle.
55 * The tool will only be activated if an object of one of these types
56 * is seen in the probed application.
58 virtual QStringList supportedTypes() const = 0;
60 /**
61 * Initialize the tool.
62 * Implement this method to do non-GUI initialization, such as creating
63 * object tracking models etc.
64 * @param probe The probe interface allowing access to the object models.
66 virtual void init(ProbeInterface *probe) = 0;
68 /**
69 * Create the UI part of this tool.
70 * @param probe The probe interface allowing access to the object models.
71 * @param parentWidget The parent widget for the visual elements of this tool.
73 virtual QWidget *createWidget(ProbeInterface *probe, QWidget *parentWidget) = 0;
76 template <typename Type, typename Tool>
77 class StandardToolFactory : public ToolFactory
79 public:
80 virtual inline QStringList supportedTypes() const {
81 return QStringList(Type::staticMetaObject.className());
83 virtual inline QString id() const {
84 return Tool::staticMetaObject.className();
86 virtual inline void init(ProbeInterface *) {}
87 virtual inline QWidget *createWidget(ProbeInterface *probe, QWidget *parentWidget) {
88 return new Tool(probe, parentWidget);
94 Q_DECLARE_INTERFACE(GammaRay::ToolFactory, "com.kdab.GammaRay.ToolFactory/1.0")
95 Q_DECLARE_METATYPE(GammaRay::ToolFactory *)
97 #endif