Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

timeval.h

Go to the documentation of this file.
00001 /********************************************************************
00002        Copyright (c) 2001, Lee Patterson & Ant Works Software
00003        http://ssobjects.sourceforge.net
00004 
00005        created  :  
00006        filename :  timeval.h
00007        author   :  Lee Patterson (lee@antws.com)
00008 
00009        purpose  :  wrapper for time val structure. Also stores it's 
00010                    original value, so it can be reset without having 
00011                    to set the values again.
00012 
00013        notes    :  
00014 *********************************************************************/
00015 
00016 #ifndef TIMEVAL_H
00017 #define TIMEVAL_H
00018 
00019 #ifdef _WIN32
00020 # include <time.h>
00021 #else
00022 # include <sys/time.h>
00023 # include <unistd.h>
00024 #endif
00025 
00026 #include <sys/types.h>
00027 
00028 #include "ssobjects.h"
00029 
00030 namespace ssobjects
00031 {
00032 
00033 typedef struct timeval* PTIMEVAL;
00034 
00035 class TimeVal : public timeval
00036 {
00037   protected:
00038     timeval m_timeval;  //stored time val
00039 
00040   public:
00041     TimeVal() : m_timeval() 
00042     {
00043       tv_sec=0;
00044       tv_usec=0;
00045     }
00046 
00047     TimeVal(signed32 seconds,signed32 milliseconds)
00048       : m_timeval()
00049     { 
00050       tv_sec=0;
00051       tv_usec=0;
00052       setTime(seconds,milliseconds); 
00053     }
00054         
00055     void setTime(signed32 seconds,signed32 milliseconds)
00056     { 
00057       tv_sec  = seconds;
00058       tv_usec = milliseconds*1000;
00059       m_timeval = *this;
00060     }
00061 
00062     void reset()
00063     {
00064       tv_sec  = m_timeval.tv_sec; 
00065       tv_usec = m_timeval.tv_usec; 
00066     }
00067 
00068     PTIMEVAL timevalptr() { return (PTIMEVAL)&m_timeval; }
00069     operator PTIMEVAL() { return (PTIMEVAL)this; }
00070 };
00071 
00072 };
00073 
00074 #endif
00075 

Generated on Thu Nov 8 12:39:26 2001 for SimpleServerObjects by doxygen1.2.11 written by Dimitri van Heesch, © 1997-2001