Skip to main content

DequeEventQueue Class

Concrete implementation of an EventQueue that uses a Deque as its underlying queue strategy. Adding and removing events follows a FIFO strategy. More...

Declaration

class helios::event::DequeEventQueue { ... }

Base class

classEventQueue

Abstract base class defining an interface for an EventQueue. More...

Public Member Functions Index

EventQueue &add (std::unique_ptr< const Event > event) override

Takes ownership of the event and moves it at the end of the queue. More...

EventQueue &addOrReplace (std::unique_ptr< const Event > event, const std::function< bool(const std::unique_ptr< const Event > &evt, const std::unique_ptr< const Event > &e)> &cmpFunc) override

Adds an event to the queue or replaces an existing one. More...

boolempty () const noexcept override

Returns true if the queue is empty, otherwise false. More...

std::unique_ptr< const Event >next () override

Retrieves and returns the next event from the front of the queue. More...

Private Member Attributes Index

std::deque< std::unique_ptr< const Event > >events

The internal deque for storing the events. More...

Description

Concrete implementation of an EventQueue that uses a Deque as its underlying queue strategy. Adding and removing events follows a FIFO strategy.

Definition at line 28 of file DequeEventQueue.ixx.

Public Member Functions

add()

EventQueue & helios::event::DequeEventQueue::add (std::unique_ptr< const Event > event)
inline virtual

Takes ownership of the event and moves it at the end of the queue.

Parameters
event

A unique_ptr to the event that should be managed by this class.

Returns

Definition at line 45 of file DequeEventQueue.ixx.

45 EventQueue& add(std::unique_ptr<const Event> event) override {
46 events.push_back(std::move(event));
47 return *this;
48 }

addOrReplace()

EventQueue & helios::event::DequeEventQueue::addOrReplace (std::unique_ptr< const Event > event, const std::function< bool(const std::unique_ptr< const Event > &evt, const std::unique_ptr< const Event > &e)> & cmpFunc)
inline virtual

Adds an event to the queue or replaces an existing one.

Parameters
event

A unique_ptr to the event this queue takes the ownership of.

cmpFunc

The cmp function that is used for looking up and replacing an existing event with the soecified event.

Returns

EventQueue

Definition at line 60 of file DequeEventQueue.ixx.

61 std::unique_ptr<const Event> event,
62 const std::function<bool(const std::unique_ptr<const Event>& evt,
63 const std::unique_ptr<const Event>& e)>& cmpFunc) override {
64
65 std::erase_if(events, [&event, cmpFunc](const std::unique_ptr<const Event>& e) {
66 return cmpFunc(event, e);
67 });
68 events.push_back(std::move(event));
69 return *this;
70 }

empty()

bool helios::event::DequeEventQueue::empty ()
inline nodiscard noexcept virtual

Returns true if the queue is empty, otherwise false.

Returns

True if the queue is empty, otherwise false.

Definition at line 78 of file DequeEventQueue.ixx.

78 [[nodiscard]] bool empty() const noexcept override {
79 return events.empty();
80 }

next()

std::unique_ptr< const Event > helios::event::DequeEventQueue::next ()
inline virtual

Retrieves and returns the next event from the front of the queue.

Returns

A unique_ptr to the next event in teh queue, i.e. from the front position of the queue.

Definition at line 89 of file DequeEventQueue.ixx.

89 std::unique_ptr<const Event> next() override {
90 if (events.empty()) {
91 return nullptr;
92 }
93
94 auto event = std::move(events.front());
95 events.pop_front();
96
97 return event;
98 }

Private Member Attributes

events

std::deque<std::unique_ptr<const Event> > helios::event::DequeEventQueue::events

The internal deque for storing the events.

Definition at line 34 of file DequeEventQueue.ixx.

34 std::deque<std::unique_ptr<const Event>> events;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.