|
Boost Users : |
Subject: [Boost-users] [MSM] How to access event-attributes through a "kleene"-event?
From: Deniz Bahadir (deniz.bahadir_at_[hidden])
Date: 2013-02-19 11:18:01
Hello everyone,
I am trying to use Boost.MSM with the eUML front-end and I must say:
That is a pretty cool thing! :-)
However, I stumbled across some points that raised several questions,
which I hoped someone of you could answer.
One of these points is the usage of the "kleene" event (with eUML). The
questions that came to mind are the following:
1. Is there a way to access an attribute of an (original) event if the
transition-table uses the "kleene" event?
2. If there is a way, can I access it directly from the guard or
actions-list in the transition-table?
3. If there is not a way, is it planned to be implemented (if possible)
and when?
For better understanding I insert here a simple example which explains
what I am trying to do:
In my special case, all my events have an attribute "EventNo" which is a
unique number for each event(-type). Now, I need a transition for the
events with "EventNo" greater than a special number (e.g. 7). So I
thought, I could do something like this:
// The attribute:
BOOST_MSM_EUML_DECLARE_ATTRIBUTE(int, EventNo)
BOOST_MSM_EUML_ATTRIBUTES((attributes_ << EventNo), EventNoAttr)
// All events that contain this attribute:
BOOST_MSM_EUML_EVENT_WITH_ATTRIBUTES(event1, EventNoAttr)
BOOST_MSM_EUML_EVENT_WITH_ATTRIBUTES(event2, EventNoAttr)
/* ... */
BOOST_MSM_EUML_EVENT_WITH_ATTRIBUTES(eventN, EventNoAttr)
// Entry-action of FSM which initializes these event-numbers:
BOOST_MSM_EUML_ACTION(init_all_events)
{
template <class Evt, class Fsm, class State>
void operator()(Evt const&, Fsm&, State&)
{
event1.get_attribute(EventNo) = 1;
event2.get_attribute(EventNo) = 2;
/* ... */
eventN.get_attribute(EventNo) = N;
};
}
// Some states:
BOOST_MSM_EUML_STATE((), State1)
BOOST_MSM_EUML_STATE((), State2)
// The transition table which contains all the logic:
BOOST_MSM_EUML_TRANSITION_TABLE((
State1 + kleene
[event_(EventNo) > Int_<7>()] // <-- Not working!
== State2,
State1 + event1 == State3
/* event2 to event7 are ignored! */
), stt)
// The FSM front-end and back-end:
BOOST_MSM_EUML_DECLARE_STATE_MACHINE((
stt, init_ << init_all_events
), FsmFrontend;
typedef msm::back::state_machine<FsmFrontend> Fsm;
However, the expression "event_(EventNo)" in the transition-guard fails
to compile with the following error:
error: no match for call to
â(boost::msm::front::euml::GetEvent_<EventNo_>) (const
boost::msm::front::euml::kleene_&, boost::msm::back::state_machine<
boost::msm::front::euml::func_state_machine<FsmFrontendtag, ...â
I read in the documentation of the Functor front-end that I should use
boost::any::type() to access the original event in transition actions,
but I do not really know how to go on with it. I am also not sure if
this applies to the eUML front-end at all (especially in the
transition-guard).
I hope someone can help me and answer these questions!?
Thanks in advance,
Deniz Bahadir
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