Skip to content

xumingbo/event_dispatch_framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Event Dispatching Framework

A framework for event-driven development

With event-driven programs, event dispatchers act as central control agents that poll for events from event sources, invoking event handlers as necessary. Generally, there are different types of event sources, each with its own mechanism for generating events:

  1. I/O event sources (sockets), which are common in networked applications.
  2. Timer event sources, in which operating-system timers are used to activate certain tasks of the applications.
  3. Signal event sources, including interruptions such as the UNIX signal generated by Ctrl-C. Some applications need to handle such signals.
  4. UI event sources, such as those in GUI environments (Windows and X-Windows, for instance) in which key strokes and mouse clicks generate events.
  5. Third-party messaging APIs that applications have to deal with.

In general, each application or application platform has its own way of dispatching events. While similar, these dispatchers aren't quite the same. Moreover, many existing event dispatchers are difficult (if not impossible) to extend at the event-source level. By design, Windows and X-Windows are UI oriented, making it awkward to plug in support of third-party messaging events. In many instances, a software-development organization keeps event-dispatching routines in a library that is shared by different projects across the organization. Supported event sources are then hard-coded in the library, making it impossible to add new event sources without modifying the library code. Finally, there appears to be a lack of generic event-dispatching mechanisms that might address some of these problems.

Here presents just such a generic event dispatcher framework that:

  • Captures the commonalities found in event dispatching of normal event-driven applications.
  • Is extendible at event-source level, letting you add new event sources without changing the library's code.
  • Describes events, event sources, event dispatchers, and their relationships in C++ so that extending a new event source is straightforward.

The complete article of this framework (a.k.a. the GED library) was published in 'C/C++ Users Journal October, 2005' and is available here.

Build and Run the sample code

cd src

make

./time_event

About

A framework for event-driven development

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors