Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/nto/TimerContainer.hpp

Go to the documentation of this file.
00001 // Required library:  -lrt
00002 
00003 #ifndef __J2K__TimerContainer_HPP__
00004 #define __J2K__TimerContainer_HPP__
00005 
00006 #include <j2k/Fred/Standard.hpp>
00007 
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include <unistd.h>
00011 #include <errno.h>
00012 #include <pthread.h>
00013 #include <signal.h>
00014 #include <sys/time.h>
00015 
00016 #if !defined( linux )
00017 #include <sys/siginfo.h>
00018 #endif
00019 
00020 // 16-17
00021 #ifndef  TimerSignalEvent
00022 #define  TimerSignalEvent  SIGUSR1
00023 #endif
00024 
00025 #if defined( __QNXNTO__ )
00026 
00027 #include <sys/neutrino.h>
00028 #include <sys/netmgr.h>
00029 #include <sched.h>
00030 
00031 #endif
00032 
00033 class TimerContainer
00034 {
00035 
00036 public:
00037 
00038 static const ULONG TimerContainer::Period_1_ms   =   1000000ul;
00039 static const ULONG TimerContainer::Period_10_ms  =  10000000ul;
00040 static const ULONG TimerContainer::Period_20_ms  =  20000000uL;
00041 static const ULONG TimerContainer::Period_50_ms  =  50000000ul;
00042 static const ULONG TimerContainer::Period_100_ms = 100000000ul;
00043 static const ULONG TimerContainer::Period_250_ms = 250000000ul;
00044 static const ULONG TimerContainer::Period_500_ms = 500000000ul;
00045 static const ULONG TimerContainer::Period_750_ms = 750000000ul;
00046 
00047 public:
00048 
00049   // Setup a timer, to be started later.
00050   TimerContainer( ULONG nsec = Period_500_ms, ULONG sec = 0 );
00051 
00052   virtual ~TimerContainer() { }
00053 
00054 
00055   // Implicit
00056   // virtual void start();
00057 
00058   inline virtual void stop()
00059   {
00060     set( 0, 0 );
00061   }
00062 
00063   void startTimer();
00064   void set( ULONG nsec = Period_500_ms, ULONG sec = 0 );
00065 
00066   inline int getChid() { return chid; }
00067 
00068 protected:
00069 
00070   int                  pulse_id;
00071   int                  timer_pid;
00072   int                  chid;
00073 
00074   timer_t              timer_id;
00075 
00076   struct _pulse        pulse;
00077   struct sigevent      event;
00078   struct _clockperiod  clkper;
00079   struct itimerspec    t;
00080 
00081 };
00082 
00083 #endif

Generated on Sun Oct 14 18:46:40 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001