65 if constexpr (std::is_same_v<
Token,
decltype(callback())>) {
67 }
else if constexpr (std::is_convertible_v<
decltype(callback()),
Token>) {
69 }
else if constexpr (std::is_same_v<void,
decltype(callback())>) {
100 template <
typename Transition>
107 : self_(std::make_shared<model<
Transition>>(std::move(callback))) {}
110 return callback.self_->fire_();
112 friend Eventlog getLog(
const Callback &callback) {
113 return callback.self_->get_log_();
115 friend bool isSynchronous(
const Callback &callback) {
116 return callback.self_->is_synchronous_();
118 friend void cancel(
const Callback &callback) {
119 return callback.self_->cancel_();
121 friend void pause(
const Callback &callback) {
122 return callback.self_->pause_();
124 friend void resume(
const Callback &callback) {
125 return callback.self_->resume_();
130 virtual ~concept_t() =
default;
131 virtual Token fire_()
const = 0;
132 virtual Eventlog get_log_()
const = 0;
133 virtual void cancel_()
const = 0;
134 virtual void pause_()
const = 0;
135 virtual void resume_()
const = 0;
136 virtual bool is_synchronous_()
const = 0;
146 template <
typename Transition>
147 struct model final : concept_t {
148 model(Transition &&x) : transition_(std::move(x)) {}
149 Token fire_()
const override {
return fire(transition_); }
150 Eventlog get_log_()
const override {
return getLog(transition_); }
151 void cancel_()
const override {
return cancel(transition_); }
152 bool is_synchronous_()
const override {
return isSynchronous(transition_); }
153 void pause_()
const override {
return pause(transition_); }
154 void resume_()
const override {
return resume(transition_); }
158 std::shared_ptr<const concept_t> self_;
Token fire(const T &callback)
Generates a Token based on what kind of information the Callback returns.
Definition callback.h:64
Eventlog getLog(const T &)
Get the Log object. By default it returns an empty vector.
Definition callback.h:82
bool isSynchronous(const T &)
Checks if the callback is synchronous. Synchronous callbacks are immediately executed inside the Petr...
Definition callback.h:21
void resume(const T &)
Templates a resume action for a Callback. By default it does nothing and not resume the Callback.
Definition callback.h:52
void cancel(const T &)
The default cancel implementation is naive. It only returns a user-exit state and does nothing to the...
Definition callback.h:34
void pause(const T &)
Implements a pause action for a Callback. By default it does nothing and not pause the Callback.
Definition callback.h:43
Callback is a wrapper around any type that you to tie to a transition. Typically this is an invokable...
Definition callback.h:98
Callback(Transition callback)
Construct a new Callback object.
Definition callback.h:106
Tokens are elements that can reside in places. Tokens can have a color which makes them distinguishab...
Definition colors.hpp:104
Definition colors.hpp:211
std::vector< Event > Eventlog
Definition types.h:32
std::string Transition
Definition types.h:14