ThreadWeaver

state.cpp
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.cpp 20 2005-08-08 21:02:51Z mirko $
9*/
10
11#include "state.h"
12
13namespace ThreadWeaver
14{
15const char *const StateNames[NoOfStates] = {"InConstruction", "WorkingHard", "Suspending", "Suspended", "ShuttingDown", "Destructed"};
16
17class Q_DECL_HIDDEN State::Private
18{
19public:
20 Private(QueueInterface *theWeaver)
21 : weaver(theWeaver)
22 {
23 Q_ASSERT_X(sizeof StateNames / sizeof StateNames[0] == NoOfStates, "State::Private ctor", "Make sure to keep StateId and StateNames in sync!");
24 }
25
26 /** The Weaver we relate to. */
27 QueueInterface *const weaver;
28};
29
31 : d(new Private(weaver))
32{
33}
34
36{
37 delete d;
38}
39
41{
42 return QLatin1String(StateNames[stateId()]);
43}
44
46{
47}
48
50{
51 return d->weaver;
52}
53
54const QueueInterface *State::weaver() const
55{
56 return d->weaver;
57}
58
59}
Lambda is a template that takes any type on which operator() is available, and executes it in run().
Definition lambda.h:20
WeaverInterface provides a common interface for weaver implementations.
QueueSignals declares the Qt signals shared by the Queue and Weaver classes.
virtual QueueInterface * weaver()
The Weaver interface this state handles.
Definition state.cpp:49
virtual void activated()
The state has been changed so that this object is responsible for state handling.
Definition state.cpp:45
State(QueueSignals *weaver)
Default constructor.
Definition state.cpp:30
~State() override
Destructor.
Definition state.cpp:35
QString stateName() const
The ID of the current state.
Definition state.cpp:40
virtual StateId stateId() const =0
The state Id.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.