/* */ #ifndef _D_TORRENT_DOWNLOAD_ENGINE_H_ #define _D_TORRENT_DOWNLOAD_ENGINE_H_ #include "DownloadEngine.h" #include "TimeA2.h" #include "BtContext.h" #include "BtRuntime.h" #include "PieceStorage.h" #include "PeerStorage.h" #include "BtAnnounce.h" #include "BtProgressInfoFile.h" class TorrentDownloadEngine : public DownloadEngine { private: bool filenameFixed; void initStatistics(); void calculateStatistics(); protected: Time cp; Time lastCalcStat; int downloadSpeed; int uploadSpeed; long long int selectedDownloadLengthDiff; long long int selectedTotalLength; // The time when startup Time startup; // The average speed(bytes per second) since startup int avgSpeed; // The estimated remaining time to complete the download. int eta; long long int downloadLength; long long int uploadLength; long long int totalLength; BtContextHandle btContext; BtRuntimeHandle btRuntime; PieceStorageHandle pieceStorage; PeerStorageHandle peerStorage; BtAnnounceHandle btAnnounce; BtProgressInfoFileHandle btProgressInfoFile; int calculateSpeed(long long int sessionLength, int elapsed); void calculateStat(); virtual void onEndOfRun(); virtual void sendStatistics() = 0; public: TorrentDownloadEngine(); virtual ~TorrentDownloadEngine(); bool isFilenameFixed() const { return filenameFixed; } void setBtContext(const BtContextHandle& btContext); }; #endif // _D_TORRENT_DOWNLOAD_ENGINE_H_