xosview  1.23
About: xosview is an X Windows based system monitor (cpu, memory, swap and network usage; interrupt and serial activities; load average).
  Fossies Dox: xosview-1.23.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

timeval.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 1994, 1995, 2006 by Mike Romberg ( mike.romberg@noaa.gov )
3 //
4 // This file may be distributed under terms of the GPL
5 //
6 
7 #ifndef _TIMEVAL_H_
8 #define _TIMEVAL_H_
9 
10 #include <sys/time.h>
11 #include <iostream>
12 
13 class TimeVal {
14 public:
15  TimeVal(unsigned long sec = 0, unsigned long usec = 0) {
16  _val.tv_sec = (int)sec;
17  _val.tv_usec = usec;
18  }
19  TimeVal(const struct timeval &val) { _val = val; }
20 
21  unsigned long sec(void) const { return _val.tv_sec; }
22  unsigned long usec(void) const { return _val.tv_usec; }
23  void sec(unsigned long s) { _val.tv_sec = (int)s; }
24  void usec(unsigned long us) { _val.tv_usec = us; }
25 
26  operator struct timeval(void) const { return _val; }
27 
28  std::ostream &printOn(std::ostream &os) const {
29  return os <<"(" <<sec() <<" sec, " <<usec() <<" usec)";
30  }
31 
32 private:
33  struct timeval _val;
34 };
35 
36 inline std::ostream &operator<<(std::ostream &os, const TimeVal &tv){
37  return tv.printOn(os);
38 }
39 
40 #endif
unsigned long usec(void) const
Definition: timeval.h:22
unsigned long sec(void) const
Definition: timeval.h:21
struct timeval _val
Definition: timeval.h:33
void sec(unsigned long s)
Definition: timeval.h:23
TimeVal(const struct timeval &val)
Definition: timeval.h:19
void usec(unsigned long us)
Definition: timeval.h:24
std::ostream & printOn(std::ostream &os) const
Definition: timeval.h:28
TimeVal(unsigned long sec=0, unsigned long usec=0)
Definition: timeval.h:15
std::ostream & operator<<(std::ostream &os, const TimeVal &tv)
Definition: timeval.h:36