Showing
4 changed files
with
26 additions
and
1 deletions
@@ -27,6 +27,11 @@ | @@ -27,6 +27,11 @@ | ||
27 | 27 | ||
28 | #include "trbase.h" | 28 | #include "trbase.h" |
29 | #include "trdata.h" | 29 | #include "trdata.h" |
30 | + | ||
31 | +#include "tr/event.h" | ||
32 | + | ||
33 | +TR_CLASS(TR_EventDispatcher); | ||
34 | + | ||
30 | #include "tr/event_handler.h" | 35 | #include "tr/event_handler.h" |
31 | 36 | ||
32 | typedef enum TR_e_EventDispatcherMode { | 37 | typedef enum TR_e_EventDispatcherMode { |
@@ -46,7 +51,16 @@ TR_CLASS(TR_EventDispatcher) { | @@ -46,7 +51,16 @@ TR_CLASS(TR_EventDispatcher) { | ||
46 | TR_INSTANCE_INIT(TR_EventDispatcher); | 51 | TR_INSTANCE_INIT(TR_EventDispatcher); |
47 | TR_CLASSVARS_DECL(TR_EventDispatcher) {}; | 52 | TR_CLASSVARS_DECL(TR_EventDispatcher) {}; |
48 | 53 | ||
49 | -void TR_eventDispatcherRegisterHandler(TR_EventDispatcher, TR_EventHandler); | 54 | +void TR_eventDispatcherRegisterHandler(TR_EventDispatcher, TR_EventHandler); |
55 | +void TR_eventDispatcherSetHeartbeat(TR_EventDispatcher, time_t); | ||
56 | +time_t TR_eventDispatcherGetBeatTime(TR_EventDispatcher); | ||
57 | +time_t TR_eventDispatcherGerDataWaitTime(TR_EventDispatcher); | ||
58 | +//void TR_eventDispatcherEnqueueEvent(TR_EventDispatcher, TR_Event); | ||
59 | +void TR_eventDispatcherStart(TR_EventDispatcher); | ||
60 | +void TR_eventDispatcherStop(TR_EventDispatcher); | ||
61 | +void TR_eventDispatcherShutdown(TR_EventDispatcher); | ||
62 | + | ||
63 | +#define TR_eventDispatcherEnqueueEvent(disp,ev) (TR_queuePut((disp)->events, (ev))) | ||
50 | 64 | ||
51 | #endif // __TR_EVENT_DISPATCHER_H__ | 65 | #endif // __TR_EVENT_DISPATCHER_H__ |
52 | 66 |
@@ -23,8 +23,11 @@ | @@ -23,8 +23,11 @@ | ||
23 | #ifndef __TR_EVENT_HANDLER_H__ | 23 | #ifndef __TR_EVENT_HANDLER_H__ |
24 | #define __TR_EVENT_HANDLER_H__ | 24 | #define __TR_EVENT_HANDLER_H__ |
25 | 25 | ||
26 | +#include <sys/types.h> | ||
27 | + | ||
26 | #include "trbase.h" | 28 | #include "trbase.h" |
27 | #include "trdata.h" | 29 | #include "trdata.h" |
30 | + | ||
28 | #include "tr/event.h" | 31 | #include "tr/event.h" |
29 | #include "tr/event_subject.h" | 32 | #include "tr/event_subject.h" |
30 | 33 | ||
@@ -32,8 +35,11 @@ TR_CLASS(TR_EventHandler); | @@ -32,8 +35,11 @@ TR_CLASS(TR_EventHandler); | ||
32 | 35 | ||
33 | #include "tr/event_dispatcher.h" | 36 | #include "tr/event_dispatcher.h" |
34 | 37 | ||
38 | +typedef int (* TR_EventMethod_fptr)(TR_Event); | ||
39 | + | ||
35 | TR_CLASS(TR_EventHandler) { | 40 | TR_CLASS(TR_EventHandler) { |
36 | TR_EventDispatcher dispatcher[10]; | 41 | TR_EventDispatcher dispatcher[10]; |
42 | + size_t ndispatcher; | ||
37 | TR_Hash event_methods; | 43 | TR_Hash event_methods; |
38 | }; | 44 | }; |
39 | TR_INSTANCE_INIT(TR_EventHandler); | 45 | TR_INSTANCE_INIT(TR_EventHandler); |
@@ -5,7 +5,11 @@ AM_CFLAGS += -I../include/ | @@ -5,7 +5,11 @@ AM_CFLAGS += -I../include/ | ||
5 | 5 | ||
6 | TREVENT = event.c \ | 6 | TREVENT = event.c \ |
7 | event_dispatcher.c \ | 7 | event_dispatcher.c \ |
8 | + event_dispatcher_register_handler.c \ | ||
8 | event_handler.c \ | 9 | event_handler.c \ |
10 | + event_handler_handle_event.c \ | ||
11 | + event_handler_issue_event.c \ | ||
12 | + event_handler_set_dispatcher.c \ | ||
9 | event_subject.c \ | 13 | event_subject.c \ |
10 | event_subject_emit.c \ | 14 | event_subject_emit.c \ |
11 | event_subject_id.c | 15 | event_subject_id.c |
@@ -32,6 +32,7 @@ int | @@ -32,6 +32,7 @@ int | ||
32 | eventHandlerCtor(void * _this, va_list * params) { | 32 | eventHandlerCtor(void * _this, va_list * params) { |
33 | TR_EventHandler this = _this; | 33 | TR_EventHandler this = _this; |
34 | 34 | ||
35 | + this->ndispatcher = 0; | ||
35 | this->event_methods = TR_new(TR_Hash); | 36 | this->event_methods = TR_new(TR_Hash); |
36 | 37 | ||
37 | return 0; | 38 | return 0; |
Please
register
or
login
to post a comment