/* */ #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" #include using namespace std; typedef deque Sockets; typedef queue Commands; class DownloadEngine { private: void waitData(); Sockets rsockets; Sockets wsockets; void shortSleep() const; bool addSocket(Sockets& sockets, Socket* socket); bool deleteSocket(Sockets& sockets, Socket* socket); protected: virtual void initStatistics() = 0; virtual void calculateStatistics() = 0; virtual void onEndOfRun() = 0; public: bool noWait; Commands 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_