src/scripting/time_scheduler.hpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HEADER_SUPERTUX_SCRIPTING_TIME_SCHEDULER_HPP
00018 #define HEADER_SUPERTUX_SCRIPTING_TIME_SCHEDULER_HPP
00019 
00020 #include <vector>
00021 
00022 namespace scripting {
00023 
00028 class TimeScheduler
00029 {
00030 public:
00031   TimeScheduler();
00032   virtual ~TimeScheduler();
00033 
00034   void update(float time);
00035   void schedule_thread(HSQUIRRELVM vm, float time);
00036 
00037   static TimeScheduler* instance;
00038 
00039 private:
00040   struct ScheduleEntry {
00042     HSQOBJECT thread_ref;
00044     float wakeup_time;
00045 
00046     bool operator<(const ScheduleEntry& other) const
00047     {
00048       // we need the smallest value on top
00049       return wakeup_time > other.wakeup_time;
00050     }
00051   };
00052 
00053   typedef std::vector<ScheduleEntry> ScheduleHeap;
00054   ScheduleHeap schedule;
00055 };
00056 
00057 }
00058 
00059 #endif
00060 
00061 /* EOF */

Generated on Mon Jun 9 03:38:21 2014 for SuperTux by  doxygen 1.5.1