11 virtual bool call(std::size_t eventId) = 0;
19 : action_{std::move(action)}
20 , valid_{std::move(
valid)}
23 bool call(std::size_t eventId)
override
25 auto result = action_(eventId);
35 std::function<bool(std::size_t eventId)> action_;
36 std::function<bool()> valid_;
43 std::function<
bool(std::size_t eventId)> action,
44 std::function<
bool()> valid =
48 : impl_{std::make_unique<TwoFunctorEventImpl>(std::move(action), std::move(valid))}
57 return impl_->valid();
61 return impl_->call(eventId);
65 std::unique_ptr<EventImpl> impl_;
Event & operator=(Event const &)=delete
Event(Event const &)=delete
bool operator()(std::size_t eventId) const
Definition: event.hpp:59
Event(std::function< bool(std::size_t eventId)> action, std::function< bool()> valid=[] { return true;})
Definition: event.hpp:42
Event & operator=(Event &&)=default
Definition: file_dialog.hpp:6
virtual ~EventImpl()=default
virtual bool valid() const =0
virtual bool call(std::size_t eventId)=0
bool valid() const override
Definition: event.hpp:29
bool call(std::size_t eventId) override
Definition: event.hpp:23
TwoFunctorEventImpl(std::function< bool(std::size_t eventId)> action, std::function< bool()> valid)
Definition: event.hpp:18