boost-ext / sml

C++14 State Machine library
https://boost-ext.github.io/sml
Boost Software License 1.0
1.16k stars 178 forks source link

Marking initial state in transition that originates from its nested state #44

Open Ulenspiegel opened 8 years ago

Ulenspiegel commented 8 years ago

How does one indicate initial state in an explicit transition that originates from the state nested inside the initial one, like in following example:

struct TopState {
  TopState() {}
  auto configure() const noexcept {
    using namespace msm;
    return make_transition_table(
        // Mark ss1 as initial state.
        *ss1(ls1_1) + event<e3> = ss2,  // Compilation error.
        ss2 + event<e4> = ss1
        /* ... */
    );
  }
};

Introducing separate initial state with anonymous transition to ss1 solves it, but is there a better way?

kris-jusiak commented 8 years ago

Thanks @Ulenspiegel for pointing out this issue. Unfortunately this is not implemented yet completly but your syntax is the one which should evntually works for it. For now you can explicitly enter sub state machine, like that:

 idle + event<e3> = sub(region1_state, region2_state, etc...)

I will keep this issue open as long as the proper functionality will not be implemented.

redboltz commented 8 years ago

I think that the question is related to exit point pseudo state on UML2.x. http://redboltz.wikidot.com/exit-point-pseudo-state

And the @krzysztof-jusiak 's comment is related to entry point pseudo state. http://redboltz.wikidot.com/entry-point-pseudo-state

I also want to that feature.

redboltz commented 7 years ago

Does the comment https://github.com/boost-experimental/sml/issues/44#issuecomment-223609106 mean that I can specify submachines' entry state directly? If it is, does it work with #75?

I mean something like as follows:

idle + event<e3> = "sub1"_s.sm<sub>(region1_state, region2_state, etc...)
redboltz commented 7 years ago

I noticed that

idle + event<e3> = "sub1"_s.sm<sub>(region1_state, region2_state, etc...)

got compile error but

idle + event<e3> = "sub1"_s.sm<sub>()(region1_state, region2_state, etc...)

compiles successfully.

However, it seems that transition doesn't happen. I guess that this functionality doesn't work the current version. (https://github.com/boost-experimental/sml/commit/bdad61940497e4a2ea99514bc3462f30d73e8360) http://melpon.org/wandbox/permlink/F8fxhXEk3doZJhbD

kris-jusiak commented 7 years ago

Interesting. Thanks @redboltz for pointing it out. It shouldn't work yet, I'm implementing it at the moment (explicit entry + entry/exit pseudo states). Will keep you informed about the progress.

thildenbrand commented 3 years ago

Will pseudo entry and exit states eventually be supported?