I would like to use is_flag_active() function inside one of my state's on_entry template function:
struct StBladeDown : public msm::front::state<> {
template<class Event, class FSM>
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
Try this:
struct StBladeDown : public msm::front::state<> {
template<class Event, class FSM>
void on_entry(Event const& event, FSM& fsm) {
if (fsm.template is_flag_active<FlagMaster>()) {
// doSomeThing();
}
}
};
Note the addition of the template
keyword. See this FAQ for information about why it's necessary in this context: What is the ->template
, .template
and ::template
syntax about?