kick
/Users/morten/Programmering/cpp/kick/src/kick/core/event_queue.h
00001 //
00002 // Created by Morten Nobel-Jørgensen on 27/10/14.
00003 //
00004 
00005 
00006 #pragma once
00007 
00008 #include <functional>
00009 #include <vector>
00010 
00011 namespace kick {
00012 
00013     struct EventQueueEntry {
00014         std::function<void(int)> fn;
00015         float timeStart;
00016         float timeEnd;
00017         int eventid;
00018         bool cancelled = false;
00019         EventQueueEntry(std::function<void(int)>&& fn, float timeStart, float timeEnd, int eventid);
00020     };
00021 
00022     class EventQueue {
00023     public:
00024         EventQueue(){}
00025         int scheduleEvent(std::function<void(int)>&& fn, float timeStart = 0, float timeEnd = 0);
00026         bool cancelEvent(int eventid);
00027         void run();
00028     private:
00029         std::vector<EventQueueEntry> queue;
00030         std::vector<EventQueueEntry> updatingQueue;
00031         int queueCounter = 0;
00032         bool updating = false;
00033         EventQueue(const EventQueue&) = delete;
00034         EventQueue(EventQueue&&) = delete;
00035     };
00036 }
00037 
00038 
 All Classes Functions Variables