csutil/timer.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2003 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library 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 GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_TIMER_H__ 00020 #define __CS_TIMER_H__ 00021 00026 #include <stdarg.h> 00027 #include <stdio.h> 00028 #include "csextern.h" 00029 #include "csutil/array.h" 00030 #include "csutil/scf_implementation.h" 00031 #include "iutil/timer.h" 00032 #include "iutil/eventnames.h" 00033 00034 struct iEvent; 00035 struct iObjectRegistry; 00036 struct iVirtualClock; 00037 struct iEventHandler; 00038 struct timerevent; 00039 00044 class CS_CRYSTALSPACE_EXPORT csEventTimer : 00045 public scfImplementation1<csEventTimer, iEventTimer> 00046 { 00047 private: 00048 iObjectRegistry* object_reg; 00049 csEventID FinalProcess; 00050 csArray<timerevent> timerevents; 00051 iEventHandler* handler; 00052 csRef<iVirtualClock> vc; 00053 00054 size_t FindTimerEvent (iTimerEvent* ev); 00055 00056 // Optimization: to prevent having to loop over all timer events 00057 // all the time we keep the minimum time needed before the first 00058 // event is triggered. 00059 int32 minimum_time; 00060 int32 accumulate_elapsed; 00061 00062 public: 00063 csEventTimer (iObjectRegistry* object_reg); 00064 virtual ~csEventTimer (); 00065 00066 bool HandleEvent (iEvent& e); 00067 00068 virtual void AddTimerEvent (iTimerEvent* ev, csTicks delay); 00069 virtual void RemoveTimerEvent (iTimerEvent* ev); 00070 virtual void RemoveAllTimerEvents (); 00071 00072 virtual size_t GetEventCount () const { return timerevents.Length (); } 00073 virtual csTicks GetTimeLeft (size_t idx) const; 00074 00080 static csPtr<iEventTimer> GetStandardTimer (iObjectRegistry* object_reg); 00081 }; 00082 00083 #endif // __CS_TIMER_H__ 00084
Generated for Crystal Space by doxygen 1.4.7