/* */ #ifndef _D_COMMAND_H_ #define _D_COMMAND_H_ #include "common.h" #include "LogFactory.h" typedef int CommandUuid; class Command { public: enum STATUS { STATUS_ALL, STATUS_INACTIVE, STATUS_ACTIVE, STATUS_REALTIME }; private: CommandUuid uuid; static int uuidGen; STATUS status; protected: int cuid; const Logger* logger; public: Command(int cuid):uuid(uuidGen++), status(STATUS_INACTIVE), cuid(cuid) { logger = LogFactory::getInstance(); } virtual ~Command() {} virtual bool execute() = 0; int 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; } bool statusMatch(Command::STATUS statusFilter) const { return statusFilter <= status; } void transitStatus() { switch(status) { case STATUS_REALTIME: break; default: status = STATUS_INACTIVE; } } }; typedef deque Commands; #endif // _D_COMMAND_H_