Hello,
I have following code :
/////////////////////////////////////////////
#include <iostream>
#include
#include
#include
#include
#include
#include
namespace sc = boost::statechart;
struct Event1 : sc::event<Event1> {};
struct Event11 : sc::event<Event11> {};
struct Meta;
struct Machine : sc::state_machine {};
struct Meta2 : sc::simple_state {
Meta2() { std::cout << "Meta2\n"; }
};
struct Inner1;
struct Inner2;
struct Meta : sc::simple_state> {
Meta() { std::cout << "Meta\n"; }
typedef sc::transition reactions;
};
struct Inner11 : sc::simple_state> {
Inner11() { std::cout << "Inner11\n"; }
typedef sc::custom_reaction<Event1> reactions;
sc::result react(const Event1& ev) {
std::cout << "Inner1 reaction\n";
return forward_event();
}
};
struct Inner1 : sc::simple_state> {
Inner1() { std::cout << "Inner1\n"; }
typedef sc::transition reactions;
};
struct Inner2 : sc::simple_state> {
Inner2() { std::cout << "Inner2\n"; }
};
int main() {
Machine m;
m.initiate();
m.process_event(Event11());
m.process_event(Event1());
return 0;
}
////////////////////
That gives me output:
Meta
Inner1
Inner2
Inner11
Meta2
The goal was to get Event1 processed first in Inner11 state and then forward it to outer state Meta for further processing but looks like event dispatching does not work as expected.
I can make it work in that way only if I put Event1 handling into Inner1 state.
I'm aware of limitation (https://www.boost.org/doc/libs/1_61_0/libs/statechart/doc/rationale.html#Lim... #Event dispatch to orthogonal regions) but as far I understand that considers that case when both Inner1 and Inner11 have same event processing, please correct me if I'm wrong.
Is current dispatching work correctly for my code?
Regards,
Andrew