[StateChart] Inheriting state
Hello,
I'd like to share some functionality between states belonging to
different (but similar) FSMs. I try to do this by taking out some part
of a state to a base class template:
template
reactions; };
However, this doesn't compile:
1>..\boost/statechart/state_machine.hpp(493) : error C2440: 'return' :
cannot convert from 'FSM' to 'ActiveBase
Hi Igor [snip]
Of course, the above snippet is not the real code, and maybe I miss the problem in some other place, but I just would like to know if the above approach legitimate and *should* compile.
I can't see anything wrong with your code, you should be able to inherit states as you outlined in your post. If you continue to have problems, please don't hesitate to post a repro. HTH, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
If you continue to have problems, please don't hesitate to post a repro.
Here it is:
#include
"Igor R"
If you continue to have problems, please don't hesitate to post a repro.
Here it is: [snip]
Sorry, it seems I was wrong when I said that your code should work. According to the reference, your use of in_state_reaction is invalid. ReactionContext must be a state (see SimpleState concept), which ActiveBase clearly isn't. That said, I think it's unfortunate that it doesn't work, but at the same time I don't currently see any easy way to make it work. Let me think about this some more. In the mean time, you can work around the problem by defining a forwarding function in Active that calls ActiveBase::f. Anyway, thanks for your report. Regards, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
Sorry, it seems I was wrong when I said that your code should work. According to the reference, your use of in_state_reaction is invalid. ReactionContext must be a state (see SimpleState concept), which ActiveBase clearly isn't
Ok, I see, thanks for pointing that out.
In the mean time, you can work around the problem by defining a forwarding function in Active that calls ActiveBase::f.
Well, in my case there are many small functions (reactions), so forwarding them would defeat the whole idea. I think the workaround proposed by Tarcisio is more appropriate for my case (thanks, Tarcisio!): http://permalink.gmane.org/gmane.comp.lib.boost.user/55532 Thanks, Igor'.
Well, in my case there are many small functions (reactions), so forwarding them would defeat the whole idea. I think the workaround proposed by Tarcisio is more appropriate for my case (thanks, Tarcisio!): http://permalink.gmane.org/gmane.comp.lib.boost.user/55532
Ok, FWIW, I think I can make your example work as is. I'll keep you posted. Regards, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
Hi Igor It turned out to be much easier than anticipated. The repro you posted earlier now works with the trunk version of Statechart (rev 59506 and later). All tests pass on MSVC9.0 SP1. BTW, the statechart trunk is in release ready state, so you should be able to use it verbatim with any recent (>1.39) version of Boost. Thanks again for your report! HTH, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
It turned out to be much easier than anticipated. The repro you posted earlier now works with the trunk version of Statechart (rev 59506 and later). All tests pass on MSVC9.0 SP1.
BTW, the statechart trunk is in release ready state, so you should be able to use it verbatim with any recent (>1.39) version of Boost.
Great! Thanks for your assistance, Igor'.
participants (2)
-
Andreas Huber
-
Igor R