1 | /* -*- C++ -*- |
2 | A decorator to make jobs into QObjects in ThreadWeaver. |
3 | |
4 | SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | */ |
8 | |
9 | #ifndef THREADWEAVER_QOBJECTDECORATOR_H |
10 | #define THREADWEAVER_QOBJECTDECORATOR_H |
11 | |
12 | #include <QObject> |
13 | |
14 | #include "iddecorator.h" |
15 | #include "threadweaver_export.h" |
16 | |
17 | namespace ThreadWeaver |
18 | { |
19 | class Collection; |
20 | class Sequence; |
21 | |
22 | /*! |
23 | * \class ThreadWeaver::QObjectDecorator |
24 | * \inheaderfile ThreadWeaver/QObjectDecorator |
25 | * \inmodule ThreadWeaver |
26 | */ |
27 | class THREADWEAVER_EXPORT QObjectDecorator : public QObject, public IdDecorator |
28 | { |
29 | Q_OBJECT |
30 | public: |
31 | /*! |
32 | */ |
33 | explicit QObjectDecorator(JobInterface *decoratee, QObject *parent = nullptr); |
34 | /*! |
35 | */ |
36 | explicit QObjectDecorator(JobInterface *decoratee, bool autoDelete, QObject *parent = nullptr); |
37 | |
38 | Q_SIGNALS: |
39 | /*! This signal is emitted when this job is being processed by a thread. */ |
40 | void started(ThreadWeaver::JobPointer); |
41 | /*! This signal is emitted when the job has been finished (no matter if it succeeded or not). */ |
42 | void done(ThreadWeaver::JobPointer); |
43 | /*! This job has failed. |
44 | * |
45 | * This signal is emitted when success() returns false after the job is executed. */ |
46 | void failed(ThreadWeaver::JobPointer); |
47 | |
48 | protected: |
49 | void defaultBegin(const JobPointer &job, Thread *thread) override; |
50 | void defaultEnd(const JobPointer &job, Thread *thread) override; |
51 | }; |
52 | |
53 | /*! |
54 | * \typedef ThreadWeaver::QJobPointer |
55 | */ |
56 | typedef QSharedPointer<QObjectDecorator> QJobPointer; |
57 | |
58 | } |
59 | |
60 | #endif // THREADWEAVER_QOBJECTDECORATOR_H |
61 | |