Elma
An event loop manager for embedded systems
All Classes Files Functions Variables Enumerations Pages
event.h
1 #ifndef _ELMA_EVENT_H
2 #define _ELMA_EVENT_H
3 
4 #include <string>
5 #include <vector>
6 #include <json/json.h>
7 
8 using std::string;
9 using std::vector;
10 using nlohmann::json;
11 
12 namespace elma {
13 
15 
23  class Event {
24 
25  public:
26 
29  Event(std::string name, json value) : _name(name), _value(value), _empty(false), _propagate(true) {}
30  Event(std::string name) : _name(name), _value(0), _empty(true), _propagate(true) {}
31 
34  inline json value() const { return _value; }
35 
38  inline bool empty() const { return _empty; }
39 
41  inline std::string name() const { return _name; }
42 
45  inline bool propagate() const { return _propagate; }
46 
50  inline void stop_propagation() { _propagate = false; }
51 
53  inline void reset() { _propagate = true; }
54 
55  private:
56  json _value;
57  bool _propagate;
58  bool _empty;
59  std::string _name;
60 
61  };
62 
63 }
64 
65 #endif
json value() const
Definition: event.h:34
bool empty() const
Definition: event.h:38
void stop_propagation()
Definition: event.h:50
Events that can be emitted, watched, and responded to with event handlers.
Definition: event.h:23
std::string name() const
Definition: event.h:41
void reset()
Turn propagation back on.
Definition: event.h:53
bool propagate() const
Definition: event.h:45
Event(std::string name, json value)
Definition: event.h:29
Definition: channel.cc:5