KASync

debug.h
1 /*
2  SPDX-FileCopyrightText: 2015 Daniel Vrátil <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef KASYNC_DEBUG_H
8 #define KASYNC_DEBUG_H
9 
10 //krazy:excludeall=dpointer
11 
12 #include "kasync_export.h"
13 
14 #include <QLoggingCategory>
15 #include <QStringBuilder>
16 
17 #ifndef QT_NO_DEBUG
18 #include <typeinfo>
19 #endif
20 
21 namespace KAsync
22 {
23 
24 Q_DECLARE_LOGGING_CATEGORY(Debug)
25 Q_DECLARE_LOGGING_CATEGORY(Trace)
26 
27 KASYNC_EXPORT QString demangleName(const char *name);
28 
29 namespace Private
30 {
31 struct Execution;
32 }
33 
34 class KASYNC_EXPORT Tracer
35 {
36 public:
37  explicit Tracer(Private::Execution *execution);
38  ~Tracer();
39 
40 private:
41  enum MsgType {
42  Start,
43  End
44  };
45  void msg(MsgType);
46 
47  int mId;
48  Private::Execution *mExecution;
49 
50  static int lastId;
51 };
52 
53 }
54 
55 #ifndef QT_NO_DEBUG
56  template<typename T>
57  QString storeExecutorNameExpanded() {
58  return KAsync::demangleName(typeid(T).name());
59  }
60 
61  template<typename T, typename ... Tail>
62  auto storeExecutorNameExpanded() -> std::enable_if_t<sizeof ... (Tail) != 0, QString>
63  {
64  return storeExecutorNameExpanded<T>() % QStringLiteral(", ") % storeExecutorNameExpanded<Tail ...>();
65  }
66 
67  #define STORE_EXECUTOR_NAME(name, ...) \
68  ExecutorBase::mExecutorName = QStringLiteral(name "<") % storeExecutorNameExpanded<__VA_ARGS__>() % QStringLiteral(">")
69 #else
70  #define STORE_EXECUTOR_NAME(...)
71 #endif
72 
73 #endif // KASYNC_DEBUG_H
QString name(const QVariant &location)
Definition: async.h:59
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 11 2021 23:07:13 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.