QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgseventtracing.h
Go to the documentation of this file.
1/***************************************************************************
2 qgseventtracing.h
3 --------------------------------------
4 Date : October 2019
5 Copyright : (C) 2019 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSEVENTTRACING_H
17#define QGSEVENTTRACING_H
18
19#include "qgis_core.h"
20
21#define SIP_NO_FILE
22
23#include <QMutex>
24#include <QElapsedTimer>
25#include <QString>
26#include <QVector>
27
29
30//
31// W A R N I N G
32// -------------
33//
34// This file is not part of the QGIS API. It exists purely as an
35// implementation detail. This header file may change from version to
36// version without notice, or even be removed.
37//
38
39
82class CORE_EXPORT QgsEventTracing
83{
84 public:
86 enum EventType
87 {
88 Begin,
89 End,
90 Instant,
91 AsyncBegin,
92 AsyncEnd,
93 };
94
98 static bool startTracing();
99
103 static bool stopTracing();
104
108 static bool isTracingEnabled();
109
113 static bool writeTrace( const QString &fileName );
114
120 static void addEvent( EventType type, const QString &category, const QString &name, const QString &id = QString() );
121
126 class ScopedEvent
127 {
128 public:
129 ScopedEvent( const QString &category, const QString &name ): mCat( category ), mName( name ) { addEvent( Begin, mCat, mName ); }
130 ~ScopedEvent() { addEvent( End, mCat, mName ); }
131 private:
132 QString mCat, mName;
133 };
134
135};
136
138
139#endif // QGSEVENTTRACING_H