summaryrefslogtreecommitdiff
path: root/plugin/src/Caelestia/service.hpp
blob: 40e9110f2d3fe22aefd48f59778acdecd000c8ba (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
#pragma once

#include <QMutex>
#include <QObject>

namespace caelestia {

class Service : public QObject {
    Q_OBJECT

    Q_PROPERTY(int refCount READ refCount NOTIFY refCountChanged)

public:
    explicit Service(QObject* parent = nullptr);

    [[nodiscard]] int refCount();

    void ref();
    void unref();

signals:
    void refCountChanged();

private:
    int m_refCount;
    QMutex m_mutex;

    virtual void start() = 0;
    virtual void stop() = 0;
};

} // namespace caelestia