Kanzi  3.9.7
Kanzi Engine API
kanzi::EventQueue Class Reference

The EventQueue class implements a queue of Kanzi input events gathered by EventSource instances. More...

#include <kanzi/core.ui/platform/input/common/event_queue.hpp>

Public Types

typedef vector< UniqueEventPtrContainer
 Event container type. More...
 
using FilterFunction = function< Container::iterator(Container::iterator it)>
 Filter function type to pass to the applyFilter() method. More...
 
typedef function< ProcessingResult(InputEvent *)> ProcessingFunction
 The event processing function type passed to processEvents() method. More...
 
enum  ProcessingResult { Continue, Stop }
 Specifies the results values of the event processing. More...
 

Public Member Functions

void append (EventQueue &other)
 Moves the content of other event queue into this queue, and clears the other queue. More...
 
void applyFilter (const FilterFunction &filter)
 Applies the given filter over the event queue. More...
 
Container::iterator begin ()
 Returns an iterator to the first event in the event queue. More...
 
Container::const_iterator cbegin () const
 Returns an iterator to the first event in the event queue. More...
 
Container::const_iterator cend () const
 Returns an iterator to the element following the last event in the event queue. More...
 
void clear ()
 Clears the event queue. More...
 
Container::iterator end ()
 Returns an iterator to the element following the last event in the event queue. More...
 
 EventQueue ()
 Creates an event queue instance. More...
 
size_t getEventCount () const
 Returns the number or events in the queue. More...
 
Container::iterator insert (Container::iterator position, UniqueEventPtr &&event)
 Inserts the event into this queue before the given position. More...
 
bool isEmpty () const
 Checks for empty queue. More...
 
Container::iterator move (Container::iterator position, Container &container)
 Moves the container content into this queue before the given position. More...
 
void processEvents (ProcessingFunction function)
 The method loops through the queue events and passes each event to the given function for processing. More...
 
void push (UniqueEventPtr event)
 Pushes an event into the queue. More...
 
Container::iterator remove (Container::iterator position)
 Removes the event at position from the event queue. More...
 
void swap (EventQueue &other)
 Swaps this event queue with the given one. More...
 

Detailed Description

The EventQueue class implements a queue of Kanzi input events gathered by EventSource instances.

Events are low-level Kanzi messages translated from the host operating system, and incorporate input, application, and window management events. Different parts of Kanzi handle these events immediately, whereas other elements, such as InputManager, forward them to input manipulators, which in turn transform them into Kanzi messages.

You can add events to the queue only by using the push() method. The EventQueue takes ownership of the event.

Once the queue events are handled, you can remove them from the queue with the clear() method. It is recommended to clear the queue before or after swapping the queue.

Member Typedef Documentation

Event container type.

The event processing function type passed to processEvents() method.

The function expects an InputEvent as argument and returns the result of the event processing.

using kanzi::EventQueue::FilterFunction = function<Container::iterator(Container::iterator it)>

Filter function type to pass to the applyFilter() method.

Parameters
itThe event queue container iterator to filter.
Returns
The event queue container iterator with which to continue. To skip an event, return the next iterator. To remove an event, call the remove() method with the iterator and return the iterator returned by the remove() method. To insert events in front of or after the processed event, call the move() method, and return the iterator relative to the iterator returned by the move() method. Use the prepend() or prependAndAdvance() functions to position the iterators to the processed event or after the processed event.
Since
Kanzi 3.9.0

Member Enumeration Documentation

Specifies the results values of the event processing.

Enumerator
Continue 

Continue the event processing with the next event in the queue.

Stop 

Exit the event processing loop.

Constructor & Destructor Documentation

kanzi::EventQueue::EventQueue ( )
explicit

Creates an event queue instance.

Member Function Documentation

void kanzi::EventQueue::processEvents ( ProcessingFunction  function)

The method loops through the queue events and passes each event to the given function for processing.

The return value of the function drives the event processing in this way:

  • EventQueue keeps processing the events for as long as Continue is returned.
  • The event processing stops when Stop is returned.
    Parameters
    functionThe function to process the queue events.
void kanzi::EventQueue::push ( UniqueEventPtr  event)

Pushes an event into the queue.

Parameters
eventThe event to push into the queue.
void kanzi::EventQueue::clear ( )

Clears the event queue.

size_t kanzi::EventQueue::getEventCount ( ) const

Returns the number or events in the queue.

Returns
The number of events in the queue.
bool kanzi::EventQueue::isEmpty ( ) const

Checks for empty queue.

Returns
true if the queue is empty.
void kanzi::EventQueue::swap ( EventQueue other)

Swaps this event queue with the given one.

Parameters
otherThe event queue with which to swap the events.
void kanzi::EventQueue::append ( EventQueue other)

Moves the content of other event queue into this queue, and clears the other queue.

Parameters
otherThe event queue to move into this event queue.
Container::iterator kanzi::EventQueue::insert ( Container::iterator  position,
UniqueEventPtr &&  event 
)

Inserts the event into this queue before the given position.

Parameters
positionThe iterator before which to move the content.
eventThe event to insert into the event queue.
Returns
The iterator pointing to the inserted event.
Since
Kanzi 3.9.0
Container::iterator kanzi::EventQueue::move ( Container::iterator  position,
Container container 
)

Moves the container content into this queue before the given position.

Parameters
positionThe iterator before which to move the content.
containerThe container to move into the event queue.
Returns
The iterator pointing to the first moved event. If the source is empty, returns position.
Since
Kanzi 3.9.0
Container::iterator kanzi::EventQueue::remove ( Container::iterator  position)

Removes the event at position from the event queue.

Parameters
positionThe iterator to the event to remove.
Returns
The iterator following the removed event.
Since
Kanzi 3.9.0
Container::iterator kanzi::EventQueue::begin ( )
inline

Returns an iterator to the first event in the event queue.

Returns
The iterator to the first event. If the event queue is empty, the returned iterator is the same as the iterator returned by end().
Since
Kanzi 3.9.0
Container::iterator kanzi::EventQueue::end ( )
inline

Returns an iterator to the element following the last event in the event queue.

Returns
The iterator to the element following the last event.
Since
Kanzi 3.9.0
Container::const_iterator kanzi::EventQueue::cbegin ( ) const
inline

Returns an iterator to the first event in the event queue.

Returns
The iterator to the first event. If the event queue is empty, the returned iterator is the same as the iterator returned by end().
Since
Kanzi 3.9.0
Container::const_iterator kanzi::EventQueue::cend ( ) const
inline

Returns an iterator to the element following the last event in the event queue.

Returns
The iterator to the element following the last event.
Since
Kanzi 3.9.0
void kanzi::EventQueue::applyFilter ( const FilterFunction filter)

Applies the given filter over the event queue.

Parameters
filterThe filter object applied over the events from the queue.
Since
Kanzi 3.9.0

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