ThreadWeaver

state.cpp
1 /* -*- C++ -*-
2  This file implements the state handling in ThreadWeaver.
3 
4  SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <[email protected]>
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 
13 namespace ThreadWeaver
14 {
15 const char *const StateNames[NoOfStates] = {"InConstruction", "WorkingHard", "Suspending", "Suspended", "ShuttingDown", "Destructed"};
16 
17 class Q_DECL_HIDDEN State::Private
18 {
19 public:
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 
54 const QueueInterface *State::weaver() const
55 {
56  return d->weaver;
57 }
58 
59 }
QString stateName() const
The ID of the current state.
Definition: state.cpp:40
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
QueueSignals declares the Qt signals shared by the Queue and Weaver classes.
Definition: queuesignals.h:23
WeaverInterface provides a common interface for weaver implementations.
virtual StateId stateId() const =0
The state Id.
virtual QueueInterface * weaver()
The Weaver interface this state handles.
Definition: state.cpp:49
~State() override
Destructor.
Definition: state.cpp:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Sep 26 2023 04:01:04 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.