eVaf
eVaf::Common::iEventQueue Class Referenceabstract

The eVaf event queue interface. More...

#include <Common/ieventqueue.h>

Public Member Functions

virtual void broadcastEvent (Event *event)=0
 Sends the event to all the subscribers. More...
 
 iEventQueue ()
 Interface constructor. More...
 
virtual uint queryEvent (QString const &name) const =0
 Queries for an existing event. More...
 
virtual uint registerEvent (QString const &name)=0
 Registers an event. More...
 
virtual uint subscribeEvent (uint id, QObject *obj)=0
 Subscribes to an event. More...
 
virtual void unregisterEvent (uint id)=0
 Unregisters an event. More...
 
virtual void unsubscribeEvent (uint id, QObject *obj)=0
 Unsubscribes from an event. More...
 
virtual ~iEventQueue ()
 Empty virtual destructor. More...
 

Static Public Member Functions

static iEventQueueinstance ()
 Returns the instance of the iEventQueue interface. More...
 

Detailed Description

The eVaf event queue interface.

#include <Common/iEventQueue>

This interface is used to work with eVaf events. Functions in this interface register new events, subscribe to existing events and broadcast events to the rest of the application. Events are implemented using the Qt event loop.

Definition at line 41 of file ieventqueue.h.

Constructor & Destructor Documentation

eVaf::Common::iEventQueue::iEventQueue ( )
inline

Interface constructor.

Definition at line 48 of file ieventqueue.h.

virtual eVaf::Common::iEventQueue::~iEventQueue ( )
inlinevirtual

Empty virtual destructor.

Definition at line 51 of file ieventqueue.h.

Member Function Documentation

virtual void eVaf::Common::iEventQueue::broadcastEvent ( Event event)
pure virtual

Sends the event to all the subscribers.

Parameters
eventThe event object

This function sends the event to all the subscribers. The event object is destroyed when the event loop is finished for this event.

The event object shall be allocated in the heap.

Implemented in eVaf::Common::Internal::EventQueue.

static iEventQueue* eVaf::Common::iEventQueue::instance ( )
static

Returns the instance of the iEventQueue interface.

Returns
The iEventQueue interface
virtual uint eVaf::Common::iEventQueue::queryEvent ( QString const &  name) const
pure virtual

Queries for an existing event.

Parameters
nameName of the event
Returns
The ID of the event or 0 if not found

This function returns the ID of the event or zero if no such event is found.

Implemented in eVaf::Common::Internal::EventQueue.

virtual uint eVaf::Common::iEventQueue::registerEvent ( QString const &  name)
pure virtual

Registers an event.

Parameters
nameName of the event
Returns
Unique ID of the event

This function registers an event and returns a unique ID for the event. The event ID value is always greater than zero.

If an event with the given name already exists, then returns the event ID for the existing event.

Implemented in eVaf::Common::Internal::EventQueue.

virtual uint eVaf::Common::iEventQueue::subscribeEvent ( uint  id,
QObject obj 
)
pure virtual

Subscribes to an event.

Parameters
idThe ID of the event (can be zero)
objThe subscriber object
Returns
The ID of the event; or zero if failed to subscribe

This function subscribes to an event identified by the ID value. Every object that wants to receive specific events, needs to subscribe to them.

The id parameter can be zero and the following example code is correct even when the event called "my-event" does not exist. The value of myEventId will be set to zero if the event does not exist.

int myEventId = iEventQueue::instance()->subscribeEvent(iEventQueue::instance()->queryEvent("my-event"), this);

Implemented in eVaf::Common::Internal::EventQueue.

virtual void eVaf::Common::iEventQueue::unregisterEvent ( uint  id)
pure virtual

Unregisters an event.

Parameters
idThe ID of the event

This function removes an event. It also unsubscribes all the subscribers from this event.

Implemented in eVaf::Common::Internal::EventQueue.

virtual void eVaf::Common::iEventQueue::unsubscribeEvent ( uint  id,
QObject obj 
)
pure virtual

Unsubscribes from an event.

Parameters
idThe ID of the event (can be zero)
objThe subscriber object

This function removes the subscriber object from the list of subscribers for the given event identified by the event ID value. After this function call the subscriber does no more receive these events.

Implemented in eVaf::Common::Internal::EventQueue.


The documentation for this class was generated from the following file: