Cupt
progress.hpp
Go to the documentation of this file.
1/**************************************************************************
2* Copyright (C) 2010 by Eugene V. Lyubimkin *
3* *
4* This program is free software; you can redistribute it and/or modify *
5* it under the terms of the GNU General Public License *
6* (version 3 or above) as published by the Free Software Foundation. *
7* *
8* This program is distributed in the hope that it will be useful, *
9* but WITHOUT ANY WARRANTY; without even the implied warranty of *
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11* GNU General Public License for more details. *
12* *
13* You should have received a copy of the GNU GPL *
14* along with this program; if not, write to the *
15* Free Software Foundation, Inc., *
16* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
17**************************************************************************/
18#ifndef CUPT_DOWNLOAD_PROGRESS_SEEN
19#define CUPT_DOWNLOAD_PROGRESS_SEEN
20
22
23#include <map>
24
25#include <cupt/common.hpp>
26
27namespace cupt {
28
29namespace internal {
30
31class ProgressImpl;
32
33}
34
35namespace download {
36
38class CUPT_API Progress
39{
40 internal::ProgressImpl* __impl;
41 public:
44 {
45 size_t number;
47 size_t size;
48 enum class Phase
49 {
50 Planned,
51 Started,
52 Postprocessed
53 } phase;
54 float sizeScaleFactor;
55
57 };
58 protected:
63 string getLongAliasForUri(const string& uri) const;
68 string getShortAliasForUri(const string& uri) const;
72 bool isOptional(const string& uri) const;
78 const std::map< string, DownloadRecord >& getDownloadRecords() const;
83 uint64_t getOverallDownloadedSize() const;
90 uint64_t getOverallEstimatedSize() const;
95 uint64_t getOverallFetchedSize() const;
99 size_t getOverallDownloadTime() const;
108 size_t getDownloadSpeed() const;
109
116 virtual void newDownloadHook(const string& uri, const DownloadRecord& downloadRecord);
124 virtual void finishedDownloadHook(const string& uri, const string& result);
135 virtual void updateHook(bool immediate);
139 virtual void finishHook();
140
141 public:
144
146
150
152
156 void setShortAliasForUri(const string& uri, const string& alias);
158
162 void setLongAliasForUri(const string& uri, const string& alias);
167 void markAsOptional(const string& uri);
168
170 CUPT_LOCAL void progress(const vector< string >& params);
172
174 virtual ~Progress();
175};
176
177}
178}
179
180#endif
181
download progress meter
Definition: progress.hpp:39
virtual void finishedDownloadHook(const string &uri, const string &result)
string getShortAliasForUri(const string &uri) const
uint64_t getOverallFetchedSize() const
void setLongAliasForUri(const string &uri, const string &alias)
sets a long alias for URI
virtual void finishHook()
size_t getOverallEstimatedTime() const
size_t getDownloadSpeed() const
virtual void updateHook(bool immediate)
uint64_t getOverallDownloadedSize() const
void setShortAliasForUri(const string &uri, const string &alias)
sets a short alias for URI
void markAsOptional(const string &uri)
virtual ~Progress()
destructor
const std::map< string, DownloadRecord > & getDownloadRecords() const
uint64_t getOverallEstimatedSize() const
static float speedCalculatingAccuracy
amount of seconds considered while calculating a download speed
Definition: progress.hpp:149
bool isOptional(const string &uri) const
string getLongAliasForUri(const string &uri) const
size_t getOverallDownloadTime() const
virtual void newDownloadHook(const string &uri, const DownloadRecord &downloadRecord)
download element
Definition: progress.hpp:44
size_t size
expected file size, -1 if unknown
Definition: progress.hpp:47
Phase
Definition: progress.hpp:49
size_t downloadedSize
already downloaded amount of bytes
Definition: progress.hpp:46
size_t number
unique number
Definition: progress.hpp:45