Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
cclock.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 /*
6  * cclock.h
7  *
8  * Created on: 07.07.2012
9  * Author: andreas
10  */
11 #ifndef CCLOCK_H_
12 #define CCLOCK_H_
13 
14 #include <errno.h>
15 #include <string.h>
16 #include <time.h>
17 #include <string>
18 
19 #include "rofl/common/logging.h"
20 #include "rofl/common/croflexception.h"
21 
22 namespace rofl
23 {
24 
25 class cclock
26 {
27 public: // data structures
28 
29  struct timespec ts;
30 
34  static cclock
35  now();
36 
37 public:
38 
42  cclock(
43  time_t delta_sec = 0,
44  time_t delta_nsec = 0);
45 
49  cclock(
50  cclock const& cc);
51 
55  ~cclock();
59  cclock&
60  operator= (cclock const& cc);
64  cclock
65  operator+ (cclock const& cc);
69  cclock
70  operator- (cclock const& cc);
74  cclock&
75  operator+= (cclock const& cc);
79  cclock&
80  operator-= (cclock const& cc);
81 
85  bool operator== (cclock const& cc) const;
86 
90  bool operator!= (cclock const& cc) const;
91 
95  bool operator< (cclock const& cc) const;
96 
100  bool operator<= (cclock const& cc) const;
101 
105  bool operator> (cclock const& cc) const;
106 
110  bool operator>= (cclock const& cc) const;
111 
115  void
116  current_time();
117 
118 public:
119 
120  friend std::ostream&
121  operator<< (std::ostream& os, cclock const clk) {
122  os << indent(0) << "<cclock sec:" << std::hex << (int)clk.ts.tv_sec
123  << " nsec:" << (int)clk.ts.tv_nsec << std::dec << " >" << std::endl;
124  return os;
125  };
126 };
127 
128 }; // end of namespace
129 
130 #endif /* CCLOCK_H_ */
Definition: cclock.h:25
cclock & operator-=(cclock const &cc)
Definition: cclock.cc:127
cclock operator+(cclock const &cc)
Definition: cclock.cc:70
cclock & operator+=(cclock const &cc)
Definition: cclock.cc:110
bool operator<=(cclock const &cc) const
Definition: cclock.cc:184
bool operator>(cclock const &cc) const
Definition: cclock.cc:191
cclock(time_t delta_sec=0, time_t delta_nsec=0)
Definition: cclock.cc:30
cclock operator-(cclock const &cc)
Definition: cclock.cc:89
~cclock()
Definition: cclock.cc:48
bool operator>=(cclock const &cc) const
Definition: cclock.cc:198
bool operator==(cclock const &cc) const
Definition: cclock.cc:206
Definition: logging.h:76
cclock & operator=(cclock const &cc)
Definition: cclock.cc:56
bool operator<(cclock const &cc) const
Definition: cclock.cc:154
bool operator!=(cclock const &cc) const
Definition: cclock.cc:146