00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#ifndef MN_TIMEVAL_H
00025
#define MN_TIMEVAL_H
00026
00027
#include <config.h>
00028
00029
#include <sys/time.h>
00030
#include <sys/types.h>
00031
#include <unistd.h>
00032
#include <string.h>
00033
00034
#include "mnstream.h"
00035
00036 typedef struct timeval
C_timeval;
00037
00038
extern bool operator< (
const C_timeval& t1,
const C_timeval& t2);
00039
extern bool operator> (
const C_timeval& t1,
const C_timeval& t2);
00040
extern bool operator>=(
const C_timeval& t1,
const C_timeval& t2);
00041
extern bool operator<=(
const C_timeval& t1,
const C_timeval& t2);
00042
extern C_timeval operator-(
const C_timeval& t1,
const C_timeval& t2);
00043
extern C_timeval operator+(
const C_timeval& t1,
const C_timeval& t2);
00044
extern C_timeval operator+(
const C_timeval& t1,
unsigned int usecs);
00045
extern C_timeval operator-(
const C_timeval& t1,
unsigned int usecs);
00046
extern C_timeval operator*(
int mul,
const C_timeval& t);
00047
extern C_timeval operator*(
const C_timeval& t,
int mul);
00048
00049 class Timeval
00050 :
public C_timeval
00051 {
00052
public:
00053 static const size_t
MAX_USEC = 1000000;
00054
00055 enum Now
00056 {
00057
NOW
00058 };
00059
00060
public:
00061
Timeval( );
00062
Timeval(
const Timeval& tv );
00063
Timeval(
const C_timeval& tv );
00064
Timeval(
int microseconds );
00065
Timeval( size_t microseconds );
00066
Timeval( int64_t microseconds );
00067
Timeval(
double seconds );
00068
Timeval( Now );
00069
00070
Timeval&
operator=(
const Timeval& tv );
00071
Timeval&
operator=(
int microseconds );
00072
Timeval&
operator=( size_t microseconds );
00073
Timeval&
operator=( int64_t microseconds );
00074
Timeval&
operator=(
double seconds );
00075
Timeval&
operator=( Now );
00076
00077
Timeval&
operator+=(
unsigned int tv );
00078
Timeval&
operator+=( Now );
00079
Timeval&
operator-=(
unsigned int tv );
00080
Timeval&
operator-=(
const Timeval& tv );
00081
00082 size_t
asUsec() const;
00083 int64_t asUsec64() const;
00084
double asSec() const;
00085
00091
void asNPT( ostream& ostr ) const;
00092 };
00093
00094 extern
Timeval operator*(
int mul, const
Timeval& t);
00095 extern
Timeval operator*(const
Timeval& t,
int mul);
00096
00097 #endif
00098