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

0001 /* -*- C++ -*-
0002     This file implements the state handling 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     $Id: State.cpp 20 2005-08-08 21:02:51Z mirko $
0009 */
0010 
0011 #include "state.h"
0012 
0013 namespace ThreadWeaver
0014 {
0015 const char *const StateNames[NoOfStates] = {"InConstruction", "WorkingHard", "Suspending", "Suspended", "ShuttingDown", "Destructed"};
0016 
0017 class Q_DECL_HIDDEN State::Private
0018 {
0019 public:
0020     Private(QueueInterface *theWeaver)
0021         : weaver(theWeaver)
0022     {
0023         Q_ASSERT_X(sizeof StateNames / sizeof StateNames[0] == NoOfStates, "State::Private ctor", "Make sure to keep StateId and StateNames in sync!");
0024     }
0025 
0026     /** The Weaver we relate to. */
0027     QueueInterface *const weaver;
0028 };
0029 
0030 State::State(QueueSignals *weaver)
0031     : d(new Private(weaver))
0032 {
0033 }
0034 
0035 State::~State()
0036 {
0037     delete d;
0038 }
0039 
0040 QString State::stateName() const
0041 {
0042     return QLatin1String(StateNames[stateId()]);
0043 }
0044 
0045 void State::activated()
0046 {
0047 }
0048 
0049 QueueInterface *State::weaver()
0050 {
0051     return d->weaver;
0052 }
0053 
0054 const QueueInterface *State::weaver() const
0055 {
0056     return d->weaver;
0057 }
0058 
0059 }