Boost logo

Boost Users :

Subject: Re: [Boost-users] [Statechart] Passing Arguments in the Events Concept
From: Andreas Huber (ahd6974-spamboostorgtrap_at_[hidden])
Date: 2008-09-30 16:08:24


Hi

> I have been researching the Boost archives, Tutorials,
> examples and I do find references to the fact that it is
> possible to provide arguments along with Events that a
> custom_reaction (in self-transition) can selectively
> "react" on based on the value of the argument but
> I am unable to articulate it using the Boost Statechart
> library.

I just realized that there is not a single example on how to pass arguments with events. It's very easy to do, though:

struct EvWhatever : sc::event< EvWhatever >
{
    int Arg1;
    double Arg2;
    // More arguments here
};

You might want to add a constructor that accepts corresponding arguments and sets the data members Arg1 & Arg2 accordingly.

You can access Arg1 & Arg2 in the react member function, in a transition action or the function called by an in_state_reaction.

Hope this helps. if not, please let me know.

Regards,

--
Andreas Huber
When replying by private email, please remove the words spam and trap from the address shown in the header.

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