/* */ #ifndef _D_COMMAND_H_ #define _D_COMMAND_H_ #include "common.h" #include #include namespace aria2 { class Logger; typedef int32_t CommandUuid; class Command { public: enum STATUS { STATUS_ALL, STATUS_INACTIVE, STATUS_ACTIVE, STATUS_REALTIME, STATUS_ONESHOT_REALTIME }; private: CommandUuid uuid; static int32_t uuidGen; STATUS status; protected: int32_t cuid; Logger* logger; bool _readEvent; bool _writeEvent; bool _errorEvent; public: Command(int32_t cuid); virtual ~Command() {} virtual bool execute() = 0; int32_t getCuid() const { return cuid; } const CommandUuid& getUuid() const { return uuid; } void setStatusActive() { this->status = STATUS_ACTIVE; } void setStatusInactive() { this->status = STATUS_INACTIVE; } void setStatusRealtime() { this->status = STATUS_REALTIME; } void setStatus(STATUS status); bool statusMatch(Command::STATUS statusFilter) const { return statusFilter <= status; } void transitStatus(); void readEventReceived(); void writeEventReceived(); void errorEventRecieved(); void clearIOEvents(); }; typedef std::deque Commands; } // namespace aria2 #endif // _D_COMMAND_H_