[boost::statechart] some questions

I'm using boost CVS version gotten on Fri Apr 6 11:48:58 EDT 2007. I'm starting to use boost::statechart for the first time. Scanning the available documentation has produced some questions. I found the following text in a C++ comment within the tutorial: context<>() is used to gain access to the direct or indirect context of a state. This can either be a direct or indirect outer state or the state machine itself. 1, What does "direct" "indirect" context mean? It is documented a number of places that the possible types of reactions are: 1. custom-reaction 2. in-state-reaction 3. deferral 4. transition 2. What is the syntax for using an "in-state-reaction", which I assume is a self transition? 3. What is a custom-reaction? 4. What is a deferral?

Jeffrey Holle wrote:
I'm using boost CVS version gotten on Fri Apr 6 11:48:58 EDT 2007.
I'm starting to use boost::statechart for the first time.
Scanning the available documentation has produced some questions.
I found the following text in a C++ comment within the tutorial: context<>() is used to gain access to the direct or indirect context of a state. This can either be a direct or indirect outer state or the state machine itself.
1, What does "direct" "indirect" context mean?
Have you read: http://www.boost-consulting.com/boost/libs/statechart/doc/definitions.html#C... ?
It is documented a number of places that the possible types of reactions are: 1. custom-reaction 2. in-state-reaction 3. deferral 4. transition
2. What is the syntax for using an "in-state-reaction"
Pretty much the same as for a transition with a transition action but of course without the Destination parameter. See here for an example: http://www.boost-consulting.com/boost/libs/statechart/doc/tutorial.html#Tran... (see the typedef in the Focusing struct)
, which I assume is a self transition?
No. A self-transition, at least with UML <2.0, always exits the state where it originates and then reenters it. That is, if present the states' exit and entry actions are called. An in-state reaction never changes the current state configuration.
3. What is a custom-reaction?
Please see http://www.boost-consulting.com/boost/libs/statechart/doc/tutorial.html#Inte... Basically they allow you to do things for which the predefined reactions are too inflexible. An event often carries arguments with it and you sometimes want to inspect these arguments before you decide exactly what kind of reaction you want to execute. Another common use-case is when the kind of reaction depends on the value of local state variables.
4. What is a deferral?
Short answer: http://www.omg.org/cgi-bin/apps/doc?formal/07-02-05.pdf, page 548 Longer answer: http://www.boost-consulting.com/boost/libs/statechart/doc/tutorial.html#Defe... HTH, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.

Andreas Huber wrote:
3. What is a custom-reaction? Basically they allow you to do things for which the predefined reactions are too inflexible.
Just what are the "predefined reactions"? I want to execute application specific code when a transition occurs. Does this mean I must use "custom-reactions"?

Jeffrey Holle wrote:
Andreas Huber wrote:
3. What is a custom-reaction? Basically they allow you to do things for which the predefined reactions are too inflexible.
Just what are the "predefined reactions"?
I want to execute application specific code when a transition occurs. Does this mean I must use "custom-reactions"?
I can see that transaction template can have applications specific actions attached, but the documentation is limited and no examples are present in my present boost download. The documentation says a transaction template can take 4 template parameters. The last two are: TransitionContext pTransitionAction If someone could supply me with an example use of these parameters, I could probably write my code. Note that in my case, the method I want to execute an transition is in my state class.

Jeffrey Holle wrote:
Jeffrey Holle wrote:
Andreas Huber wrote:
3. What is a custom-reaction? Basically they allow you to do things for which the predefined reactions are too inflexible.
Just what are the "predefined reactions"?
I want to execute application specific code when a transition occurs. Does this mean I must use "custom-reactions"?
No, see below.
I can see that transaction template can have applications specific actions attached, but the documentation is limited
It would help if you could point out exactly how you feel that the docs are limited.
and no examples are present in my present boost download.
Umm, how about ... http://www.boost-consulting.com/boost/libs/statechart/doc/tutorial.html#Tran... ... (I've already posted this link in my first follow-up)? Both cases are shown, namely the case where the transition action is a member of an outer state and where it is a member of the state_machine subclass itself.
The documentation says a transaction template can take 4 template parameters. The last two are: TransitionContext pTransitionAction
If someone could supply me with an example use of these parameters, I could probably write my code. Note that in my case, the method I want to execute an transition is in my state class.
See above. -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.

OK, I've "succeeded" to get a transition handler to compile, but only if if I use a method defined in another class. When I attempt a reference a local method, the the compiler complains that a partially defined class is being used in the definition the the reactions typedef in my state class. Local data is what is needed because the hierarchical nature of an XML file. Can one reference local methods in a transition template? If not, will I be able to employ the content<> template in a state machine method to access the state object content which has the data? Even if this works, it is less than optional because I'll have to define addition methods and wonder about efficiency.

Jeffrey Holle wrote:
OK, I've "succeeded" to get a transition handler to compile, but only if if I use a method defined in another class. When I attempt a reference a local method,
I assume with "local method" you mean a method that is a member of the same class that also defines the transition in its reactions typedef. [snip]
Can one reference local methods in a transition template?
No, you cannot. The very semantics UML state machines forbid you to do that. If you read everything under http://www.boost-consulting.com/boost/libs/statechart/doc/tutorial.html#Tran... then this should become abundantly clear. That is, at the point where the transition action should be called, the state in question has already been exited (the state object is destroyed).
If not, will I be able to employ the content<> template in a state machine method to access the state object content which has the data?
I assume you mean the context<> template. If so then the answer is no. As the name suggests this template is intended to give you access to a context of a given state object. Could you please explain exactly what you want to achieve? The code you have so far with a few comments would go a long way. -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
participants (2)
-
Andreas Huber
-
Jeffrey Holle