class Request;
//职责链接口
class Chain {
protected:
Chain* chain;
public:
Chain(Chain* chain = nullptr);
virtual ~Chain() = 0;
void setChain(Chain* chain) { this->chain = chain; }
virtual void request(Request* request);
};
Chain::Chain(Chain *chain)
:chain(chain) {
}
Chain::~Chain() {
}
void Chain::request(Request* request) {
this->chain->request(request);
}
//请求接口
class Request {
public:
enum class RequestType {
RequestChangeWindowMode,
RequestClose,
RequestChangePlayStatus,
};
protected:
RequestType requestType;
public:
Request(RequestType requestType);
virtual ~Request() = 0;
inline RequestType getRequestType() const { return this->requestType; }
};
//策略处理请求
class RequestStrategy {
protected:
//MainWindow* mainWindow;
Request* request;
public:
RequestStrategy( Request* request);
virtual ~RequestStrategy() = 0;
virtual bool response() = 0;
};
//策略简单工厂
class RequestStrategyFactory {
public:
RequestStrategyFactory();
~RequestStrategyFactory();
static RequestStrategy* create(Request* request);
};