Home | C-Bits Package Documentation | Project Page |
00001 /* ==================================================================== 00002 * The CBITS Software License, Version 1.0 00003 * 00004 * Copyright (c) 2002-2003 Bruce Lowery 00005 * All rights reserved 00006 * 00007 * Redistribution and use of this software, in source and binary forms, 00008 * with or without modification, are permitted provided that the above 00009 * copyright notice, this paragraph, and the following paragraph are 00010 * retained in each source code file. 00011 * 00012 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00013 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00014 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00015 * DISCLAIMED. IN NO EVENT SHALL BRUCE LOWERY OR OTHER CONTRIBUTORS 00016 * TO THE CBITS LIBRARY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00017 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00018 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00019 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00020 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00021 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00022 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00023 * SUCH DAMAGE. 00024 * ==================================================================== 00025 */ 00026 #ifndef __CALLBACK_TIMER_H__ 00027 #define __CALLBACK_TIMER_H__ 00028 00029 #include <cbits/Runnable.h> 00030 #include <cbits/Thread.h> 00031 #include <cbits/CallbackTimerListener.h> 00032 00033 #ifdef BUILD_DLL 00034 #define EXPORT __declspec(dllexport) 00035 #else 00036 #define EXPORT 00037 #endif 00038 00039 00040 namespace cbits 00041 { 00042 00043 00074 class EXPORT CallbackTimer : public virtual Runnable 00075 { 00076 public: 00077 00081 enum Type 00082 { 00083 SINGLE = 1, 00084 PERIODIC = 2 00085 }; 00086 00098 static CallbackTimer* create 00099 ( 00100 const Type t, 00101 const long tm, 00102 CallbackTimerListener& cl 00103 ); 00104 00111 virtual ~CallbackTimer(); 00112 00113 00120 const bool start(); 00121 00122 00129 const bool stop(); 00130 00131 00135 virtual void run(); 00136 00137 00141 const bool isStopped() const; 00142 00143 00148 const Thread * const getThread() const { return _timer; } 00149 00150 00151 protected: 00152 00159 CallbackTimer 00160 ( 00161 const Type t, 00162 const long tm, 00163 CallbackTimerListener& cl 00164 ); 00165 00176 virtual const bool impl_lock_obj() const = 0; 00177 00184 virtual const bool impl_unlock_obj() const = 0; 00185 00198 virtual const bool impl_wait( const long msec ) = 0; 00199 00207 virtual const bool impl_signal() = 0; 00208 00209 private: 00210 Type _type; 00211 long _tm_msec; 00212 CallbackTimerListener& _client; 00213 Thread* _timer; 00214 bool _halt; 00216 }; /* END OF CLASS CallbackTimer */ 00217 00218 }; /* END OF NAMESPACE cbits */ 00219 00220 #endif 00221 00222 /* 00223 * $Id: CallbackTimer.h,v 1.7 2002/10/08 14:59:21 brulow Exp $ 00224 * 00225 * History: (Add nothing manually below) 00226 * ----------------------------------------------------------------------- 00227 * 00228 * $Log: CallbackTimer.h,v $ 00229 * Revision 1.7 2002/10/08 14:59:21 brulow 00230 * Improve comments 00231 * 00232 * Revision 1.6 2002/10/08 02:04:18 brulow 00233 * Improve documentation 00234 * 00235 * Revision 1.5 2002/10/07 21:07:40 brulow 00236 * Add/improve documentation 00237 * 00238 * Revision 1.4 2002/10/07 14:48:08 brulow 00239 * Fix compile errors on SunOS::Forte 00240 * 00241 * 00242 */
|
|