TrinityCore
EventMap Class Reference

#include <EventMap.h>

Public Member Functions

 EventMap ()
 
Reset

Removes all scheduled events and resets time and phase.

void Reset ()
 
Update

Updates the timer of the event map.

Parameters
timeValue in ms to be added to time.
void Update (uint32 time)
 
void Update (Milliseconds time)
 
GetPhaseMask
Returns
Active phases as mask.
uint8 GetPhaseMask () const
 
Empty
Returns
True, if there are no events scheduled.
bool Empty () const
 
SetPhase

Sets the phase of the map (absolute).

Parameters
phasePhase which should be set. Values: 1 - 8. 0 resets phase.
void SetPhase (uint8 phase)
 
AddPhase

Activates the given phase (bitwise).

Parameters
phasePhase which should be activated. Values: 1 - 8
void AddPhase (uint8 phase)
 
RemovePhase

Deactivates the given phase (bitwise).

Parameters
phasePhase which should be deactivated. Values: 1 - 8.
void RemovePhase (uint8 phase)
 
ScheduleEvent

Schedules a new event. An existing event is not canceled.

Parameters
eventIdThe id of the new event.
minTimeThe minimum time until the event occurs as std::chrono type.
maxTimeThe maximum time until the event occurs as std::chrono type.
groupThe group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
phaseThe phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.
void ScheduleEvent (uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
 
void ScheduleEvent (uint32 eventId, Milliseconds minTime, Milliseconds maxTime, uint32 group=0, uint8 phase=0)
 
RescheduleEvent

Cancels the given event and reschedules it.

Parameters
eventIdThe id of the event.
minTimeThe minimum time until the event occurs as std::chrono type.
maxTimeThe maximum time until the event occurs as std::chrono type.
groupThe group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
phaseThe phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.
void RescheduleEvent (uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
 
void RescheduleEvent (uint32 eventId, Milliseconds minTime, Milliseconds maxTime, uint32 group=0, uint8 phase=0)
 
RepeatEvent

Repeats the most recently executed event.

Parameters
minTimeThe minimum time until the event occurs as std::chrono type.
maxTimeThe maximum time until the event occurs as std::chrono type.
void Repeat (Milliseconds time)
 
void Repeat (Milliseconds minTime, Milliseconds maxTime)
 
ExecuteEvent

Returns the next event to be executed and removes it from map.

Returns
Id of the event to execute.
uint32 ExecuteEvent ()
 
DelayEvents

Delay all events of the same group.

Parameters
delayAmount of delay as std::chrono type.
groupGroup of the events.
void DelayEvents (Milliseconds delay)
 
void DelayEvents (Milliseconds delay, uint32 group)
 
CancelEvent

Cancels all events of the specified id.

Parameters
eventIdEvent id to cancel.
void CancelEvent (uint32 eventId)
 
CancelEventGroup

Cancel events belonging to specified group.

Parameters
groupGroup to cancel.
void CancelEventGroup (uint32 group)
 
IsInPhase

Returns whether event map is in specified phase or not.

Parameters
phaseWanted phase.
Returns
True, if phase of event map contains specified phase.
bool IsInPhase (uint8 phase) const
 
GetTimeUntilEvent

Returns time as std::chrono type until next event.

Parameters
eventIdof the event.
Returns
Time of next event. If event is not scheduled returns Milliseconds::max()
Milliseconds GetTimeUntilEvent (uint32 eventId) const
 
ScheduleNextFromSeries

Schedules specified event with next timer from series

Parameters
fullevent data, including group and phase
void ScheduleNextFromSeries (uint32 eventData)
 
ScheduleEventSeries

Schedules specified event with first value of the series and then requeues with the next

Parameters
eventIdof the event.
timeSeriesspecifying the times the event should be automatically scheduled after each trigger (first value is initial schedule)
void ScheduleEventSeries (uint32 eventId, uint8 group, uint8 phase, std::initializer_list< Milliseconds > const &timeSeries)
 
void ScheduleEventSeries (uint32 eventId, std::initializer_list< Milliseconds > const &series)
 

Private Types

typedef std::multimap< TimePoint, uint32EventStore
 
typedef std::map< uint32, std::queue< Milliseconds > > EventSeriesStore
 

Private Attributes

_time

Internal timer.

This does not represent the real date/time value. It's more like a stopwatch: It can run, it can be stopped, it can be resetted and so on. Events occur when this timer has reached their time value. Its value is changed in the Update method.

TimePoint _time
 
_phase

Phase mask of the event map.

Contains the phases the event map is in. Multiple phases from 1 to 8 can be set with SetPhase or AddPhase. RemovePhase deactives a phase.

uint8 _phase
 
_eventMap

Internal event storage map. Contains the scheduled events.

See typedef at the beginning of the class for more details.

EventStore _eventMap
 
_lastEvent

Stores information on the most recently executed event

uint32 _lastEvent
 
_timerSeries

Stores information about time series which requeue itself until series is empty

EventSeriesStore _timerSeries
 

Detailed Description

Definition at line 26 of file EventMap.h.

Member Typedef Documentation

◆ EventSeriesStore

typedef std::map<uint32 , std::queue<Milliseconds> > EventMap::EventSeriesStore
private

Definition at line 40 of file EventMap.h.

◆ EventStore

typedef std::multimap<TimePoint, uint32> EventMap::EventStore
private

Internal storage type. Key: Time as TimePoint when the event should occur. Value: The event data as uint32.

Structure of event data:

  • Bit 0 - 15: Event Id.
  • Bit 16 - 23: Group
  • Bit 24 - 31: Phase
  • Pattern: 0xPPGGEEEE

Definition at line 39 of file EventMap.h.

Constructor & Destructor Documentation

◆ EventMap()

EventMap::EventMap ( )
inline

Definition at line 43 of file EventMap.h.

Member Function Documentation

◆ AddPhase()

void EventMap::AddPhase ( uint8  phase)
inline

Definition at line 101 of file EventMap.h.

◆ CancelEvent()

void EventMap::CancelEvent ( uint32  eventId)

Definition at line 131 of file EventMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CancelEventGroup()

void EventMap::CancelEventGroup ( uint32  group)

Definition at line 153 of file EventMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DelayEvents() [1/2]

void EventMap::DelayEvents ( Milliseconds  delay)

Definition at line 96 of file EventMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DelayEvents() [2/2]

void EventMap::DelayEvents ( Milliseconds  delay,
uint32  group 
)

Definition at line 110 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ Empty()

bool EventMap::Empty ( ) const
inline

Definition at line 84 of file EventMap.h.

+ Here is the caller graph for this function:

◆ ExecuteEvent()

uint32 EventMap::ExecuteEvent ( )

Definition at line 73 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ GetPhaseMask()

uint8 EventMap::GetPhaseMask ( ) const
inline

Definition at line 75 of file EventMap.h.

+ Here is the caller graph for this function:

◆ GetTimeUntilEvent()

Milliseconds EventMap::GetTimeUntilEvent ( uint32  eventId) const

Definition at line 175 of file EventMap.cpp.

+ Here is the caller graph for this function:

◆ IsInPhase()

bool EventMap::IsInPhase ( uint8  phase) const
inline

Definition at line 217 of file EventMap.h.

+ Here is the caller graph for this function:

◆ RemovePhase()

void EventMap::RemovePhase ( uint8  phase)
inline

Definition at line 112 of file EventMap.h.

◆ Repeat() [1/2]

void EventMap::Repeat ( Milliseconds  minTime,
Milliseconds  maxTime 
)

Definition at line 68 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ Repeat() [2/2]

void EventMap::Repeat ( Milliseconds  time)

Definition at line 63 of file EventMap.cpp.

◆ RescheduleEvent() [1/2]

void EventMap::RescheduleEvent ( uint32  eventId,
Milliseconds  minTime,
Milliseconds  maxTime,
uint32  group = 0,
uint8  phase = 0 
)

Definition at line 58 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ RescheduleEvent() [2/2]

void EventMap::RescheduleEvent ( uint32  eventId,
Milliseconds  time,
uint32  group = 0,
uint8  phase = 0 
)

Definition at line 52 of file EventMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Reset()

void EventMap::Reset ( )

Definition at line 21 of file EventMap.cpp.

◆ ScheduleEvent() [1/2]

void EventMap::ScheduleEvent ( uint32  eventId,
Milliseconds  minTime,
Milliseconds  maxTime,
uint32  group = 0,
uint8  phase = 0 
)

Definition at line 47 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ ScheduleEvent() [2/2]

void EventMap::ScheduleEvent ( uint32  eventId,
Milliseconds  time,
uint32  group = 0,
uint8  phase = 0 
)

Definition at line 36 of file EventMap.cpp.

◆ ScheduleEventSeries() [1/2]

void EventMap::ScheduleEventSeries ( uint32  eventId,
std::initializer_list< Milliseconds > const &  series 
)

Definition at line 216 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ ScheduleEventSeries() [2/2]

void EventMap::ScheduleEventSeries ( uint32  eventId,
uint8  group,
uint8  phase,
std::initializer_list< Milliseconds > const &  timeSeries 
)

Definition at line 202 of file EventMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ScheduleNextFromSeries()

void EventMap::ScheduleNextFromSeries ( uint32  eventData)

Definition at line 184 of file EventMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetPhase()

void EventMap::SetPhase ( uint8  phase)

Definition at line 28 of file EventMap.cpp.

◆ Update() [1/2]

void EventMap::Update ( Milliseconds  time)
inline

Definition at line 66 of file EventMap.h.

◆ Update() [2/2]

void EventMap::Update ( uint32  time)
inline

Definition at line 56 of file EventMap.h.

+ Here is the call graph for this function:

Member Data Documentation

◆ _eventMap

EventStore EventMap::_eventMap
private

Definition at line 285 of file EventMap.h.

◆ _lastEvent

uint32 EventMap::_lastEvent
private

Definition at line 291 of file EventMap.h.

◆ _phase

uint8 EventMap::_phase
private

Definition at line 276 of file EventMap.h.

◆ _time

TimePoint EventMap::_time
private

Definition at line 266 of file EventMap.h.

◆ _timerSeries

EventSeriesStore EventMap::_timerSeries
private

Definition at line 297 of file EventMap.h.


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