ThreadWeaver 5.109.0
state.h
1/* -*- C++ -*-
2 This file implements the state handling 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 $Id: State.h 32 2005-08-17 08:38:01Z mirko $
9*/
10
11#ifndef THREADWEAVER_STATE_H
12#define THREADWEAVER_STATE_H
13
14#include <QString>
15
16#include "queueinterface.h"
17#include "queuesignals.h"
18#include "threadweaver_export.h"
19#include "weaverinterface.h"
20
21namespace ThreadWeaver
22{
23class Job;
24class Thread;
25
31enum StateId {
34 InConstruction = 0,
36 WorkingHard,
39 Suspending,
42 Suspended,
46 ShuttingDown,
49 Destructed,
51 NoOfStates,
52};
53
55class THREADWEAVER_EXPORT State : public QueueInterface, public WeaverInterface
56{
57public:
59 explicit State(QueueSignals *weaver);
60
62 ~State() override;
63
67 QString stateName() const;
68
70 virtual StateId stateId() const = 0;
71
74 virtual void activated();
75
76protected:
79 virtual const QueueInterface *weaver() const;
80
81private:
82 class Private;
83 Private *const d;
84};
85
86}
87
88#endif // THREADWEAVER_STATE_H
WeaverInterface provides a common interface for weaver implementations.
Definition queueinterface.h:45
QueueSignals declares the Qt signals shared by the Queue and Weaver classes.
Definition queuesignals.h:24
We use a State pattern to handle the system state in ThreadWeaver.
Definition state.h:56
QString stateName() const
The ID of the current state.
virtual QueueInterface * weaver()
The Weaver interface this state handles.
State(QueueSignals *weaver)
Default constructor.
~State() override
Destructor.
virtual void activated()
The state has been changed so that this object is responsible for state handling.
virtual StateId stateId() const =0
The state Id.