[MSM] How to use is_flag_active inside on_entry ?
Hi,
I would like to use is_flag_active<SomeFlag>() function inside one of my state's on_entry template function:
struct StBladeDown : public msm::front::state<> {
template
Hi,
I would like to use is_flag_active<SomeFlag>() function inside one of my state's on_entry template function: struct StBladeDown : public msm::front::state<> { template
void on_entry(Event const& event, FSM& fsm) { if(fsm.is_flag_active<FlagMaster>()) { // ERROR // doSomeThing(); } } }; However I got the following compile error: StOk.hpp: In member function 'void mr::mrd::amfo::StOk_::StBladeDown::on_entry(const Event&, FSM&)': StOk.hpp:78: error: expected primary-expression before '>' token StOk.hpp:78: error: expected primary-expression before ')' token However outside of the state machine, I mean if I first declare a state machine, I can use the is_flag_active: StAMFODirector backEnd; backEnd.start(); processEvent(backEnd,EvBladeDown()); processEvent(backEnd,EvMaster()); if(backEnd.is_flag_active<FlagMaster>()){ // OK _LOG_DEBUG("Flag Master active"); }
If I use the front_end's is_flag_ I get compiler error again (no such function in msm::back::state_machine).
Any idea how to use is_flag_active together with on_entry? Or if it is not possible are there any alternatives?
Thanks for any help, Gabor
Hi Gabor,
welcome to gcc's readable error messages ;-)
I really have to make this clear in the doc. Sorry about it.
on_entry is a template function so you need to add a template keyword.
Try:
struct StBladeDown : public msm::front::state<> {
template
Hi,
I would like to use is_flag_active<SomeFlag>() function inside one of my state's on_entry template function: struct StBladeDown : public msm::front::state<> { template
void on_entry(Event const& event, FSM& fsm) { if(fsm.is_flag_active<FlagMaster>()) { // ERROR // doSomeThing(); } } }; However I got the following compile error: StOk.hpp: In member function 'void mr::mrd::amfo::StOk_::StBladeDown::on_entry(const Event&, FSM&)': StOk.hpp:78: error: expected primary-expression before '>' token StOk.hpp:78: error: expected primary-expression before ')' token However outside of the state machine, I mean if I first declare a state machine, I can use the is_flag_active: StAMFODirector backEnd; backEnd.start(); processEvent(backEnd,EvBladeDown()); processEvent(backEnd,EvMaster()); if(backEnd.is_flag_active<FlagMaster>()){ // OK _LOG_DEBUG("Flag Master active"); }
If I use the front_end's is_flag_ I get compiler error again (no such function in msm::back::state_machine).
Any idea how to use is_flag_active together with on_entry? Or if it is not possible are there any alternatives?
Thanks for any help, Gabor
Hi Gabor,
welcome to gcc's readable error messages ;-) I really have to make this clear in the doc. Sorry about it.
on_entry is a template function so you need to add a template keyword. Try: struct StBladeDown : public msm::front::state<> { template
void on_entry(Event const& event, FSM& fsm) { if(fsm.template is_flag_active<FlagMaster>()) { // doSomeThing(); } } }; HTH, Christophe
Hi Christophe, It is great to hear the answer from the library author! Many thanks, Gabor
participants (2)
-
Christophe Henry
-
Gábor Márton