Commit 59594f31458628e2666ad4ce0dae2e4b80b1beaa
1 parent
72d8b99b
derive EventDispatcher from EventSubject
Showing
2 changed files
with
25 additions
and
2 deletions
| ... | ... | @@ -40,6 +40,8 @@ typedef enum TR_e_EventDispatcherMode { |
| 40 | 40 | } TR_EventDispatcherMode; |
| 41 | 41 | |
| 42 | 42 | TR_CLASS(TR_EventDispatcher) { |
| 43 | + TR_EXTENDS(TR_EventSubject); | |
| 44 | + | |
| 43 | 45 | TR_Queue events; |
| 44 | 46 | TR_Hash handler; |
| 45 | 47 | TR_EventHandler default_handler; |
| ... | ... | @@ -49,7 +51,14 @@ TR_CLASS(TR_EventDispatcher) { |
| 49 | 51 | TR_EventDispatcherMode mode; |
| 50 | 52 | }; |
| 51 | 53 | TR_INSTANCE_INIT(TR_EventDispatcher); |
| 52 | -TR_CLASSVARS_DECL(TR_EventDispatcher) {}; | |
| 54 | +TR_CLASSVARS_DECL(TR_EventDispatcher) { | |
| 55 | + TR_CV_EXTENDS(TR_EventSubject); | |
| 56 | +}; | |
| 57 | + | |
| 58 | +#define TR_DISPATCHER_EVENT_HEARTBEAT 0 | |
| 59 | +#define TR_DISPATCHER_EVENT_USER_WAIT 1 | |
| 60 | +#define TR_DISPATCHER_EVENT_DATA_WAIT 2 | |
| 61 | +#define TR_DISPATCHER_EVENT_SHUTDOWN 3 | |
| 53 | 62 | |
| 54 | 63 | void TR_eventDispatcherRegisterHandler(TR_EventDispatcher, TR_EventHandler); |
| 55 | 64 | void TR_eventDispatcherSetHeartbeat(TR_EventDispatcher, time_t); | ... | ... |
| ... | ... | @@ -54,7 +54,21 @@ eventDispatcherDtor(void * _this) { |
| 54 | 54 | TR_delete(this->events); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | +static | |
| 58 | +void | |
| 59 | +eventDispatcherCvInit(TR_class_ptr cls) | |
| 60 | +{ | |
| 61 | + TR_EVENT_CREATE(cls, TR_DISPATCHER_EVENT_HEARTBEAT); | |
| 62 | + TR_EVENT_CREATE(cls, TR_DISPATCHER_EVENT_USER_WAIT); | |
| 63 | + TR_EVENT_CREATE(cls, TR_DISPATCHER_EVENT_DATA_WAIT); | |
| 64 | + TR_EVENT_CREATE(cls, TR_DISPATCHER_EVENT_SHUTDOWN); | |
| 65 | +} | |
| 66 | + | |
| 57 | 67 | TR_INIT_IFACE(TR_Class, eventDispatcherCtor, eventDispatcherDtor, NULL); |
| 58 | -TR_CREATE_CLASS(TR_EventDispatcher, NULL, NULL, TR_IF(TR_Class)); | |
| 68 | +TR_CREATE_CLASS( | |
| 69 | + TR_EventDispatcher, | |
| 70 | + TR_EventSubject, | |
| 71 | + eventDispatcherCvInit, | |
| 72 | + TR_IF(TR_Class)); | |
| 59 | 73 | |
| 60 | 74 | // vim: set ts=4 sw=4: | ... | ... |
Please
register
or
login
to post a comment