SMACC
Loading...
Searching...
No Matches
eg_conditional_generator.h
Go to the documentation of this file.
1#pragma once
2#include <smacc/common.h>
5#include <typeinfo>
6#include <boost/statechart/event.hpp>
7#include <functional>
8
9namespace smacc
10{
11 namespace event_generators
12 {
13 template <typename TSource, typename TState>
14 struct EvTrue : sc::event<EvTrue<TSource, TState>>
15 {
16 };
17
18 template <typename TSource, typename TState>
19 struct EvFalse : sc::event<EvFalse<TSource, TState>>
20 {
21 };
22
24 {
27 };
28
29 //-----------------------------------------------------------------------
31 {
32 public:
33 EgConditionalGenerator(ConditionalGeneratorMode mode, std::function <bool()> updatePredicate = nullptr);
34
35 virtual void onEntry() override;
36
37 template <typename TState, typename TSource>
39 {
40 this->postEventTrue = [this]() { this->postEvent<EvTrue<TSource, TState>>(); };
41 this->postEventFalse = [this]() { this->postEvent<EvFalse<TSource, TState>>(); };
42 }
43
44 virtual void update() override;
46
47 void setPredicateFunction(std::function <bool()> updatePredicate);
48
49 private:
51 std::function<void()> postEventTrue;
52 std::function<void()> postEventFalse;
53 std::function<bool()> updatePredicate_;
54 };
55 } // namespace state_reactors
56} // namespace smacc
void setPredicateFunction(std::function< bool()> updatePredicate)