65 #ifndef CLOE_TRIGGER_TRANSITION_EVENT_HPP_ 66 #define CLOE_TRIGGER_TRANSITION_EVENT_HPP_ 80 :
Event(name), from_(from), to_(to), ready_(
false) {}
85 EventPtr
clone()
const override {
return std::make_unique<Transition<T>>(
name(), from_, to_); }
87 bool operator()(
const Sync&, T x) {
94 }
else if (x != from_) {
121 template <
typename T>
129 static const char* desc =
"transition between one state and another";
135 {
"from", make_prototype<T>().
description(
"from state").require()},
136 {
"to", make_prototype<T>().
description(
"destination state").require()},
143 auto from = c.
get<T>(
"from");
144 auto to = c.
get<T>(
"to");
145 return std::make_unique<Transition<T>>(
name(), from, to);
146 }
catch (std::exception& e) {
151 EventPtr
make(
const std::string& s)
const override {
152 auto sep = s.find(
"->");
153 if (sep == std::string::npos) {
157 auto from = Json{s.substr(0, sep)}.get<T>();
158 auto to = Json{s.substr(sep + 2)}.get<T>();
159 return make(
Conf{Json{
166 template <
typename T>
172 #endif // CLOE_TRIGGER_TRANSITION_EVENT_HPP_
Definition: registrar.hpp:45
EventPtr clone() const override
Definition: transition_event.hpp:85
Definition: trigger.hpp:73
Definition: transition_event.hpp:122
T get() const
Definition: conf.hpp:164
EventPtr make(const Conf &c) const override
Definition: transition_event.hpp:141
Definition: coordinator.hpp:36
Definition: trigger.hpp:487
TriggerSchema schema() const override
Definition: transition_event.hpp:127
Definition: transition_event.hpp:77
Definition: trigger.hpp:300
std::string name() const
Definition: entity.hpp:68
std::string description() const
Definition: entity.hpp:91
void to_json(Json &j) const override
Definition: transition_event.hpp:108
Definition: trigger.hpp:87
EventPtr make(const std::string &s) const override
Definition: transition_event.hpp:151
Definition: trigger.hpp:207