Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
EventProcessor.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef __EVENTPROCESSOR_H
7#define __EVENTPROCESSOR_H
8
9#include "Define.h"
10
11#include <map>
12
13// Note. All times are in milliseconds here.
14
16{
17public:
18 BasicEvent() : m_addTime(0), m_execTime(0) { to_Abort = false; }
19 virtual ~BasicEvent() { } // override destructor to perform some actions on event removal
20
21 // this method executes when the event is triggered
22 // return false if event does not want to be deleted
23 // e_time is execution time, p_time is update interval
24 virtual bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { return true; }
25
26 virtual bool IsDeletable() const { return true; } // this event can be safely deleted
27
28 virtual void Abort(uint64 /*e_time*/) { } // this method executes when the event is aborted
29
30 bool to_Abort; // set by externals when the event is aborted, aborted events don't execute
31 // and get Abort call when deleted
32
33 // these can be used for time offset control
34 uint64 m_addTime; // time when the event was added to queue, filled by event handler
35 uint64 m_execTime; // planned time of next execution, filled by event handler
36};
37
38typedef std::multimap<uint64, BasicEvent*> EventList;
39
41{
42public:
43 EventProcessor() : m_time(0), m_aborting(false) { }
45
46 void Update(uint32 p_time);
47 void KillAllEvents(bool force);
48 void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true);
49 uint64 CalculateTime(uint64 t_offset) const;
50protected:
54};
55#endif
std::uint32_t uint32
Definition Define.h:77
std::uint64_t uint64
Definition Define.h:76
std::multimap< uint64, BasicEvent * > EventList
virtual void Abort(uint64)
virtual ~BasicEvent()
virtual bool IsDeletable() const
virtual bool Execute(uint64, uint32)
uint64 m_addTime
uint64 m_execTime
void AddEvent(BasicEvent *Event, uint64 e_time, bool set_addtime=true)
void KillAllEvents(bool force)
EventList m_events
uint64 CalculateTime(uint64 t_offset) const
void Update(uint32 p_time)