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< UniqueEventPtr > | Container |
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... | |
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.
typedef vector<UniqueEventPtr> kanzi::EventQueue::Container |
Event container type.
typedef function<ProcessingResult(InputEvent*)> kanzi::EventQueue::ProcessingFunction |
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.
it | The event queue container iterator to filter. |
|
explicit |
Creates an event queue instance.
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:
function | The function to process the queue events. |
void kanzi::EventQueue::push | ( | UniqueEventPtr | event | ) |
Pushes an event into the queue.
event | The 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.
bool kanzi::EventQueue::isEmpty | ( | ) | const |
Checks for empty queue.
void kanzi::EventQueue::swap | ( | EventQueue & | other | ) |
Swaps this event queue with the given one.
other | The 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.
other | The 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.
position | The iterator before which to move the content. |
event | The event to insert into the event queue. |
Container::iterator kanzi::EventQueue::move | ( | Container::iterator | position, |
Container & | container | ||
) |
Moves the container content into this queue before the given position.
position | The iterator before which to move the content. |
container | The container to move into the event queue. |
Container::iterator kanzi::EventQueue::remove | ( | Container::iterator | position | ) |
Removes the event at position from the event queue.
position | The iterator to the event to remove. |
|
inline |
Returns an iterator to the first event in the event queue.
|
inline |
Returns an iterator to the element following the last event in the event queue.
|
inline |
Returns an iterator to the first event in the event queue.
|
inline |
Returns an iterator to the element following the last event in the event queue.
void kanzi::EventQueue::applyFilter | ( | const FilterFunction & | filter | ) |
Applies the given filter over the event queue.
filter | The filter object applied over the events from the queue. |