lxg

导航

 

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);

};

posted on 2021-07-18 21:57  lxg_7105  阅读(41)  评论(0编辑  收藏  举报