KDStateMachineEditor  1.0.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-2015 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 class QAbstractTransition;
31 class QAbstractState;
32 
33 namespace KDSME {
34 namespace DebugInterface {
35 
36 // note: typedef bring major pain, on the client side i.e. it would always look for
37 // signal/slots with the base type (or actually, the first type which was registered
38 // to the meta type system)...
40 {
41  TransitionId(const TransitionId &id)
42  : id(id.id)
43  {}
44  explicit TransitionId(QAbstractTransition *transition = nullptr)
45  : id(reinterpret_cast<quint64>(transition))
46  {}
47  operator quint64() const
48  {
49  return id;
50  }
51  quint64 id;
52 };
53 
54 inline QDataStream &operator<<(QDataStream &out, TransitionId value)
55 {
56  out << value.id;
57  return out;
58 }
59 
60 inline QDataStream &operator>>(QDataStream &in, TransitionId &value)
61 {
62  in >> value.id;
63  return in;
64 }
65 
66 struct StateId
67 {
68  StateId(const StateId &id)
69  : id(id.id)
70  {}
71  explicit StateId(QAbstractState *state= nullptr)
72  : id(reinterpret_cast<quint64>(state))
73  {}
74  operator quint64() const
75  {
76  return id;
77  }
78  quint64 id;
79 };
80 
81 inline QDataStream &operator<<(QDataStream &out, StateId value)
82 {
83  out << value.id;
84  return out;
85 }
86 
87 inline QDataStream &operator>>(QDataStream &in, StateId &value)
88 {
89  in >> value.id;
90  return in;
91 }
92 
93 enum StateType {
94  OtherState,
95  FinalState,
96  ShallowHistoryState,
97  DeepHistoryState,
98  StateMachineState
99 };
100 
101 inline QDataStream &operator<<(QDataStream &out, StateType value)
102 {
103  out << int(value);
104  return out;
105 }
106 
107 inline QDataStream &operator>>(QDataStream &in, StateType &value)
108 {
109  int val;
110  in >> val;
111  value = static_cast<StateType>(val);
112  return in;
113 }
114 
115 typedef QList<StateId> StateMachineConfiguration;
116 
117 inline void registerTypes() //krazy:exclude=inline
118 {
119  qRegisterMetaTypeStreamOperators<StateId>();
120  qRegisterMetaTypeStreamOperators<StateMachineConfiguration>();
121  qRegisterMetaTypeStreamOperators<TransitionId>();
122  qRegisterMetaTypeStreamOperators<StateType>();
123 }
124 
125 }
126 }
127 
128 Q_DECLARE_METATYPE(KDSME::DebugInterface::StateId)
129 Q_DECLARE_METATYPE(KDSME::DebugInterface::TransitionId)
130 Q_DECLARE_METATYPE(KDSME::DebugInterface::StateMachineConfiguration)
131 Q_DECLARE_METATYPE(KDSME::DebugInterface::StateType)
132 
133 #endif
Definition: debuginterface_types.h:39
Definition: debuginterface_types.h:66
Definition: abstractexporter.h:33

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