/
Stomp_sm.h
222 lines (177 loc) · 5.26 KB
/
Stomp_sm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#ifndef _H_STOMP_SM
#define _H_STOMP_SM
/*
* ex: set ro:
* DO NOT EDIT.
* generated by smc (http://smc.sourceforge.net/)
* from file : Stomp_sm.sm
*/
#define SMC_USES_IOSTREAMS
#include <statemap.h>
namespace STOMP
{
// Forward declarations.
class StompFSM_map;
class StompFSM_map_Disconnected;
class StompFSM_map_SocketConnected;
class StompFSM_map_Ready;
class StompFSM_map_SendingAck;
class StompFSM_map_Disconnecting;
class StompFSM_map_Default;
class PocoStompState;
class StompContext;
class PocoStomp;
class PocoStompState :
public statemap::State
{
public:
PocoStompState(const char *name, int stateId)
: statemap::State(name, stateId)
{};
virtual void Entry(StompContext&) {};
virtual void Exit(StompContext&) {};
virtual void ack_received(StompContext& context, PFrame _frame);
virtual void receive_frame(StompContext& context, PFrame _frame);
virtual void send_frame(StompContext& context, PFrame _frame);
virtual void socket_connected(StompContext& context);
virtual void socket_disconnected(StompContext& context);
virtual void timeout(StompContext& context);
virtual void timeout(StompContext& context, PocoStompState* waitingfor);
protected:
virtual void Default(StompContext& context);
};
class StompFSM_map
{
public:
static StompFSM_map_Disconnected Disconnected;
static StompFSM_map_SocketConnected SocketConnected;
static StompFSM_map_Ready Ready;
static StompFSM_map_SendingAck SendingAck;
static StompFSM_map_Disconnecting Disconnecting;
};
class StompFSM_map_Default :
public PocoStompState
{
public:
StompFSM_map_Default(const char *name, int stateId)
: PocoStompState(name, stateId)
{};
};
class StompFSM_map_Disconnected :
public StompFSM_map_Default
{
public:
StompFSM_map_Disconnected(const char *name, int stateId)
: StompFSM_map_Default(name, stateId)
{};
void socket_connected(StompContext& context);
void socket_disconnected(StompContext& context);
};
class StompFSM_map_SocketConnected :
public StompFSM_map_Default
{
public:
StompFSM_map_SocketConnected(const char *name, int stateId)
: StompFSM_map_Default(name, stateId)
{};
void send_frame(StompContext& context, PFrame _frame);
void socket_disconnected(StompContext& context);
};
class StompFSM_map_Ready :
public StompFSM_map_Default
{
public:
StompFSM_map_Ready(const char *name, int stateId)
: StompFSM_map_Default(name, stateId)
{};
void receive_frame(StompContext& context, PFrame _frame);
void send_frame(StompContext& context, PFrame _frame);
void socket_disconnected(StompContext& context);
void timeout(StompContext& context);
};
class StompFSM_map_SendingAck :
public StompFSM_map_Default
{
public:
StompFSM_map_SendingAck(const char *name, int stateId)
: StompFSM_map_Default(name, stateId)
{};
void send_frame(StompContext& context, PFrame _frame);
};
class StompFSM_map_Disconnecting :
public StompFSM_map_Default
{
public:
StompFSM_map_Disconnecting(const char *name, int stateId)
: StompFSM_map_Default(name, stateId)
{};
void ack_received(StompContext& context, PFrame _frame);
void timeout(StompContext& context, PocoStompState* waitingfor);
};
class StompContext :
public statemap::FSMContext
{
public:
StompContext(PocoStomp& owner)
: FSMContext(StompFSM_map::Disconnected),
_owner(owner)
{};
StompContext(PocoStomp& owner, const statemap::State& state)
: FSMContext(state),
_owner(owner)
{};
virtual void enterStartState()
{
getState().Entry(*this);
return;
}
PocoStomp& getOwner() const
{
return (_owner);
};
PocoStompState& getState() const
{
if (_state == NULL)
{
throw statemap::StateUndefinedException();
}
return (dynamic_cast<PocoStompState&>(*_state));
};
void ack_received(PFrame _frame)
{
(getState()).ack_received(*this, _frame);
};
void receive_frame(PFrame _frame)
{
(getState()).receive_frame(*this, _frame);
};
void send_frame(PFrame _frame)
{
(getState()).send_frame(*this, _frame);
};
void socket_connected()
{
(getState()).socket_connected(*this);
};
void socket_disconnected()
{
(getState()).socket_disconnected(*this);
};
void timeout()
{
(getState()).timeout(*this);
};
void timeout(PocoStompState* waitingfor)
{
(getState()).timeout(*this, waitingfor);
};
private:
PocoStomp& _owner;
};
}
/*
* Local variables:
* buffer-read-only: t
* End:
*/
#endif // _H_STOMP_SM