Boost logo

Boost Users :

Subject: [Boost-users] [Statechart] Passing Arguments in the Events Concept
From: Babi Seal (sseal73_at_[hidden])
Date: 2008-09-29 01:10:15


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.

As reference I took the BitMachine/Performance library where the Events seemed to take a class BitNo as a parameter but I could not adapt it for my application.

I am trying to control a box which has many interfaces. Each interface has an InterfaceID . I have statemachines for Box and Interface. When an interface is removed, the statemachine of the interface sends first an InterfaceDeleteTrigger event to get the Box in the InterfaceDelete_Pending state Then the Interface would like to send the actual interface Event InterfaceDelete with the Id to the Box so that the box can trigger the appropriate actions to remove the Interface.

(PS - I am using two events because I read that it is not good design to try to extract triggering events and event arguments for state entry. So I tried to enter the state with a trigger event and used another instate event with actual interface id to find the actual interface).

I tried something like this for the Box StateMachine :

template <class InterfaceID>
struct EvInterfaceDelete : sc::event< EvInterfaceDelete < InterfaceID > > {};

:
:
struct InterfaceDelete_Pending : sc::state < InterfaceDelete_Pending, BoxStateMachine>
{
typedef mpl::list<
sc::custom_reaction < EvInterfaceDelete < InterfaceID> >> reactions;

sc::result reaction (const EvInterfaceDelete <InterfaceID> &)
{
//// Sorry for my ignorance - but how I access the class InterfaceID internals so I can do something like :

Box pBox = outermost_context().box;

uint64_t id = InterfaceID.GetID();
pBox->DeleteInterface(id);

}

Thanks and I greatly appreciate if someone could point me to some examples of code where the events are passed with arguments and the values of the arguments are examined for processing.

Thanks again

      


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