-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvent.h
47 lines (38 loc) · 960 Bytes
/
Event.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef _SERIALIZABLE_INTERFACE_H_
#include "SerializableInterface.h"
#endif
#ifndef _DATA_H_
#include "Data.h"
#endif
#ifndef _EVENT_H_
#define _EVENT_H_
// Useage:
// class SomeObservableClass {
// ...
// static Event _someEvent;
// ...
// someMethod() {
// this->pushEvent(_someEvent);
// }
// ...
// }
class Event : public SerializableInterface {
public:
static const Data::Type _evtDataType;
private:
static uint32_t _nextID;
uint32_t _id;
public:
explicit Event() { _id = ++_nextID; }
explicit Event(const Data& data);
virtual ~Event() {}
unsigned int getID() const { return _id; }
bool operator==(const Event* evt) const { return (_id == evt->getID()); }
bool operator==(const Event& evt) const { return (_id == evt.getID()); }
// Override SerializableInterface
public:
virtual const Data::Type type() const;
virtual size_t serialize(Data& data);
virtual void deserialize(const Data& data);
};
#endif