00001 /* AbiSource Program Utilities 00002 * Copyright (C) 1998 AbiSource, Inc. 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (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, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 * 02110-1301 USA. 00018 */ 00019 00020 00021 00022 #ifndef UT_TIMER_H 00023 #define UT_TIMER_H 00024 00025 /* pre-emptive dismissal; ut_types.h is needed by just about everything, 00026 * so even if it's commented out in-file that's still a lot of work for 00027 * the preprocessor to do... 00028 */ 00029 #ifndef UT_TYPES_H 00030 #include "ut_types.h" 00031 #endif 00032 #include "ut_vector.h" 00033 #include "ut_worker.h" 00034 00035 class GR_Graphics; 00036 00037 // simple backwards-compatible definition 00038 typedef UT_WorkerCallback UT_TimerCallback; 00039 00040 /* 00041 UT_Timer is an abstract class which encapsulates the platform-specific 00042 details for managing timers. 00043 */ 00044 class ABI_EXPORT UT_Timer : public UT_Worker 00045 { 00046 public: 00047 virtual ~UT_Timer(); 00048 00049 virtual void setCallback(UT_WorkerCallback p); 00050 void setInstanceData(void*); 00051 00052 virtual UT_sint32 set(UT_uint32 iMilliseconds) = 0; /* set freq and start */ 00053 virtual void stop(void) = 0; /* suspend events */ 00054 virtual void start(void) = 0; /* resume events */ 00055 00056 void setIdentifier(UT_uint32); 00057 UT_uint32 getIdentifier(); 00058 00059 static UT_Timer* findTimer(UT_uint32 iIdentifier); 00060 00061 /* 00062 Note that the static_constructor is actually implemented in 00063 *platform* code, so that it can instantiate the appropriate 00064 platform-specific subclass. 00065 */ 00066 static UT_Timer* static_constructor(UT_WorkerCallback pCallback, void* pData); 00067 00068 protected: 00069 UT_Timer(); // should only be called from static_constructor() 00070 static UT_GenericVector<UT_Timer*> & _getVecTimers (); 00071 00072 private: 00073 UT_uint32 m_iIdentifier; 00074 }; 00075 00076 #endif /* UT_TIMER_H */