Boost logo

Boost Users :

Subject: [Boost-users] [msm] extending msm::back::state_machine
From: Manuel Schiller (caligano_at_[hidden])
Date: 2014-09-05 05:35:56


Hi,

I tried to enhance the backend of boost::msm by inheriting from
boost::msm::back::state_machine.
When doing so, I cannot access members of my subclass in the states.

When compiling the attached example, I get this error message:

*error: ‘class boost::msm::back::state_machine<fsm_,
boost::parameter::void_, boost::parameter::void_, boost::parameter::void_,
boost::parameter::void_>’ has no member named ‘test’*

How can I "inject" extended_back_machine as the type being passed as "FSM"
to the state?

Bye
Manuel

####################################

template<typename FrontMachine>
struct extended_back_machine : public
boost::msm::back::state_machine<FrontMachine>
{
  void test()
  {
    std::cout << "test" << std::endl;
  }
};

struct fsm_ : public boost::msm::front::state_machine_def<fsm_>
{
  struct State : public boost::msm::front::state<>
  {
    template <class Event,class FSM>
    void on_entry(Event const&, FSM& fsm)
    {
      fsm.test();
    }
  };
  typedef State initial_state;
};

int main()
{
  typedef extended_back_machine<fsm_> fsm;
  fsm m;
  m.start();
  return 0;
}

####################################





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