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 
27 namespace cupt {
28 
29 namespace internal {
30 
31 class ProgressImpl;
32 
33 }
34 
35 namespace download {
36 
38 class CUPT_API Progress
39 {
40  internal::ProgressImpl* __impl;
41  public:
44  {
45  size_t number;
46  size_t downloadedSize;
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;
104  size_t getOverallEstimatedTime() 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 
cupt::download::Progress::~Progress
virtual ~Progress()
destructor
cupt::download::Progress::DownloadRecord::number
size_t number
unique number
Definition: progress.hpp:45
cupt::download::Progress::updateHook
virtual void updateHook(bool immediate)
cupt::download::Progress::getDownloadSpeed
size_t getDownloadSpeed() const
cupt::download::Progress::isOptional
bool isOptional(const string &uri) const
cupt::download::Progress
download progress meter
Definition: progress.hpp:39
cupt::download::Progress::getOverallDownloadTime
size_t getOverallDownloadTime() const
common.hpp
cupt::download::Progress::DownloadRecord
download element
Definition: progress.hpp:44
cupt::download::Progress::Progress
Progress()
constructor
cupt::download::Progress::getOverallEstimatedSize
uint64_t getOverallEstimatedSize() const
cupt::download::Progress::DownloadRecord::downloadedSize
size_t downloadedSize
already downloaded amount of bytes
Definition: progress.hpp:46
cupt::download::Progress::getLongAliasForUri
string getLongAliasForUri(const string &uri) const
cupt::download::Progress::setLongAliasForUri
void setLongAliasForUri(const string &uri, const string &alias)
sets a long alias for URI
cupt::download::Progress::finishedDownloadHook
virtual void finishedDownloadHook(const string &uri, const string &result)
cupt::download::Progress::getOverallDownloadedSize
uint64_t getOverallDownloadedSize() const
cupt::download::Progress::speedCalculatingAccuracy
static float speedCalculatingAccuracy
amount of seconds considered while calculating a download speed
Definition: progress.hpp:149
cupt::download::Progress::getDownloadRecords
const std::map< string, DownloadRecord > & getDownloadRecords() const
cupt::download::Progress::getOverallFetchedSize
uint64_t getOverallFetchedSize() const
cupt::download::Progress::newDownloadHook
virtual void newDownloadHook(const string &uri, const DownloadRecord &downloadRecord)
cupt::download::Progress::DownloadRecord::size
size_t size
expected file size, -1 if unknown
Definition: progress.hpp:47
cupt::download::Progress::getOverallEstimatedTime
size_t getOverallEstimatedTime() const
cupt::download::Progress::setShortAliasForUri
void setShortAliasForUri(const string &uri, const string &alias)
sets a short alias for URI
cupt::download::Progress::DownloadRecord::Phase
Phase
Definition: progress.hpp:49
cupt::download::Progress::finishHook
virtual void finishHook()
cupt::download::Progress::markAsOptional
void markAsOptional(const string &uri)
cupt::download::Progress::getShortAliasForUri
string getShortAliasForUri(const string &uri) const