summaryrefslogtreecommitdiff
path: root/plugin/src/Caelestia/service.hpp
blob: 787818b3c1ad915dbf06aab60895287981d1504c (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.h>
#include <qobject.h>

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() const;

    void ref();
    void unref();

signals:
    void refCountChanged();

private:
    int m_refCount;
    mutable QMutex m_mutex;

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

} // namespace caelestia