-
Notifications
You must be signed in to change notification settings - Fork 6
/
event.h
48 lines (32 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
48
#ifndef _event
#define _event
#include <iostream>
#include <queue>
#include "messages.h"
#include "topology.h"
enum EventType { ADD_NODE, DELETE_NODE, ADD_LINK, DELETE_LINK,
CHANGE_NODE, CHANGE_LINK, DRAW_TOPOLOGY, DRAW_TREE, DRAW_PATH,
DUMP_TABLE, ROUTING_MESSAGE_ARRIVAL, TIMEOUT, PRINT};
class Event {
private:
double timestamp;
EventType etype;
void *handler;
void *data;
public:
Event(double t, EventType e, void *handler, void *d);
// default copy construct and operator= is OK
virtual ~Event();
double GetTimeStamp();
void Dispatch();
void Disassociate();
bool IsLater(const Event *rhs) const;
ostream & Print(ostream &os) const;
};
inline ostream & operator<<(ostream &os, const Event &e) { return e.Print(os);}
struct CompareEvents : public binary_function<Event *,Event *, bool> {
inline bool operator ()(const Event *lhs, const Event *rhs) {
return lhs->IsLater(rhs);
}
};
#endif