File indexing completed on 2024-04-28 04:01:23

0001 /* -*- C++ -*-
0002     A decorator to make jobs into QObjects in ThreadWeaver.
0003 
0004     SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef THREADWEAVER_QOBJECTDECORATOR_H
0010 #define THREADWEAVER_QOBJECTDECORATOR_H
0011 
0012 #include <QObject>
0013 
0014 #include "iddecorator.h"
0015 #include "threadweaver_export.h"
0016 
0017 namespace ThreadWeaver
0018 {
0019 class Collection;
0020 class Sequence;
0021 
0022 class THREADWEAVER_EXPORT QObjectDecorator : public QObject, public IdDecorator
0023 {
0024     Q_OBJECT
0025 public:
0026     explicit QObjectDecorator(JobInterface *decoratee, QObject *parent = nullptr);
0027     explicit QObjectDecorator(JobInterface *decoratee, bool autoDelete, QObject *parent = nullptr);
0028 
0029 Q_SIGNALS:
0030     /** This signal is emitted when this job is being processed by a thread. */
0031     void started(ThreadWeaver::JobPointer);
0032     /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */
0033     void done(ThreadWeaver::JobPointer);
0034     /** This job has failed.
0035      *
0036      * This signal is emitted when success() returns false after the job is executed. */
0037     void failed(ThreadWeaver::JobPointer);
0038 
0039 protected:
0040     void defaultBegin(const JobPointer &job, Thread *thread) override;
0041     void defaultEnd(const JobPointer &job, Thread *thread) override;
0042 };
0043 
0044 typedef QSharedPointer<QObjectDecorator> QJobPointer;
0045 
0046 }
0047 
0048 #endif // THREADWEAVER_QOBJECTDECORATOR_H