The **EventHandler** class, in additions to EventHandlerBase, also extends the ActiveObejct interface.
The **EventHandler** class, in addition to EventHandlerBase, also extends the ActiveObejct interface.
In fact an EventHandler is a special ActiveObject that periodically checks a synchronized queue of events. When new events are present they can be removed from the queue and processed.
In fact an EventHandler is a special ActiveObject that periodically checks a synchronized queue of events. When new events are present they can be removed from the queue and processed.
### Methods
### Methods
EventHadler offers two main methods:
EventHadler offers two main methods:
-**virtual void postEvent(const Event& ev)**: overridden from EventHandlerBase, it enqueues the event passed as a parameters.
-**virtual void postEvent(const Event& ev)**: overridden from EventHandlerBase, it enqueues the event passed as a parameters.
-**virtual void handleEvent(const Event& ev)**: protected method that is periodically called in the active objects thread. In fact in the *run()* method, whenever an event is present in the queue, it gets removed and the *handleEvent* method is called. The *handleEvent* method has to be overridden and implemented by any class that extends EventHandler.
-**virtual void handleEvent(const Event& ev)**: protected method that is periodically called in the active objects thread. In fact in the *run()* method, whenever an event is present in the queue, it gets removed and the *handleEvent* method is called. The *handleEvent* method has to be overridden and implemented by any class that extends EventHandler.
You can find the complete definition of EventHandler in `src/shared/events/EventHandler.h`.
You can find the complete implementation of EventHandler in `src/shared/events/EventHandler.h`.
### Example
### Example
This example shows how to define a very simple custom EventHandler.
This example shows how to define a very simple custom EventHandler.