File indexing completed on 2024-04-21 05:42:43

0001 /*
0002  *   Copyright 2014-2017 by Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU Library General Public License as
0006  *   published by the Free Software Foundation; either version 2, or
0007  *   (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU General Public License for more details
0013  *
0014  *   You should have received a copy of the GNU Library General Public
0015  *   License along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018  */
0019 
0020 #ifndef TIMETRACKER_H
0021 #define TIMETRACKER_H
0022 
0023 #include <QObject>
0024 #include <QVariantMap>
0025 #include <QDateTime>
0026 #include <QVector>
0027 #include <QScopedPointer>
0028 
0029 class ObjectHistory;
0030 /**
0031  * This debugging class is meant to provide an overview of how the objects change
0032  * over time and hopefully provide the information required to detect buggy initialization.
0033  *
0034  * To use it, you'll pass the object you want to track to the constructor and the TimeTracker
0035  * will use Qt introspection to read the properties and check what values they have and how they
0036  * change.
0037  *
0038  * To analyze the results one can read the generated json file /tmp/debug-$application-$USER, as soon
0039  * as the process has quit.
0040  */
0041 
0042 class ObjectTimeTracker : public QObject
0043 {
0044 Q_OBJECT
0045 public:
0046     explicit ObjectTimeTracker(QObject* object);
0047     ~ObjectTimeTracker() override;
0048     void init();
0049 
0050 private Q_SLOTS:
0051     void sync();
0052     void propertyChanged();
0053     void objectDestroyed();
0054 
0055 private:
0056     QObject* m_object;
0057     QScopedPointer<ObjectHistory> m_history;
0058 };
0059 
0060 #endif // TIMETRACKER_H