Commit 72d8b99bc069d794d2587f94ebd1c47edfa1df36

Authored by Georg Hopp
1 parent ab4ae343

code for event handling

... ... @@ -27,6 +27,11 @@
27 27
28 28 #include "trbase.h"
29 29 #include "trdata.h"
  30 +
  31 +#include "tr/event.h"
  32 +
  33 +TR_CLASS(TR_EventDispatcher);
  34 +
30 35 #include "tr/event_handler.h"
31 36
32 37 typedef enum TR_e_EventDispatcherMode {
... ... @@ -46,7 +51,16 @@ TR_CLASS(TR_EventDispatcher) {
46 51 TR_INSTANCE_INIT(TR_EventDispatcher);
47 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 65 #endif // __TR_EVENT_DISPATCHER_H__
52 66
... ...
... ... @@ -23,8 +23,11 @@
23 23 #ifndef __TR_EVENT_HANDLER_H__
24 24 #define __TR_EVENT_HANDLER_H__
25 25
  26 +#include <sys/types.h>
  27 +
26 28 #include "trbase.h"
27 29 #include "trdata.h"
  30 +
28 31 #include "tr/event.h"
29 32 #include "tr/event_subject.h"
30 33
... ... @@ -32,8 +35,11 @@ TR_CLASS(TR_EventHandler);
32 35
33 36 #include "tr/event_dispatcher.h"
34 37
  38 +typedef int (* TR_EventMethod_fptr)(TR_Event);
  39 +
35 40 TR_CLASS(TR_EventHandler) {
36 41 TR_EventDispatcher dispatcher[10];
  42 + size_t ndispatcher;
37 43 TR_Hash event_methods;
38 44 };
39 45 TR_INSTANCE_INIT(TR_EventHandler);
... ...
... ... @@ -5,7 +5,11 @@ AM_CFLAGS += -I../include/
5 5
6 6 TREVENT = event.c \
7 7 event_dispatcher.c \
  8 + event_dispatcher_register_handler.c \
8 9 event_handler.c \
  10 + event_handler_handle_event.c \
  11 + event_handler_issue_event.c \
  12 + event_handler_set_dispatcher.c \
9 13 event_subject.c \
10 14 event_subject_emit.c \
11 15 event_subject_id.c
... ...
... ... @@ -32,6 +32,7 @@ int
32 32 eventHandlerCtor(void * _this, va_list * params) {
33 33 TR_EventHandler this = _this;
34 34
  35 + this->ndispatcher = 0;
35 36 this->event_methods = TR_new(TR_Hash);
36 37
37 38 return 0;
... ...
Please register or login to post a comment