Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

trafficgraphdata.h
Go to the documentation of this file.
1 #ifndef TRAFFICGRAPHDATA_H
2 #define TRAFFICGRAPHDATA_H
3 
4 #include <QHash>
5 #include <QQueue>
6 
8 {
9  float in;
10  float out;
11 
12  TrafficSample(float in, float out)
13  {
14  this->in = in;
15  this->out = out;
16  }
17 
19  {
20  return TrafficSample(this->in + other.in, this->out + other.out);
21  }
22 
24  {
25  this->in += rhs.in;
26  this->out += rhs.out;
27  return *this;
28  }
29 };
30 
32 {
33 public:
35  {
46  };
47 
48  static const int RangeMinutes[];
49  static const int DESIRED_DATA_SAMPLES;
50  static const int SMALLEST_SAMPLE_PERIOD;
51 
52  typedef QQueue<TrafficSample> SampleQueue;
53  typedef QHash<GraphRange,SampleQueue> SampleQueueMap;
54 
56  bool update(const TrafficSample& trafficSample);
57  bool update(quint64 totalBytesRecv, quint64 totalBytesSent);
58  void switchRange(GraphRange newRange);
62  void clear();
63  void setLastBytes(quint64 nLastBytesIn, quint64 nLastBytesOut);
64  quint64 getLastBytesIn() { return nLastBytesIn; }
65  quint64 getLastBytesOut() { return nLastBytesOut; }
66 
67 private:
68  static const int DesiredQueueSizes[];
69 
72 
75 
76  quint64 nLastBytesIn;
77  quint64 nLastBytesOut;
78 
79  void update(GraphRange range, const TrafficSample &trafficSample);
80 
84 
85  SampleQueue sumEach2Samples(const SampleQueue &rangeQueue);
86  SampleQueue sumEach3Samples(const SampleQueue &rangeQueue, GraphRange range);
87 
88  float convertSampleToBandwidth(float dataAmount);
91 };
92 
93 #endif // TRAFFICGRAPHDATA_H
TrafficGraphData(GraphRange range)
static const int DesiredQueueSizes[]
SampleQueue sumEach2Samples(const SampleQueue &rangeQueue)
void setLastBytes(quint64 nLastBytesIn, quint64 nLastBytesOut)
void tryUpdateNextWithLast3Samples(GraphRange range, GraphRange nextRange)
SampleQueue getRangeQueue(GraphRange range)
SampleQueueMap sampleStash
TrafficSample operator+(const TrafficSample &other) const
QQueue< TrafficSample > SampleQueue
GraphRange currentGraphRange
quint64 getLastBytesOut()
static const int SMALLEST_SAMPLE_PERIOD
TrafficSample(float in, float out)
TrafficGraphData & operator=(TrafficGraphData const &)
static const int DESIRED_DATA_SAMPLES
void tryUpdateNextWithLast2Samples(GraphRange range, GraphRange nextRange)
QHash< GraphRange, SampleQueue > SampleQueueMap
TrafficSample & operator+=(const TrafficSample &rhs)
quint64 getLastBytesIn()
SampleQueue getCurrentRangeQueue()
float convertSampleToBandwidth(float dataAmount)
static const int RangeMinutes[]
void tryAddingSampleToStash(GraphRange range)
bool update(const TrafficSample &trafficSample)
void switchRange(GraphRange newRange)
SampleQueue getCurrentRangeQueueWithAverageBandwidth()
SampleQueue sumEach3Samples(const SampleQueue &rangeQueue, GraphRange range)
SampleQueueMap sampleMap
Released under the MIT license