author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 03 May 2010 13:17:34 +0300 | |
changeset 19 | fcece45ef507 |
parent 18 | 2f34d5167611 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtCore module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QSTATEMACHINE_P_H |
|
43 |
#define QSTATEMACHINE_P_H |
|
44 |
||
45 |
// |
|
46 |
// W A R N I N G |
|
47 |
// ------------- |
|
48 |
// |
|
49 |
// This file is not part of the Qt API. It exists purely as an |
|
50 |
// implementation detail. This header file may change from version to |
|
51 |
// version without notice, or even be removed. |
|
52 |
// |
|
53 |
// We mean it. |
|
54 |
// |
|
55 |
||
56 |
#include "private/qstate_p.h" |
|
57 |
||
58 |
#include <QtCore/qcoreevent.h> |
|
59 |
#include <QtCore/qhash.h> |
|
60 |
#include <QtCore/qlist.h> |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
61 |
#include <QtCore/qmutex.h> |
0 | 62 |
#include <QtCore/qpair.h> |
63 |
#include <QtCore/qset.h> |
|
64 |
#include <QtCore/qvector.h> |
|
65 |
||
66 |
QT_BEGIN_NAMESPACE |
|
67 |
||
68 |
class QEvent; |
|
69 |
#ifndef QT_NO_STATEMACHINE_EVENTFILTER |
|
70 |
class QEventTransition; |
|
71 |
#endif |
|
72 |
class QSignalEventGenerator; |
|
73 |
class QSignalTransition; |
|
74 |
class QAbstractState; |
|
75 |
class QAbstractTransition; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
76 |
class QFinalState; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
77 |
class QHistoryState; |
0 | 78 |
class QState; |
79 |
||
80 |
#ifndef QT_NO_ANIMATION |
|
81 |
class QAbstractAnimation; |
|
82 |
#endif |
|
83 |
||
84 |
class QStateMachine; |
|
85 |
class Q_CORE_EXPORT QStateMachinePrivate : public QStatePrivate |
|
86 |
{ |
|
87 |
Q_DECLARE_PUBLIC(QStateMachine) |
|
88 |
public: |
|
89 |
enum State { |
|
90 |
NotRunning, |
|
91 |
Starting, |
|
92 |
Running |
|
93 |
}; |
|
94 |
enum EventProcessingMode { |
|
95 |
DirectProcessing, |
|
96 |
QueuedProcessing |
|
97 |
}; |
|
98 |
enum StopProcessingReason { |
|
99 |
EventQueueEmpty, |
|
100 |
Finished, |
|
101 |
Stopped |
|
102 |
}; |
|
103 |
||
104 |
QStateMachinePrivate(); |
|
105 |
~QStateMachinePrivate(); |
|
106 |
||
107 |
static QStateMachinePrivate *get(QStateMachine *q); |
|
108 |
||
109 |
QState *findLCA(const QList<QAbstractState*> &states) const; |
|
110 |
||
111 |
static bool stateEntryLessThan(QAbstractState *s1, QAbstractState *s2); |
|
112 |
static bool stateExitLessThan(QAbstractState *s1, QAbstractState *s2); |
|
113 |
||
114 |
QAbstractState *findErrorState(QAbstractState *context); |
|
115 |
void setError(QStateMachine::Error error, QAbstractState *currentContext); |
|
116 |
||
117 |
// private slots |
|
118 |
void _q_start(); |
|
119 |
void _q_process(); |
|
120 |
#ifndef QT_NO_ANIMATION |
|
121 |
void _q_animationFinished(); |
|
122 |
#endif |
|
123 |
||
124 |
QState *rootState() const; |
|
125 |
||
126 |
QState *startState(); |
|
127 |
void removeStartState(); |
|
128 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
129 |
void clearHistory(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
130 |
|
0 | 131 |
void microstep(QEvent *event, const QList<QAbstractTransition*> &transitionList); |
132 |
bool isPreempted(const QAbstractState *s, const QSet<QAbstractTransition*> &transitions) const; |
|
133 |
QSet<QAbstractTransition*> selectTransitions(QEvent *event) const; |
|
134 |
QList<QAbstractState*> exitStates(QEvent *event, const QList<QAbstractTransition*> &transitionList); |
|
135 |
void executeTransitionContent(QEvent *event, const QList<QAbstractTransition*> &transitionList); |
|
136 |
QList<QAbstractState*> enterStates(QEvent *event, const QList<QAbstractTransition*> &enabledTransitions); |
|
137 |
void addStatesToEnter(QAbstractState *s, QState *root, |
|
138 |
QSet<QAbstractState*> &statesToEnter, |
|
139 |
QSet<QAbstractState*> &statesForDefaultEntry); |
|
140 |
||
141 |
void applyProperties(const QList<QAbstractTransition*> &transitionList, |
|
142 |
const QList<QAbstractState*> &exitedStates, |
|
143 |
const QList<QAbstractState*> &enteredStates); |
|
144 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
static QState *toStandardState(QAbstractState *state); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
static const QState *toStandardState(const QAbstractState *state); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
static QFinalState *toFinalState(QAbstractState *state); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
static QHistoryState *toHistoryState(QAbstractState *state); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
|
0 | 150 |
bool isInFinalState(QAbstractState *s) const; |
151 |
static bool isFinal(const QAbstractState *s); |
|
152 |
static bool isParallel(const QAbstractState *s); |
|
153 |
bool isCompound(const QAbstractState *s) const; |
|
154 |
bool isAtomic(const QAbstractState *s) const; |
|
155 |
static bool isDescendantOf(const QAbstractState *s, const QAbstractState *other); |
|
156 |
static QList<QState*> properAncestors(const QAbstractState *s, const QState *upperBound); |
|
157 |
||
158 |
void goToState(QAbstractState *targetState); |
|
159 |
||
160 |
void registerTransitions(QAbstractState *state); |
|
161 |
void registerSignalTransition(QSignalTransition *transition); |
|
162 |
void unregisterSignalTransition(QSignalTransition *transition); |
|
163 |
#ifndef QT_NO_STATEMACHINE_EVENTFILTER |
|
164 |
void registerEventTransition(QEventTransition *transition); |
|
165 |
void unregisterEventTransition(QEventTransition *transition); |
|
166 |
void handleFilteredEvent(QObject *watched, QEvent *event); |
|
167 |
#endif |
|
168 |
void unregisterTransition(QAbstractTransition *transition); |
|
169 |
void unregisterAllTransitions(); |
|
170 |
void handleTransitionSignal(QObject *sender, int signalIndex, |
|
171 |
void **args); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
172 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
173 |
void postInternalEvent(QEvent *e); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
174 |
void postExternalEvent(QEvent *e); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
175 |
QEvent *dequeueInternalEvent(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
176 |
QEvent *dequeueExternalEvent(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
177 |
bool isInternalEventQueueEmpty(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
178 |
bool isExternalEventQueueEmpty(); |
0 | 179 |
void processEvents(EventProcessingMode processingMode); |
180 |
void cancelAllDelayedEvents(); |
|
181 |
||
182 |
#ifndef QT_NO_PROPERTIES |
|
183 |
typedef QPair<QObject *, QByteArray> RestorableId; |
|
184 |
QHash<RestorableId, QVariant> registeredRestorables; |
|
185 |
void registerRestorable(QObject *object, const QByteArray &propertyName); |
|
186 |
void unregisterRestorable(QObject *object, const QByteArray &propertyName); |
|
187 |
bool hasRestorable(QObject *object, const QByteArray &propertyName) const; |
|
188 |
QVariant restorableValue(QObject *object, const QByteArray &propertyName) const; |
|
189 |
QList<QPropertyAssignment> restorablesToPropertyList(const QHash<RestorableId, QVariant> &restorables) const; |
|
190 |
#endif |
|
191 |
||
192 |
State state; |
|
193 |
QState *_startState; |
|
194 |
bool processing; |
|
195 |
bool processingScheduled; |
|
196 |
bool stop; |
|
197 |
StopProcessingReason stopProcessingReason; |
|
198 |
QSet<QAbstractState*> configuration; |
|
199 |
QList<QEvent*> internalEventQueue; |
|
200 |
QList<QEvent*> externalEventQueue; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
201 |
QMutex internalEventMutex; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
202 |
QMutex externalEventMutex; |
0 | 203 |
|
204 |
QStateMachine::Error error; |
|
205 |
QStateMachine::RestorePolicy globalRestorePolicy; |
|
206 |
||
207 |
QString errorString; |
|
208 |
QSet<QAbstractState *> pendingErrorStates; |
|
209 |
QSet<QAbstractState *> pendingErrorStatesForDefaultEntry; |
|
210 |
||
211 |
#ifndef QT_NO_ANIMATION |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
212 |
bool animated; |
0 | 213 |
|
214 |
QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> > |
|
215 |
initializeAnimation(QAbstractAnimation *abstractAnimation, |
|
216 |
const QPropertyAssignment &prop); |
|
217 |
||
218 |
QHash<QAbstractState*, QList<QAbstractAnimation*> > animationsForState; |
|
219 |
QHash<QAbstractAnimation*, QPropertyAssignment> propertyForAnimation; |
|
220 |
QHash<QAbstractAnimation*, QAbstractState*> stateForAnimation; |
|
221 |
QSet<QAbstractAnimation*> resetAnimationEndValues; |
|
222 |
||
223 |
QList<QAbstractAnimation *> defaultAnimations; |
|
224 |
QMultiHash<QAbstractState *, QAbstractAnimation *> defaultAnimationsForSource; |
|
225 |
QMultiHash<QAbstractState *, QAbstractAnimation *> defaultAnimationsForTarget; |
|
226 |
||
227 |
#endif // QT_NO_ANIMATION |
|
228 |
||
229 |
QSignalEventGenerator *signalEventGenerator; |
|
230 |
||
231 |
QHash<const QObject*, QVector<int> > connections; |
|
232 |
#ifndef QT_NO_STATEMACHINE_EVENTFILTER |
|
233 |
QHash<QObject*, QHash<QEvent::Type, int> > qobjectEvents; |
|
234 |
#endif |
|
235 |
QHash<int, QEvent*> delayedEvents; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
QMutex delayedEventsMutex; |
0 | 237 |
|
238 |
typedef QEvent* (*f_cloneEvent)(QEvent*); |
|
239 |
struct Handler { |
|
240 |
f_cloneEvent cloneEvent; |
|
241 |
}; |
|
242 |
||
243 |
static const Handler *handler; |
|
244 |
}; |
|
245 |
||
246 |
Q_CORE_EXPORT const QStateMachinePrivate::Handler *qcoreStateMachineHandler(); |
|
247 |
||
248 |
QT_END_NAMESPACE |
|
249 |
||
250 |
#endif |