/* */ #ifndef _D_ABSTRACT_COMMAND_H_ #define _D_ABSTRACT_COMMAND_H_ #include "Command.h" #include "Request.h" #include "DownloadEngine.h" #include "SegmentMan.h" #include "TimeA2.h" class AbstractCommand : public Command { private: Time checkPoint; int timeout; protected: Request* req; DownloadEngine* e; SocketHandle socket; void tryReserved(); virtual bool prepareForRetry(int wait); virtual void onAbort(Exception* ex); virtual bool executeInternal(Segment& segment) = 0; void setReadCheckSocket(const SocketHandle& socket); void setWriteCheckSocket(const SocketHandle& socket); void disableReadCheckSocket(); void disableWriteCheckSocket(); #ifdef ENABLE_ASYNC_DNS void setNameResolverCheck(const NameResolverHandle& resolver); void disableNameResolverCheck(const NameResolverHandle& resolver); bool resolveHostname(const string& hostname, const NameResolverHandle& nameResolver); #endif // ENABLE_ASYNC_DNS void setTimeout(int timeout) { this->timeout = timeout; } private: bool checkSocketIsReadable; bool checkSocketIsWritable; SocketHandle readCheckTarget; SocketHandle writeCheckTarget; public: AbstractCommand(int cuid, Request* req, DownloadEngine* e, const SocketHandle& s = SocketHandle()); virtual ~AbstractCommand(); bool execute(); }; #endif // _D_ABSTRACT_COMMAND_H_