KASync

debug.h
1/*
2 SPDX-FileCopyrightText: 2015 Daniel Vrátil <dvratil@redhat.com>
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
21namespace KAsync
22{
23
24Q_DECLARE_LOGGING_CATEGORY(Debug)
25Q_DECLARE_LOGGING_CATEGORY(Trace)
26
27KASYNC_EXPORT QString demangleName(const char *name);
28
29namespace Private
30{
31struct Execution;
32}
33
34class KASYNC_EXPORT Tracer
35{
36public:
37 explicit Tracer(Private::Execution *execution);
38 ~Tracer();
39
40private:
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(StandardAction id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:10:09 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.