1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#ifndef CBM_STATISTICS_H
#define CBM_STATISTICS_H
#include <list>
#include <string>
#include <sys/time.h>
namespace statistics {
struct Statistics {
struct timeval timestamp;
unsigned long long rx_bytes, rx_packets, rx_errs, rx_drop, rx_fifo,
rx_frame, rx_compressed, rx_multicast,
tx_bytes, tx_packets, tx_errs, tx_drop, tx_fifo,
tx_frame, tx_compressed, tx_multicast;
};
class Interface {
public:
Interface(const std::string& name);
const std::string& getName() const;
void setUpdated(bool updated);
bool getUpdated() const;
void update(const Statistics& statistics);
double getReceiveSpeed() const;
double getTransmitSpeed() const;
private:
std::string name_;
bool updated_;
Statistics statistics_[2];
double receiveSpeed_, transmitSpeed_;
};
class Reader {
public:
void update();
typedef std::list<Interface> Interfaces;
const Interfaces& getInterfaces() const;
private:
Interfaces interfaces_;
};
} // namespace statistics
#endif
|