event_listener.h 1.81 KB
#ifndef _SCOT_EVENT_LISTENER_H
#define _SCOT_EVENT_LISTENER_H

#include <limits.h>

#include <scot/scot_int.h>
#include <scot/event.h>
#include <scot/thread.h>

#include <scot/stack_type_proto.h>

/* valid return codes for the callbacks */
#define SCOT_EVENT_END                 0x00
#define SCOT_EVENT_CONT                0x01
#define SCOT_EVENT_CONT_DATA_DONE		0x02

#define SCOT_EL_WAIT_THREAD_MAX        INFINITE


typedef unsigned short (*scot_event_cb_fptr) (struct scot_event *);

GEN_STACK_TYPE_PROTO (scot_event_cb_fptr);

struct scot_event_listener
{
	unsigned char                     group;

	stack_scot_event_cb_fptr_node_t * cb_mappings[UCHAR_MAX];
	void *                            cb_extra_data[UCHAR_MAX];

	THREAD_T                          thread_handle;
	THREAD_ID_T                       thread_id;
	int                               thread_run_flg;

	scot_thread_entry_fptr            el_entry_func;
};
typedef struct scot_event_listener scot_event_listener;

void scot_event_listener_init        (struct scot_event_listener *,
                                      const unsigned char         ,
                                      const scot_thread_entry_fptr);
void scot_event_listener_fini        (struct scot_event_listener *);
void scot_event_listener_start       (struct scot_event_listener *);
void scot_event_listener_stop        (struct scot_event_listener *);
int  scot_event_listener_is_running  (struct scot_event_listener *);
void scot_event_listener_register_cb (struct scot_event_listener *,
                                      SCOT_EVENT_NO               ,
                                      scot_event_cb_fptr          ,
												  void *);
void scot_event_listener_call_cb     (struct scot_event_listener *, 
                                      struct scot_event *);

#endif /* _SCOT_EVENT_LISTENER_H */