Fix Idle count
[samplevnf.git] / VNFs / DPPD-PROX / tools / flow_extract / timestamp.hpp
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef _TIMESTAMP_H_
18 #define _TIMESTAMP_H_
19
20 #include <iostream>
21
22 #include <sys/time.h>
23 #include <inttypes.h>
24
25 using namespace std;
26
27 class Timestamp {
28 public:
29         Timestamp(const uint64_t sec, const uint64_t nsec) : m_sec(sec), m_nsec(nsec) {}
30         Timestamp() {}
31         Timestamp(const struct timeval& tv) : m_sec(tv.tv_sec), m_nsec(tv.tv_usec) {}
32         Timestamp operator-(const Timestamp& other) const;
33         bool operator==(const Timestamp &other) const;
34         friend double operator/(double d, const Timestamp &denominator);
35         bool operator>(const Timestamp& other);
36         bool operator<(const Timestamp& other);
37         uint64_t sec() const {return m_sec;}
38         uint64_t nsec() const {return m_nsec;}
39         friend ostream& operator<<(ostream& stream, const Timestamp& ts);
40 private:
41         uint64_t m_sec;
42         uint64_t m_nsec;
43 };
44
45 #endif /* _TIMESTAMP_H_ */