|
Boost Users : |
Subject: Re: [Boost-users] [statechart] Passing parameters from event to State Local Storage
From: Felipe Magno de Almeida (felipe.almeida_at_[hidden])
Date: 2010-05-06 13:00:59
Christophe Bourez <boost_at_[hidden]> writes:
> I need to maintain a parameter into the state local storage. This
> parameter is initially contained in the event that causes the transition to
> the target state. I give hereafter a small illustrative example.
>
> typename sc = boost::statechart;
>
> class EvTest : public sc::event<EvTest>
> {
> public:
> EvTest(std::size_t val) : value(val) {}
> std::size_t getValue() const { return this->value; }
> private:
> std::size_t value;
> };
>
> class MyStateMachine;
> class StSource;
> class StTarget;
>
> class StSource : public sc::simple_state<StSource, MyStateMachine>
> {
> public:
> typedef sc::custom_reaction<EvTest> reactions;
>
> sc::result react(const EvTest &event)
> {
> // How to pass event.getValue() to the target state ?
> transit<StTarget>();
> }
> };
>
> class StTarget : public sc::simple_state<StTarget, MyStateMachine>
> {
> public:
> StTarget(std::size_t val) : val(value) {}
> private:
> std::size_t value;
> };
I have a patch using boost.fusion to allow this. It works this way:
class StSource : public sc::simple_state<StSource, MyStateMachine>
{
public:
typedef sc::custom_reaction<EvTest> reactions;
sc::result react(const EvTest &event)
{
// How to pass event.getValue() to the target state ?
transit<StTarget>(event.value); // pass arguments to target
// state constructor
}
};
Does Boost have interest in this?
> Thanks,
> Christophe
Regards,
-- Felipe Magno de Almeida
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