CrystalSpace

Public API Reference

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

csws/cstimer.h

Go to the documentation of this file.
00001 /*
00002     Crystal Space Windowing System: timer class
00003     Copyright (C) 1998,1999 by Andrew Zabolotny <bit@eltech.ru>
00004     Copyright (C) 2002 by Mat Sutcliffe <oktal@gmx.co.uk>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public
00017     License along with this library; if not, write to the Free
00018     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #ifndef __CS_CSTIMER_H__
00022 #define __CS_CSTIMER_H__
00023 
00024 #include "cscomp.h"
00025 
00034 
00035 enum
00036 {
00045   cscmdTimerPulse = 0x00000300
00046 };
00047 
00048 #include "iutil/event.h"
00049 #include "csutil/csevent.h"
00050 struct iEventHandler;
00051 struct iEventQueue;
00052 struct iEventOutlet;
00053 
00060 class csTimer : public csComponent
00061 {
00063   unsigned timeout;
00065   unsigned start;
00067   unsigned pausetime;
00069   bool Stopped;
00070 
00071   iEventHandler *eventh;
00072   iEventOutlet *evento;
00073   void Init (unsigned iPeriod);
00074   struct csTimerEvent : public csEvent
00075   {
00076     SCF_DECLARE_IBASE;
00077     csTimerEvent () { SCF_CONSTRUCT_IBASE(0); }
00078     virtual ~csTimerEvent() { SCF_DESTRUCT_IBASE(); }
00079   } TimerEvent;
00080   
00081 public:
00083   csTimer (csComponent *iParent, unsigned iPeriod);
00084   csTimer (iEventHandler *iParent, unsigned iPeriod, void *iInfo = 0);
00085   csTimer (iEventQueue *iParent, unsigned iPeriod, void *iInfo = 0);
00086 
00088   virtual bool HandleEvent (iEvent &Event);
00089 
00091   void Stop ();
00092 
00094   void Restart ();
00095 
00097   void Pause (unsigned iPause);
00098 
00100   bool Running () { return !Stopped; }
00101 };
00102 
00105 #endif // __CS_CSTIMER_H__

Generated for Crystal Space by doxygen 1.2.18