78 :
Event(
name), from_(from), to_(to), ready_(
false) {}
83 EventPtr
clone()
const override {
return std::make_unique<Transition<T>>(
name(), from_, to_); }
85 bool operator()(
const Sync&, T x) {
92 }
else if (x != from_) {
106 void to_json(Json& j)
const override {
119 template <
typename T>
126 using namespace fable::schema;
127 static const char* desc =
"transition between one state and another";
133 {
"from", make_prototype<T>().
description(
"from state").require()},
134 {
"to", make_prototype<T>().description(
"destination state").require()},
141 auto from = c.
get<T>(
"from");
142 auto to = c.
get<T>(
"to");
143 return std::make_unique<Transition<T>>(
name(), from, to);
144 }
catch (std::exception& e) {
149 EventPtr
make(
const std::string& s)
const override {
150 auto sep = s.find(
"->");
151 if (sep == std::string::npos) {
155 auto from = Json{s.substr(0, sep)}.get<T>();
156 auto to = Json{s.substr(sep + 2)}.get<T>();
164 template <
typename T>
Definition: registrar.hpp:44
const std::string & description() const
Definition: entity.hpp:90
const std::string & name() const
Definition: entity.hpp:67
Definition: trigger.hpp:478
Definition: trigger.hpp:290
Definition: trigger.hpp:73
Definition: transition_event.hpp:120
EventPtr make(const Conf &c) const override
Definition: transition_event.hpp:139
EventPtr make(const std::string &s) const override
Definition: transition_event.hpp:149
TriggerSchema schema() const override
Definition: transition_event.hpp:125
Definition: transition_event.hpp:75
EventPtr clone() const override
Definition: transition_event.hpp:83
T get() const
Definition: conf.hpp:298
nlohmann::json Json
Definition: fable_fwd.hpp:35
Definition: trigger.hpp:87
const std::string & description() const
Definition: trigger.hpp:143
Definition: trigger.hpp:207