Boost logo

Boost Users :

Subject: Re: [Boost-users] [msm] extending msm::back::state_machine
From: christophe.j.henry_at_[hidden]
Date: 2014-09-09 14:05:44


Hi Manuel,
>The reason I want to extend the backend is that I need to maintain a separate event queue (a job queue).
>
>In reality, "test()" is a function template, so I cannot use virtual functions.
>

>
>If I implement this function template in the frontend, I need to static_cast to the backend, which I try to avoid
>struct fsm_ : public boost::msm::front::state_machine_def<fsm_>
>{
>
>typedef msmb::state_machine<fsm_> BackMachine;
>
>template <typename EventType>
>void enqueue_job(const EventType& evt)
>{
> job_queue.push(
> std::bind(&BackMachine::template process_event<EventType>, static_cast<BackMachine*>(this), evt)
> );
>}

>};
>
>
>Is there any third option?

Unfortunately not in the general case.
But in your use case, maybe. There is already in state_machine<> an enqueue_event() and an execute_queued_events(). Could this help?

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