CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

timer.h

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 
00022 #include <stdarg.h>
00023 #include <stdio.h>
00024 #include "csextern.h"
00025 #include "array.h"
00026 #include "iutil/timer.h"
00027 
00028 struct iEvent;
00029 struct iObjectRegistry;
00030 struct iVirtualClock;
00031 struct iEventHandler;
00032 struct timerevent;
00033 
00038 class CS_CSUTIL_EXPORT csEventTimer : public iEventTimer
00039 {
00040 private:
00041   iObjectRegistry* object_reg;
00042   csArray<timerevent> timerevents;
00043   iEventHandler* handler;
00044   csRef<iVirtualClock> vc;
00045 
00046   size_t FindTimerEvent (iTimerEvent* ev);
00047 
00048   // Optimization: to prevent having to loop over all timer events
00049   // all the time we keep the minimum time needed before the first
00050   // event is triggered.
00051   int32 minimum_time;
00052   int32 accumulate_elapsed;
00053 
00054 public:
00055   csEventTimer (iObjectRegistry* object_reg);
00056   virtual ~csEventTimer ();
00057 
00058   bool HandleEvent (iEvent& e);
00059 
00060   SCF_DECLARE_IBASE;
00061 
00062   virtual void AddTimerEvent (iTimerEvent* ev, csTicks delay);
00063   virtual void RemoveTimerEvent (iTimerEvent* ev);
00064   virtual void RemoveAllTimerEvents ();
00065 
00071   static csPtr<iEventTimer> GetStandardTimer (iObjectRegistry* object_reg);
00072 };
00073 
00074 #endif // __CS_TIMER_H__
00075 

Generated for Crystal Space by doxygen 1.3.9.1