WSF
WsfEventManager Class Reference

#include <WsfEventManager.hpp>

Inheritance diagram for WsfEventManager:

Classes

struct  Event

Public Member Functions

 WsfEventManager (WsfSimulation &aSimulation)
 WsfEventManager (const WsfEventManager &aSrc)=delete
WsfEventManageroperator= (const WsfEventManager &aRhs)=delete
 WsfEventManager (WsfEventManager &&)=default
WsfEventManageroperator= (WsfEventManager &&)=default
virtual ~WsfEventManager ()=default
virtual void AddEvent (std::unique_ptr< WsfEvent > aEventPtr)
 Add an event to the event queue.
virtual WsfEventPeekEvent () const
 Get, but do not remove, the next event that should be dispatched.
virtual std::unique_ptr< WsfEventPopEvent ()
 Get and remove the next event that should be dispatched.
virtual void Reset ()
 Reset the event queue back to an empty state.

Protected Attributes

std::recursive_mutex mMutex {}

Detailed Description

A manager for a time-ordered queue (strict weak ordering) of WsfEvent objects

This class is used by WsfSimulation to implement an event queue. It could also be used by other classes that want to retain their own time-ordered event queues.

The event manager operates as a queue with ordering primarily dictated by the indicated simulation execution time of the event. Events occurring at the same discrete time are further ordered by a priority value. In most use cases, the priority value is default assigned such that all events added to the queue at the same time observe a first-in-first-out behavior. However, priority may be modified to change the relative ordering of same-time events.

Constructor & Destructor Documentation

◆ WsfEventManager() [1/3]

◆ WsfEventManager() [2/3]

WsfEventManager::WsfEventManager ( const WsfEventManager & aSrc)
delete

References WsfEventManager().

◆ WsfEventManager() [3/3]

WsfEventManager::WsfEventManager ( WsfEventManager && )
default

References WsfEventManager().

◆ ~WsfEventManager()

virtual WsfEventManager::~WsfEventManager ( )
virtualdefault

Member Function Documentation

◆ AddEvent()

void WsfEventManager::AddEvent ( std::unique_ptr< WsfEvent > aEventPtr)
virtual

Add an event to the event queue.

Add an event to the event queue.

Parameters
aEventPtrPointer to the event to be added to the queue. The WsfEvent::GetTime method will be used to determine when the event should be dispatched. The event manager becomes the owner of the event.

Events added are ordered by simulation time. In the case of events with the same simulation time, events are then ordered by priority. Events with the same simulation time and priority are executed in a first-in-first-out manner via an incrementing counter.

References mMutex.

Referenced by ~WsfEventManager().

◆ operator=() [1/2]

WsfEventManager & WsfEventManager::operator= ( const WsfEventManager & aRhs)
delete

References WsfEventManager().

◆ operator=() [2/2]

WsfEventManager & WsfEventManager::operator= ( WsfEventManager && )
default

References WsfEventManager().

◆ PeekEvent()

WsfEvent * WsfEventManager::PeekEvent ( ) const
virtual

Get, but do not remove, the next event that should be dispatched.

Get, but do not remove, the next event that should be dispatched

The next event is the one with the lowest time value. In cases of equivalent time value, the next event is the one with the lowest priority. In cases of equivalent time and priority, the next event is the one that was added to the event manager first.

Returns
A non-owning pointer to the next event or nullptr if there is no next event.

References mMutex.

Referenced by ~WsfEventManager().

◆ PopEvent()

std::unique_ptr< WsfEvent > WsfEventManager::PopEvent ( )
virtual

Get and remove the next event that should be dispatched.

Get and remove the next event that should be dispatched

The next event is the one with the lowest time value. In cases of equivalent time value, the next event is the one with the lowest priority. In cases of equivalent time and priority, the next event is the one that was added to the event manager first.

Returns
The pointer to the next event or nullptr if there is no next event. Caller assumes ownership of the event.

Reimplemented in WsfStableOrderEventManager.

References mMutex.

Referenced by ~WsfEventManager().

◆ Reset()

void WsfEventManager::Reset ( )
virtual

Reset the event queue back to an empty state.

Reimplemented in WsfStableOrderEventManager.

References mMutex.

Referenced by ~WsfEventManager(), and WsfStableOrderEventManager::~WsfStableOrderEventManager().

Member Data Documentation

◆ mMutex


The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved