| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qabstractstate.h" | - |
| 43 | | - |
| 44 | #ifndef QT_NO_STATEMACHINE | - |
| 45 | | - |
| 46 | #include "qabstractstate_p.h" | - |
| 47 | #include "qstate.h" | - |
| 48 | #include "qstate_p.h" | - |
| 49 | #include "qstatemachine.h" | - |
| 50 | #include "qstatemachine_p.h" | - |
| 51 | | - |
| 52 | QT_BEGIN_NAMESPACE | - |
| 53 | | - |
| 54 | /*! | - |
| 55 | \class QAbstractState | - |
| 56 | \inmodule QtCore | - |
| 57 | | - |
| 58 | \brief The QAbstractState class is the base class of states of a QStateMachine. | - |
| 59 | | - |
| 60 | \since 4.6 | - |
| 61 | \ingroup statemachine | - |
| 62 | | - |
| 63 | The QAbstractState class is the abstract base class of states that are part | - |
| 64 | of a QStateMachine. It defines the interface that all state objects have in | - |
| 65 | common. QAbstractState is part of \l{The State Machine Framework}. | - |
| 66 | | - |
| 67 | The entered() signal is emitted when the state has been entered. The | - |
| 68 | exited() signal is emitted when the state has been exited. | - |
| 69 | | - |
| 70 | The parentState() function returns the state's parent state. The machine() | - |
| 71 | function returns the state machine that the state is part of. | - |
| 72 | | - |
| 73 | \section1 Subclassing | - |
| 74 | | - |
| 75 | The onEntry() function is called when the state is entered; reimplement this | - |
| 76 | function to perform custom processing when the state is entered. | - |
| 77 | | - |
| 78 | The onExit() function is called when the state is exited; reimplement this | - |
| 79 | function to perform custom processing when the state is exited. | - |
| 80 | */ | - |
| 81 | | - |
| 82 | QAbstractStatePrivate::QAbstractStatePrivate(StateType type) | - |
| 83 | : stateType(type), isMachine(false), parentState(0) | - |
| 84 | { | - |
| 85 | } executed: }Execution Count:540 | 540 |
| 86 | | - |
| 87 | QAbstractStatePrivate *QAbstractStatePrivate::get(QAbstractState *q) | - |
| 88 | { | - |
| 89 | return q->d_func(); executed: return q->d_func();Execution Count:17595 | 17595 |
| 90 | } | - |
| 91 | | - |
| 92 | const QAbstractStatePrivate *QAbstractStatePrivate::get(const QAbstractState *q) | - |
| 93 | { | - |
| 94 | return q->d_func(); executed: return q->d_func();Execution Count:13969 | 13969 |
| 95 | } | - |
| 96 | | - |
| 97 | QStateMachine *QAbstractStatePrivate::machine() const | - |
| 98 | { | - |
| 99 | QObject *par = parent; executed (the execution status of this line is deduced): QObject *par = parent; | - |
| 100 | while (par != 0) { evaluated: par != 0| yes Evaluation Count:402133 | yes Evaluation Count:83 |
| 83-402133 |
| 101 | if (QStateMachine *mach = qobject_cast<QStateMachine*>(par)) evaluated: QStateMachine *mach = qobject_cast<QStateMachine*>(par)| yes Evaluation Count:401831 | yes Evaluation Count:299 |
| 299-401831 |
| 102 | return mach; executed: return mach;Execution Count:401831 | 401831 |
| 103 | par = par->parent(); executed (the execution status of this line is deduced): par = par->parent(); | - |
| 104 | } executed: }Execution Count:299 | 299 |
| 105 | return 0; executed: return 0;Execution Count:83 | 83 |
| 106 | } | - |
| 107 | | - |
| 108 | void QAbstractStatePrivate::callOnEntry(QEvent *e) | - |
| 109 | { | - |
| 110 | Q_Q(QAbstractState); executed (the execution status of this line is deduced): QAbstractState * const q = q_func(); | - |
| 111 | q->onEntry(e); executed (the execution status of this line is deduced): q->onEntry(e); | - |
| 112 | } executed: }Execution Count:1442 | 1442 |
| 113 | | - |
| 114 | void QAbstractStatePrivate::callOnExit(QEvent *e) | - |
| 115 | { | - |
| 116 | Q_Q(QAbstractState); executed (the execution status of this line is deduced): QAbstractState * const q = q_func(); | - |
| 117 | q->onExit(e); executed (the execution status of this line is deduced): q->onExit(e); | - |
| 118 | } executed: }Execution Count:1271 | 1271 |
| 119 | | - |
| 120 | void QAbstractStatePrivate::emitEntered() | - |
| 121 | { | - |
| 122 | Q_Q(QAbstractState); executed (the execution status of this line is deduced): QAbstractState * const q = q_func(); | - |
| 123 | emit q->entered(QAbstractState::QPrivateSignal()); executed (the execution status of this line is deduced): q->entered(QAbstractState::QPrivateSignal()); | - |
| 124 | } executed: }Execution Count:1442 | 1442 |
| 125 | | - |
| 126 | void QAbstractStatePrivate::emitExited() | - |
| 127 | { | - |
| 128 | Q_Q(QAbstractState); executed (the execution status of this line is deduced): QAbstractState * const q = q_func(); | - |
| 129 | emit q->exited(QAbstractState::QPrivateSignal()); executed (the execution status of this line is deduced): q->exited(QAbstractState::QPrivateSignal()); | - |
| 130 | } executed: }Execution Count:1271 | 1271 |
| 131 | | - |
| 132 | /*! | - |
| 133 | Constructs a new state with the given \a parent state. | - |
| 134 | */ | - |
| 135 | QAbstractState::QAbstractState(QState *parent) | - |
| 136 | : QObject(*new QAbstractStatePrivate(QAbstractStatePrivate::AbstractState), parent) | - |
| 137 | { | - |
| 138 | } | 0 |
| 139 | | - |
| 140 | /*! | - |
| 141 | \internal | - |
| 142 | */ | - |
| 143 | QAbstractState::QAbstractState(QAbstractStatePrivate &dd, QState *parent) | - |
| 144 | : QObject(dd, parent) | - |
| 145 | { | - |
| 146 | } executed: }Execution Count:540 | 540 |
| 147 | | - |
| 148 | /*! | - |
| 149 | Destroys this state. | - |
| 150 | */ | - |
| 151 | QAbstractState::~QAbstractState() | - |
| 152 | { | - |
| 153 | } | - |
| 154 | | - |
| 155 | /*! | - |
| 156 | Returns this state's parent state, or 0 if the state has no parent state. | - |
| 157 | */ | - |
| 158 | QState *QAbstractState::parentState() const | - |
| 159 | { | - |
| 160 | Q_D(const QAbstractState); executed (the execution status of this line is deduced): const QAbstractStatePrivate * const d = d_func(); | - |
| 161 | if (d->parentState != parent()) evaluated: d->parentState != parent()| yes Evaluation Count:381 | yes Evaluation Count:29356 |
| 381-29356 |
| 162 | d->parentState = qobject_cast<QState*>(parent()); executed: d->parentState = qobject_cast<QState*>(parent());Execution Count:381 | 381 |
| 163 | return d->parentState; executed: return d->parentState;Execution Count:29737 | 29737 |
| 164 | } | - |
| 165 | | - |
| 166 | /*! | - |
| 167 | Returns the state machine that this state is part of, or 0 if the state is | - |
| 168 | not part of a state machine. | - |
| 169 | */ | - |
| 170 | QStateMachine *QAbstractState::machine() const | - |
| 171 | { | - |
| 172 | Q_D(const QAbstractState); executed (the execution status of this line is deduced): const QAbstractStatePrivate * const d = d_func(); | - |
| 173 | return d->machine(); executed: return d->machine();Execution Count:401448 | 401448 |
| 174 | } | - |
| 175 | | - |
| 176 | /*! | - |
| 177 | \fn QAbstractState::onExit(QEvent *event) | - |
| 178 | | - |
| 179 | This function is called when the state is exited. The given \a event is what | - |
| 180 | caused the state to be exited. Reimplement this function to perform custom | - |
| 181 | processing when the state is exited. | - |
| 182 | */ | - |
| 183 | | - |
| 184 | /*! | - |
| 185 | \fn QAbstractState::onEntry(QEvent *event) | - |
| 186 | | - |
| 187 | This function is called when the state is entered. The given \a event is | - |
| 188 | what caused the state to be entered. Reimplement this function to perform | - |
| 189 | custom processing when the state is entered. | - |
| 190 | */ | - |
| 191 | | - |
| 192 | /*! | - |
| 193 | \fn QAbstractState::entered() | - |
| 194 | | - |
| 195 | This signal is emitted when the state has been entered (after onEntry() has | - |
| 196 | been called). | - |
| 197 | */ | - |
| 198 | | - |
| 199 | /*! | - |
| 200 | \fn QAbstractState::exited() | - |
| 201 | | - |
| 202 | This signal is emitted when the state has been exited (after onExit() has | - |
| 203 | been called). | - |
| 204 | */ | - |
| 205 | | - |
| 206 | /*! | - |
| 207 | \reimp | - |
| 208 | */ | - |
| 209 | bool QAbstractState::event(QEvent *e) | - |
| 210 | { | - |
| 211 | return QObject::event(e); executed: return QObject::event(e);Execution Count:999 | 999 |
| 212 | } | - |
| 213 | | - |
| 214 | QT_END_NAMESPACE | - |
| 215 | | - |
| 216 | #endif //QT_NO_STATEMACHINE | - |
| 217 | | - |
| | |