libktorrent
2.2.0
src
torrent
timeestimator.h
1
/***************************************************************************
2
* Copyright (C) 2006 by Ivan Vasić *
3
* ivasic@gmail.com *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
* *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
14
* *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
20
#ifndef BTTIMEESTIMATOR_H
21
#define BTTIMEESTIMATOR_H
22
23
#include <climits>
24
#include <ktorrent_export.h>
25
#include <util/constants.h>
26
27
namespace
bt
28
{
29
class
TorrentControl;
30
36
class
SampleQueue
37
{
38
public
:
39
SampleQueue();
40
~SampleQueue();
41
42
enum
{SAMPLE_COUNT_MAX = 20};
43
47
void
push
(Uint32 sample);
48
49
Uint32 first();
50
Uint32 last();
51
52
bool
isFull();
53
58
int
count
();
59
63
Uint32
sum
();
64
65
private
:
66
int
m_count;
67
68
int
m_start;
69
int
m_end;
70
71
Uint32 m_samples[SAMPLE_COUNT_MAX];
72
};
73
78
class
KTORRENT_EXPORT
TimeEstimator
79
{
80
public
:
81
static
const
int
NEVER = INT_MAX;
82
static
const
int
ALREADY_FINISHED = 0;
83
84
enum
ETAlgorithm
85
{
86
ETA_KT,
//ktorrent default algorithm - combination of the following according to our tests
87
ETA_CSA,
//current speed algorithm
88
ETA_GASA,
//global average speed algorithm
89
ETA_WINX,
//window of X algorithm
90
ETA_MAVG
//moving average algorithm
91
};
92
93
TimeEstimator
(
TorrentControl
* tc);
94
~
TimeEstimator
();
95
97
int
estimate();
98
99
private
:
100
int
estimateGASA();
101
int
estimateWINX();
102
int
estimateMAVG();
103
int
estimateKT();
104
105
Uint32 sample()
const
;
106
Uint64 bytesLeft()
const
;
107
108
TorrentControl
* m_tc;
109
SampleQueue
m_samples;
110
111
Uint32 m_lastAvg;
112
int
m_lastETA;
113
114
//last percentage
115
double
m_perc;
116
};
117
118
}
119
120
#endif
bt::TimeEstimator
Definition:
timeestimator.h:97
bt::SampleQueue::sum
Uint32 sum()
bt::SampleQueue::count
int count()
bt::TorrentControl
Controls just about everything.
Definition:
torrentcontrol.h:69
bt::SampleQueue
Definition:
timeestimator.h:55
bt::SampleQueue::push
void push(Uint32 sample)
Generated by
1.8.18