00001 /* ==================================================== ======== ======= * 00002 * 00003 * utimer.hpp 00004 * Ubit Project 00005 * Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs 00006 * (C) 1999-2006 Eric Lecolinet / ENST Paris 00007 * 00008 * *********************************************************************** 00009 * COPYRIGHT NOTICE : 00010 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 00011 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 00012 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 00013 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 00014 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION. 00015 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS. 00016 * *********************************************************************** 00017 * ==================================================== [(c)Elc] ======= * 00018 * ==================================================== ======== ======= */ 00019 00020 #ifndef _utimer_hpp_ 00021 #define _utimer_hpp_ 00022 //pragma ident "@(#)utimer.hpp ubit:05.05.00" 00023 00024 extern "C" { 00025 struct timeval; 00026 } 00027 00028 #include <ubit/ubrick.hpp> 00029 namespace ubit { 00030 00031 /* ==================================================== ======== ======= */ 00050 class UTimer : public UBrick { 00051 public: 00052 UBIT_CLASS(UTimer,UBrick) 00053 00054 UTimer(); 00055 virtual ~UTimer(); 00056 00057 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00058 00059 virtual void onAction(UCall& callback); 00060 virtual void onTimeout(UCall& callback) {onAction(callback);} 00066 virtual void start(UTime delay, int ntimes = 0, bool auto_delete = true); 00079 virtual void stop(); 00085 int getDelay() const {return delay;} 00086 void setDelay(UTime); 00087 00088 bool isRunning() const {return is_running;} 00090 00091 // - impl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00092 00093 virtual void fireTimer(); 00094 00095 private: 00096 friend class UAppli; 00097 friend class UNatAppli; 00098 bool auto_delete, is_running; 00099 int firecount; 00100 UTime delay; 00101 #ifdef WITH_GDK 00102 unsigned int gid; 00103 #else 00104 struct timeval& timeout; 00105 #endif 00106 }; 00107 } 00108 #endif 00109 /* ==================================================== [TheEnd] ======= */ 00110 /* ==================================================== [(c)Elc] ======= */