boost-ext / sml

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

Anonymous explicit transitions from a substate don't seem to work #46

Open Ulenspiegel opened 8 years ago

Ulenspiegel commented 8 years ago

I can't seem to make things work with an anonymous explicit transition from a substate:

#include <boost/msm-lite.hpp>

namespace msm = boost::msm::lite;
using msm::state;
using msm::sm;

struct SubState {
  auto configure() const noexcept {
    using namespace msm;
    return make_transition_table(
        *"ss1"_s + "e2"_t = "final"_s
    );
  }
};

state<sm<SubState>> ss;

struct TopState {
  auto configure() const noexcept {
    using namespace msm;
    return make_transition_table(
        *"s1"_s + "e1"_t = ss,
        // ss("final"_s) + "e3"_t = "s2"_s   // Works.
        // ss("final"_s) / []{} = "s2"_s     // Compiles, but doesn't work.
        // ss("final"_s) = "s2"_s            // Compilation error.
    );
  }
};

int main(int argc, char** argv) {
  using namespace msm;
  sm<TopState> m;
  m.process_event("e1"_t);
  m.process_event("e2"_t);
  m.process_event("e3"_t);
  return 0;
}

Usual transition from a substate works fine. Anonymous transition causes compilation error. Transition with empty action does compile, but it's still not triggered when source state of the substate is entered. I wonder if it's supposed to work, or there's different notation?

It's probably low-priority, but such transitions are useful to make "exit point" pseudostates and keep transition logic (and possibly multiple transitions routed to exit) incapsulated inside substate.

krzysztof-jusiak commented 8 years ago

Thank you @Ulenspiegel for reporting this issue and testing msm-lite so deeply. I really do appreciate this. Of course, you are absolutely right about the problems. I have been fixing some of them already on the 'anonymous' branch last month. Explicit entry is not yet supported, however, the syntax is provided for it :/ I will try to fix it ASAP.

krzysztof-jusiak commented 7 years ago

Small update,

ss("final"_s) = "s2"_s            // Compilation error.

compiles now, however, it still doesn't work.