⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clstimer.h

📁 set of classes for timing applications
💻 H
字号:
#ifndef CLSTIMER_H#define CLSTIMER_H#include <time.h>#include <sys/time.h>typedef struct timeval strPrecTime;struct tm;class clsTimer{    public:        enum    eIntervals  { eitNoInterval , eitDays , eitWeeks , eitMonths, eitYears , eitContinous };        clsTimer();        ~clsTimer();        long    SetStartTime    ( long lStartTime = 0 );        long    SetStartTime    ( long iHour , long iMinute );        long    SetInterval     ( long iHour , long iMinute , long iSec = 0 );        long    SetInterval     ( long iSec );        long    GetNextTime     ( ) { return m_lNextTime; };   //daje vrijeme sljedeceg dogadjaja bez izracunavanja        long    GetInterval     ( ) { return m_lIntervalSec; };//daje longerval ponavljanja        long    UpdateNextTime  ( );                          //izracunava vrijeme sljedeceg dogadjaja        long    IsIntervalOver  ( );        static char*    GetTimeString   ( long lUnixTime );        static long     AddInterval     ( long lUnixTime , unsigned long lIntervalType , unsigned long lIntervalAmount );        static long     AddInterval     ( tm& rTm , unsigned long lIntervalType , unsigned long lIntervalAmount );        static long     AdjustDstError  ( tm& rTm );        static long     GetStartStopTime( unsigned long lType , unsigned long lAmount , long& lStart , long& lStop );        static long     GetStartTime    ( int lIntervalType , int lIntervalAmount );        //lIntervalType - day, week, month...        //lIntervalAmount - 0 current, -1 previous, +1 next...  protected:        long  m_lStartHour;        long  m_lStartMin;        long  m_lIntervalSec;        long  m_lStartEntered;        long  m_lIntervalEntered;        long  m_lNextTime;  private:};class clsPrecTimer{    public:        enum    eRetVal { NoError };        clsPrecTimer();        ~clsPrecTimer();                void    SetToZero   ( );                void    SetToNow    ( );        inline  bool    IntervalActive      ( ) const { return m_sTime.tv_sec ? true : false; }                int     InitInterval        ( unsigned int iSecs , unsigned int iMSecs );                int     StopTimer           ( );                bool    IntervalFinished    ( ) const;                bool    IntervalFinished    ( long lTimeNowSec , long lTimeNowUSec ) const;                bool    IntervalFinished    ( const clsPrecTimer& rEndTime ) const;                bool    IntervalFinished    ( const strPrecTime& rEndTime ) const;        static strPrecTime  TimeNow ( );        static strPrecTime  TimeZero( );        static  bool    TimeoutEnd  ( const strPrecTime& rStart , const strPrecTime& rNow , long lIntervalMSecs );    protected:        strPrecTime     m_sTime;};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -