jp-embedded / scxmlcc

The SCXML state machine to C++ compiler
GNU General Public License v3.0
138 stars 34 forks source link

Adding event payloads #102

Open wizfromoz opened 5 years ago

wizfromoz commented 5 years ago

This is a suggestion for improvement:

It would be nice if it was possible to pass additional data when dispatching an event. I currently get around this by placing data in the user_model area, but it complicates control of the access in a multi-threaded environment. It would be much simpler if one could pass payload data alongside the event instance when firing events.

sstiller commented 5 years ago

This was added in December 2018 to the string version of dispatch(). It has a second param with a std::any (or boost::any, depending on configurend C++ version). The any object can be accessed in the transition with _event.data (using any_cast, of course). See #87 Works fine on a large embedded state machine I'm working on.

wizfromoz commented 5 years ago

I am using the release version 0.9, which was released in January. It looks like the change you're talking about hasn't made to the release line. Is this in some kind of development line? Any idea when it will make it to the release? Thanks for your prompt response.

jp-embedded commented 5 years ago

The master branch is stable, so you can try this. It is just not tagged with a version nummer.

It wont probobly be long before a new tag is made

But anyway, this feature is missing in the non-string version

You have to enable the string version with a parameter to scxmlcc. Also note that this wont have the same performance if that is critical for you.