QGIS API Documentation 4.1.0-Master (ca2ac17535b)
Loading...
Searching...
No Matches
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#include <QElapsedTimer>
22#include <QMutex>
23#include <QString>
24#include <QVector>
25
26#define SIP_NO_FILE
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
81class CORE_EXPORT QgsEventTracing
82{
83 public:
85 enum EventType
86 {
87 Begin,
88 End,
89 Instant,
90 AsyncBegin,
91 AsyncEnd,
92 };
93
97 static bool startTracing();
98
102 static bool stopTracing();
103
107 static bool isTracingEnabled();
108
112 static bool writeTrace( const QString &fileName );
113
120 static void addEvent( EventType type, const QString &category, const QString &name, const QString &id = QString() );
121
128 static void addEventToQgisTrace( EventType type, const QString &category, const QString &name, const QString &id = QString() );
129
134 static void setFloatVariable( const char *name, double value, bool continuous = false );
135
140 static void setIntVariable( const char *name, int64_t value, bool continuous = false );
141};
142
147class CORE_EXPORT QgsScopedEvent
148{
149 public:
150 QgsScopedEvent( const QString &category, const QString &name )
151 : mCat( category )
152 , mName( name )
153 , mId( QString::number( sNextId++ ) )
154 {
155 QgsEventTracing::addEvent( QgsEventTracing::Begin, mCat, mName, mId );
156 }
157 ~QgsScopedEvent() { QgsEventTracing::addEvent( QgsEventTracing::End, mCat, mName, mId ); }
158
159 private:
160 QString mCat, mName, mId;
161 static size_t sNextId;
162};
163
164
166
167#endif // QGSEVENTTRACING_H