Cupt
|
00001 /************************************************************************** 00002 * Copyright (C) 2010 by Eugene V. Lyubimkin * 00003 * * 00004 * This program is free software; you can redistribute it and/or modify * 00005 * it under the terms of the GNU General Public License * 00006 * (version 3 or above) as published by the Free Software Foundation. * 00007 * * 00008 * This program is distributed in the hope that it will be useful, * 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00011 * GNU General Public License for more details. * 00012 * * 00013 * You should have received a copy of the GNU GPL * 00014 * along with this program; if not, write to the * 00015 * Free Software Foundation, Inc., * 00016 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * 00017 **************************************************************************/ 00018 #ifndef CUPT_DOWNLOAD_PROGRESS_SEEN 00019 #define CUPT_DOWNLOAD_PROGRESS_SEEN 00020 00022 00023 #include <map> 00024 00025 #include <cupt/common.hpp> 00026 00027 namespace cupt { 00028 00029 namespace internal { 00030 00031 class ProgressImpl; 00032 00033 } 00034 00035 namespace download { 00036 00038 class CUPT_API Progress 00039 { 00040 internal::ProgressImpl* __impl; 00041 public: 00043 struct DownloadRecord 00044 { 00045 size_t number; 00046 size_t downloadedSize; 00047 size_t size; 00048 bool beingPostprocessed; 00049 }; 00050 protected: 00055 string getLongAliasForUri(const string& uri) const; 00060 string getShortAliasForUri(const string& uri) const; 00066 const std::map< string, DownloadRecord >& getDownloadRecords() const; 00071 uint64_t getOverallDownloadedSize() const; 00079 uint64_t getOverallEstimatedSize() const; 00084 uint64_t getOverallFetchedSize() const; 00088 size_t getOverallDownloadTime() const; 00093 size_t getOverallEstimatedTime() const; 00097 size_t getDownloadSpeed() const; 00098 00105 virtual void newDownloadHook(const string& uri, const DownloadRecord& downloadRecord); 00113 virtual void finishedDownloadHook(const string& uri, const string& result); 00124 virtual void updateHook(bool immediate); 00128 virtual void finishHook(); 00129 00130 public: 00132 Progress(); 00133 00135 00138 static float speedCalculatingAccuracy; 00139 00141 00145 void setShortAliasForUri(const string& uri, const string& alias); 00147 00151 void setLongAliasForUri(const string& uri, const string& alias); 00153 00159 void setTotalEstimatedSize(uint64_t size); 00160 00162 CUPT_LOCAL void progress(const vector< string >& params); 00164 00166 virtual ~Progress(); 00167 }; 00168 00169 } 00170 } 00171 00172 #endif 00173