summaryrefslogtreecommitdiffstats
path: root/src/plugins/tracing/qctfplugin.cpp
blob: 93e508e1990c79ced27d2aed6cf410510041b44e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#define BUILD_LIBRARY
#include <qstring.h>
#include "qctfplugin_p.h"
#include "qctflib_p.h"

QT_BEGIN_NAMESPACE

class QCtfTracePlugin : public QCtfLib
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QCtfLib" FILE "trace.json")
    Q_INTERFACES(QCtfLib)

public:
    QCtfTracePlugin()
    {

    }
    ~QCtfTracePlugin()
    {
        m_cleanup = true;
        *m_shutdown = true;
        QCtfLibImpl::cleanup();
    }
    void shutdown(bool *shutdown) override
    {
        m_shutdown = shutdown;
    }
    bool tracepointEnabled(const QCtfTracePointEvent &point) override
    {
        if (m_cleanup)
            return false;
        return QCtfLibImpl::instance()->tracepointEnabled(point);
    }
    void doTracepoint(const QCtfTracePointEvent &point, const QByteArray &arr) override
    {
        if (m_cleanup)
            return;
        QCtfLibImpl::instance()->doTracepoint(point, arr);
    }
    bool sessionEnabled() override
    {
        if (m_cleanup)
            return false;
        return QCtfLibImpl::instance()->sessionEnabled();
    }
    QCtfTracePointPrivate *initializeTracepoint(const QCtfTracePointEvent &point) override
    {
        if (m_cleanup)
            return nullptr;
        return QCtfLibImpl::instance()->initializeTracepoint(point);
    }
private:
    bool m_cleanup = false;
    bool *m_shutdown = nullptr;
};

QT_END_NAMESPACE

#include "qctfplugin.moc"