| 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 | |
| 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 | |
| 30 | State::State(QueueSignals *weaver) |
| 31 | : d(new Private(weaver)) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | State::~State() |
| 36 | { |
| 37 | delete d; |
| 38 | } |
| 39 | |
| 40 | QString State::stateName() const |
| 41 | { |
| 42 | return QLatin1String(StateNames[stateId()]); |
| 43 | } |
| 44 | |
| 45 | void State::activated() |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | QueueInterface *State::weaver() |
| 50 | { |
| 51 | return d->weaver; |
| 52 | } |
| 53 | |
| 54 | const QueueInterface *State::weaver() const |
| 55 | { |
| 56 | return d->weaver; |
| 57 | } |
| 58 | |
| 59 | } |
| 60 | |