/* */ #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; int32_t downloadSpeed; int32_t uploadSpeed; int64_t selectedDownloadLengthDiff; int64_t selectedTotalLength; // The time when startup Time startup; // The average speed(bytes per second) since startup int32_t avgSpeed; // The estimated remaining time to complete the download. int32_t eta; int64_t downloadLength; int64_t uploadLength; int64_t totalLength; BtContextHandle btContext; BtRuntimeHandle btRuntime; PieceStorageHandle pieceStorage; PeerStorageHandle peerStorage; BtAnnounceHandle btAnnounce; BtProgressInfoFileHandle btProgressInfoFile; int32_t calculateSpeed(int64_t sessionLength, int32_t 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_