TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
EventProcessor Class Reference

#include <EventProcessor.h>

Public Member Functions

 EventProcessor ()
 
 ~EventProcessor ()
 
void Update (uint32 p_time)
 
void KillAllEvents (bool force)
 
void AddEvent (BasicEvent *Event, uint64 e_time, bool set_addtime=true)
 
uint64 CalculateTime (uint64 t_offset) const
 

Protected Attributes

uint64 m_time
 
EventList m_events
 
bool m_aborting
 

Constructor & Destructor Documentation

EventProcessor::EventProcessor ( )
22 {
23  m_time = 0;
24  m_aborting = false;
25 }
bool m_aborting
Definition: EventProcessor.h:71
uint64 m_time
Definition: EventProcessor.h:69
EventProcessor::~EventProcessor ( )
28 {
29  KillAllEvents(true);
30 }
void KillAllEvents(bool force)
Definition: EventProcessor.cpp:61

+ Here is the call graph for this function:

Member Function Documentation

void EventProcessor::AddEvent ( BasicEvent Event,
uint64  e_time,
bool  set_addtime = true 
)
89 {
90  if (set_addtime) Event->m_addTime = m_time;
91  Event->m_execTime = e_time;
92  m_events.insert(std::pair<uint64, BasicEvent*>(e_time, Event));
93 }
uint64 m_addTime
Definition: EventProcessor.h:52
EventList m_events
Definition: EventProcessor.h:70
uint64 m_time
Definition: EventProcessor.h:69
uint64 m_execTime
Definition: EventProcessor.h:53

+ Here is the caller graph for this function:

uint64 EventProcessor::CalculateTime ( uint64  t_offset) const
96 {
97  return(m_time + t_offset);
98 }
uint64 m_time
Definition: EventProcessor.h:69

+ Here is the caller graph for this function:

void EventProcessor::KillAllEvents ( bool  force)
62 {
63  // prevent event insertions
64  m_aborting = true;
65 
66  // first, abort all existing events
67  for (EventList::iterator i = m_events.begin(); i != m_events.end();)
68  {
69  EventList::iterator i_old = i;
70  ++i;
71 
72  i_old->second->to_Abort = true;
73  i_old->second->Abort(m_time);
74  if (force || i_old->second->IsDeletable())
75  {
76  delete i_old->second;
77 
78  if (!force) // need per-element cleanup
79  m_events.erase (i_old);
80  }
81  }
82 
83  // fast clear event list (in force case)
84  if (force)
85  m_events.clear();
86 }
EventList m_events
Definition: EventProcessor.h:70
bool m_aborting
Definition: EventProcessor.h:71
uint64 m_time
Definition: EventProcessor.h:69

+ Here is the caller graph for this function:

void EventProcessor::Update ( uint32  p_time)
33 {
34  // update time
35  m_time += p_time;
36 
37  // main event loop
38  EventList::iterator i;
39  while (((i = m_events.begin()) != m_events.end()) && i->first <= m_time)
40  {
41  // get and remove event from queue
42  BasicEvent* Event = i->second;
43  m_events.erase(i);
44 
45  if (!Event->to_Abort)
46  {
47  if (Event->Execute(m_time, p_time))
48  {
49  // completely destroy event if it is not re-added
50  delete Event;
51  }
52  }
53  else
54  {
55  Event->Abort(m_time);
56  delete Event;
57  }
58  }
59 }
bool to_Abort
Definition: EventProcessor.h:48
virtual void Abort(uint64)
Definition: EventProcessor.h:46
virtual bool Execute(uint64, uint32)
Definition: EventProcessor.h:42
Definition: EventProcessor.h:28
EventList m_events
Definition: EventProcessor.h:70
uint64 m_time
Definition: EventProcessor.h:69

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

bool EventProcessor::m_aborting
protected
EventList EventProcessor::m_events
protected
uint64 EventProcessor::m_time
protected

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