Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
trigger.h
1#ifndef TRIGGER_H
2#define TRIGGER_H
3
4#include <functional>
5
6namespace ara
7{
8 namespace sm
9 {
11 using TriggerHandler = std::function<void()>;
12
15 template <typename T>
16 class Trigger
17 {
18 private:
19 T &mState;
20 TriggerHandler mHandler;
21
22 public:
26 Trigger(T &state, TriggerHandler handler) : mState{state},
27 mHandler{handler}
28 {
29 }
30
31 Trigger() = delete;
32 ~Trigger() noexcept = default;
33 Trigger(const Trigger &) = delete;
34 Trigger(Trigger &&) = delete;
35 Trigger &operator=(const Trigger &) = delete;
36 Trigger &operator=(Trigger &&) = delete;
37
40 void Write(T state)
41 {
42 mState = state;
43 mHandler();
44 }
45 };
46 }
47}
48
49#endif
State changing trigger wrapper.
Definition: trigger.h:17
Trigger(T &state, TriggerHandler handler)
Constructor.
Definition: trigger.h:26
void Write(T state)
Write into the trigger.
Definition: trigger.h:40
std::function< void()> TriggerHandler
Callback on trigger invocation.
Definition: trigger.h:11