To return to the previous state in Boost.Statechart

Asked 1 years ago, Updated 1 years ago, 127 views

I am using Boost.Statechart, but if there are several transition source states, is there an easy way to return to the previous state?

I can do it if I remember which condition I came in from, but could you tell me if there is a better way?

c++ boost state-machines boost-statechart

2022-09-30 19:49

2 Answers

Since the state transition diagram is a directed graph, a reverse state transition must be defined to return to the "previous state".If no reverse transition is defined, it is against the state transition rule in the first place.

Boost.Statechart is a generic framework that represents state transitions, so I don't think it provides exceptional functionality.


2022-09-30 19:49

boot::statechart I've never used the library, so I'd like you to see it as a link until someone knows more about it.

Boost::statechart Tutorial
The above is in English, but the information is new.

Boost Library FSM Tutorial Japanese
The Japanese translation of the above PDF is quite appropriate, but...
The source code of the tutorial is FSM, so it was about 10 years ago before the name changed.
However, even those who are not familiar with English will be able to understand the feeling, so I will leave a link.

In the tutorial documentation, there were items such as History or History.

For example, the declaration for simple_state is as follows:

template<class MostDerived,
          class Context,
          class InnerInitial=mpl::list <>,
          history_mode historyMode = has_no_history>
class simple_state:public detail::simple_state_base_type<MostDerived,
  typenameContext:: inner_context_type, InnerInitial>::type

You can pass one of the following enums to the template parameter history_mode.

 enum history_mode
{
  has_no_history,
  has_show_history,
  has_deep_history,
  has_full_history//show&deep
};

I am sorry that I could not read the difference between show, deep, and full from the above tutorial.

There is also an FAQ asking if the status history can be disabled, so please check it together.(Dynamically disabled, so it's off the mark)


2022-09-30 19:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.