QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
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 
80 class CORE_EXPORT QgsEventTracing
81 {
82  public:
84  enum EventType
85  {
86  Begin,
87  End,
88  Instant,
89  AsyncBegin,
90  AsyncEnd,
91  };
92 
96  static bool startTracing();
97 
101  static bool stopTracing();
102 
106  static bool isTracingEnabled();
107 
111  static bool writeTrace( const QString &fileName );
112 
118  static void addEvent( EventType type, const QString &category, const QString &name, const QString &id = QString() );
119 
124  class ScopedEvent
125  {
126  public:
127  ScopedEvent( const QString &category, const QString &name ): mCat( category ), mName( name ) { addEvent( Begin, mCat, mName ); }
128  ~ScopedEvent() { addEvent( End, mCat, mName ); }
129  private:
130  QString mCat, mName;
131  };
132 
133 };
134 
136 
137 #endif // QGSEVENTTRACING_H