KASync

debug.h
1 /*
2  * Copyright 2015 Daniel Vrátil <[email protected]>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef KASYNC_DEBUG_H
19 #define KASYNC_DEBUG_H
20 
21 //krazy:excludeall=dpointer
22 
23 #include "kasync_export.h"
24 
25 #include <QLoggingCategory>
26 #include <QStringBuilder>
27 
28 #ifndef QT_NO_DEBUG
29 #include <typeinfo>
30 #endif
31 
32 namespace KAsync
33 {
34 
35 Q_DECLARE_LOGGING_CATEGORY(Debug)
36 Q_DECLARE_LOGGING_CATEGORY(Trace)
37 
38 KASYNC_EXPORT QString demangleName(const char *name);
39 
40 namespace Private
41 {
42 struct Execution;
43 }
44 
45 class KASYNC_EXPORT Tracer
46 {
47 public:
48  explicit Tracer(Private::Execution *execution);
49  ~Tracer();
50 
51 private:
52  enum MsgType {
53  Start,
54  End
55  };
56  void msg(MsgType);
57 
58  int mId;
59  Private::Execution *mExecution;
60 
61  static int lastId;
62 };
63 
64 }
65 
66 #ifndef QT_NO_DEBUG
67  template<typename T>
68  QString storeExecutorNameExpanded() {
69  return KAsync::demangleName(typeid(T).name());
70  }
71 
72  template<typename T, typename ... Tail>
73  auto storeExecutorNameExpanded() -> std::enable_if_t<sizeof ... (Tail) != 0, QString>
74  {
75  return storeExecutorNameExpanded<T>() % QStringLiteral(", ") % storeExecutorNameExpanded<Tail ...>();
76  }
77 
78  #define STORE_EXECUTOR_NAME(name, ...) \
79  ExecutorBase::mExecutorName = QStringLiteral(name "<") % storeExecutorNameExpanded<__VA_ARGS__>() % QStringLiteral(">")
80 #else
81  #define STORE_EXECUTOR_NAME(...)
82 #endif
83 
84 #endif // KASYNC_DEBUG_H
QString name(const QVariant &location)
Definition: async.h:68
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 22:57:35 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.