Boost logo

Boost Users :

Subject: Re: [Boost-users] [MSM] How to use is_flag_active inside on_entry ?
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2011-08-26 17:08:29


> 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<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

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<class Event, class FSM>
 void on_entry(Event const& event, FSM& fsm) {
 if(fsm.template is_flag_active<FlagMaster>())
{
 // doSomeThing();
 }
 }
 };

HTH,
Christophe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net