[MSM] Problem with passing event as a reference to base event class

Hi, I have noticed a strange problem with event processing with msm. My events derive publicly from a base events struct like this: struct BaseEvent { virtual ~BaseEvent() {} }; struct ConcreteEvent : public BaseEvent {}; I my FSM i have a transition defined for ConcreteEvent, When I do this : void foo(const BuddyEvent& event) { fsm->process_event(event); // event is of type ConcreteEvent } The fsm fires a no_transition , and I see a message saying no transition for ConcreteEvent in state X (state X has a valid transition for ConcreteEvent) However this succeeds: void foo(const BuddyEvent& event) { fsm->process_event(ConcreteEvent(0); } I am using boost-1.49 and the boost msm library that comes bundled with this. So my question is, why is msm not able to generate a valid transition for a concrete event passed as a reference to its base tyoe. Thanks!

Hi,
Hi,
I have noticed a strange problem with event processing with msm. My events derive publicly from a base events struct like this:
struct BaseEvent { virtual ~BaseEvent() {} }; struct ConcreteEvent : public BaseEvent {};
I my FSM i have a transition defined for ConcreteEvent,
When I do this :
void foo(const BuddyEvent& event)
Do you mean BaseEvent?
{ fsm->process_event(event); // event is of type ConcreteEvent }
The fsm fires a no_transition , and I see a message saying no transition for ConcreteEvent in state X (state X has a valid transition for >ConcreteEvent)
The message is probably using typeid, which uses rtti, msm does not.
However this succeeds: void foo(const BuddyEvent& event) { fsm->process_event(ConcreteEvent(0); }
I am using boost-1.49 and the boost msm library that comes bundled with this. This should make no difference, but I'm not sure what bugs there were in this version.
So my question is, why is msm not able to generate a valid transition for a concrete event passed as a reference to its base tyoe.
MSM is a compile-time construct, not run-time. When you call process_event, templatized on the event type, the compile generates code for this type, because it has no way to know which event you will really send at run-time. Note that the other way around would work, a transition with BaseEvent, and process_event(ConcreteEvent(0)) because this is something the compiler can solve. What you want is probably possible in C++, but it would be another library based on rtti (no idea if one is doing though). Cheers, Christophe
participants (2)
-
Christophe Henry
-
samriti katoch