SMACC
Loading...
Searching...
No Matches
sr_conditional.h
Go to the documentation of this file.
1#pragma once
2#include <smacc/common.h>
4#include <map>
5#include <typeinfo>
6#include <boost/statechart/event.hpp>
7
8namespace smacc
9{
10namespace state_reactors
11{
12template <typename TSource, typename TObjectTag = EmptyObjectTag>
13struct Evsr_conditionalTrue : sc::event<Evsr_conditionalTrue<TSource, TObjectTag>>
14{
15};
16
17//-----------------------------------------------------------------------
19{
20private:
21 std::map<const std::type_info *, bool> triggeredEvents;
23
24public:
25 template <typename TEv>
26 Srsr_conditional(std::function<bool(TEv *)> sr_conditionalFunction)
27 {
28 std::function<void(TEv *)> callback =
29 [=](TEv *ev) {
30 bool condition = sr_conditionalFunction(ev);
31 this->conditionFlag = condition;
32 };
33
34 this->createEventCallback(callback);
35 }
36
38
39 virtual bool triggers() override;
40};
41} // namespace state_reactors
42} // namespace smacc
void createEventCallback(void(TClass::*callback)(T *), TClass *object)
Srsr_conditional(std::function< bool(TEv *)> sr_conditionalFunction)
std::map< const std::type_info *, bool > triggeredEvents