/* */ #ifndef _D_DOWNLOAD_ENGINE_H_ #define _D_DOWNLOAD_ENGINE_H_ #include #include #include "Command.h" #include "Socket.h" #include "SegmentMan.h" #include "common.h" #include "Logger.h" #include "DiskWriter.h" #include "Option.h" using namespace std; class DownloadEngine { private: void waitData(); vector rsockets; vector wsockets; bool addSocket(vector& sockets, Socket* socket); bool deleteSocket(vector& sockets, Socket* socket); struct timeval cp; long long int psize; void initStatistics(); void calculateStatistics(); protected: int speed; virtual void sendStatistics(long long int currentSize, long long int totalSize) {}; public: bool noWait; queue commands; SegmentMan* segmentMan; DiskWriter* diskWriter; const Logger* logger; const Option* option; DownloadEngine(); virtual ~DownloadEngine(); void run(); bool addSocketForReadCheck(Socket* socket); bool deleteSocketForReadCheck(Socket* socket); bool addSocketForWriteCheck(Socket* socket); bool deleteSocketForWriteCheck(Socket* socket); }; #endif // _D_DOWNLOAD_ENGINE_H_