27 lines
732 B
C++
27 lines
732 B
C++
#ifndef ACTION_H
|
|
#define ACTION_H
|
|
|
|
#include "Arduino.h"
|
|
#include "functional"
|
|
#include "StreamEvent.h"
|
|
|
|
template <typename T>
|
|
class Action {
|
|
public:
|
|
Action(function<bool(StreamEvent*)> _funcEventMatchesAction, function<T*(StreamEvent*)> _funcInvokeAction) :
|
|
funcEventMatchesAction(_funcEventMatchesAction), funcInvokeAction(_funcInvokeAction) {}
|
|
|
|
bool eventMatchesAction(StreamEvent* event) {
|
|
return funcEventMatchesAction(event);
|
|
}
|
|
|
|
T* invokeAction(StreamEvent* event) {
|
|
return funcInvokeAction(event);
|
|
}
|
|
|
|
private:
|
|
function<bool(StreamEvent*)> funcEventMatchesAction;
|
|
function<T*(StreamEvent*)> funcInvokeAction;
|
|
};
|
|
|
|
#endif |