
On 25.6.2010 10:40, Richard Szabo wrote:
I'm now using Row and Defer functor I have now an other problem whit the :
void defer_event(Event const& e) { // to call this function, you need either a state with a deferred_events typedef // or that the fsm provides the activate_deferred_events typedef BOOST_MPL_ASSERT(( has_fsm_deferred_events<library_sm> )); execute_return (library_sm::*pf) (Event const& evt)= &library_sm::process_event; Event temp (e); ::boost::function<execute_return ()> f= ::boost::bind(pf, this,temp); post_deferred_event(f); }
actually it tries to instantiate the base class ( Event temp (e); ) but in my case the base class is an abstract class -> compiler error; and after deferring I want to dispatch the original derived event not the copy constructed base class instance of the event.
You might try the following: Instead of making your event class polymorphic, you add a shared pointer to polymorphic data. E.g. struct deferred_event { boost::shared_ptr<deferred_event_data_base> event_data; }; This would solve both issues as you would have a single event to be deferred, and it would be copyable but would still retain polymorphic data needed to process event. HTH