KDStateMachineEditor  1.1.0
A framework for creating Qt State Machine metacode using a graphical user interface
debuginterface_types.h
1 /*
2  This file is part of the KDAB State Machine Editor Library.
3 
4  Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com.
5  All rights reserved.
6  Author: Kevin Funk <kevin.funk@kdab.com>
7 
8  Licensees holding valid commercial KDAB State Machine Editor Library
9  licenses may use this file in accordance with the KDAB State Machine Editor
10  Library License Agreement provided with the Software.
11 
12  This file may be distributed and/or modified under the terms of the
13  GNU Lesser General Public License version 2.1 as published by the
14  Free Software Foundation and appearing in the file LICENSE.LGPL.txt included.
15 
16  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
17  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 
19  Contact info@kdab.com if any conditions of this licensing are not
20  clear to you.
21 */
22 
23 #ifndef KDSME_DEBUGINTERFACE_TYPES_H
24 #define KDSME_DEBUGINTERFACE_TYPES_H
25 
26 #include <QDataStream>
27 #include <QList>
28 #include <QMetaType>
29 
30 QT_BEGIN_NAMESPACE
31 class QAbstractTransition;
32 class QAbstractState;
33 QT_END_NAMESPACE
34 
35 namespace KDSME {
36 namespace DebugInterface {
37 
38 // note: typedef bring major pain, on the client side i.e. it would always look for
39 // signal/slots with the base type (or actually, the first type which was registered
40 // to the meta type system)...
42 {
43  TransitionId(const TransitionId &id)
44  : id(id.id)
45  {}
46  explicit TransitionId(QAbstractTransition *transition = nullptr)
47  : id(reinterpret_cast<quint64>(transition))
48  {}
49  operator quint64() const
50  {
51  return id;
52  }
53  quint64 id;
54 };
55 
56 inline QDataStream &operator<<(QDataStream &out, TransitionId value)
57 {
58  out << value.id;
59  return out;
60 }
61 
62 inline QDataStream &operator>>(QDataStream &in, TransitionId &value)
63 {
64  in >> value.id;
65  return in;
66 }
67 
68 struct StateId
69 {
70  StateId(const StateId &id)
71  : id(id.id)
72  {}
73  explicit StateId(QAbstractState *state= nullptr)
74  : id(reinterpret_cast<quint64>(state))
75  {}
76  operator quint64() const
77  {
78  return id;
79  }
80  quint64 id;
81 };
82 
83 inline QDataStream &operator<<(QDataStream &out, StateId value)
84 {
85  out << value.id;
86  return out;
87 }
88 
89 inline QDataStream &operator>>(QDataStream &in, StateId &value)
90 {
91  in >> value.id;
92  return in;
93 }
94 
95 enum StateType {
96  OtherState,
97  FinalState,
98  ShallowHistoryState,
99  DeepHistoryState,
100  StateMachineState
101 };
102 
103 inline QDataStream &operator<<(QDataStream &out, StateType value)
104 {
105  out << int(value);
106  return out;
107 }
108 
109 inline QDataStream &operator>>(QDataStream &in, StateType &value)
110 {
111  int val;
112  in >> val;
113  value = static_cast<StateType>(val);
114  return in;
115 }
116 
117 typedef QList<StateId> StateMachineConfiguration;
118 
119 inline void registerTypes() //krazy:exclude=inline
120 {
121  qRegisterMetaTypeStreamOperators<StateId>();
122  qRegisterMetaTypeStreamOperators<StateMachineConfiguration>();
123  qRegisterMetaTypeStreamOperators<TransitionId>();
124  qRegisterMetaTypeStreamOperators<StateType>();
125 }
126 
127 }
128 }
129 
130 Q_DECLARE_METATYPE(KDSME::DebugInterface::StateId)
131 Q_DECLARE_METATYPE(KDSME::DebugInterface::TransitionId)
132 Q_DECLARE_METATYPE(KDSME::DebugInterface::StateMachineConfiguration)
133 Q_DECLARE_METATYPE(KDSME::DebugInterface::StateType)
134 
135 #endif
Definition: debuginterface_types.h:41
Definition: debuginterface_types.h:68
Definition: abstractexporter.h:33

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
https://github.com/KDAB/KDStateMachineEditor