qswiki/handlers/handlerfactory.h

29 行
826 B
C++

#ifndef HANDLERFACTORY_H
#define HANDLERFACTORY_H
#include <memory>
#include "handler.h"
#include "../template.h"
class HandlerFactory
{
HandlerConfig &handlerConfig;
Template &templ;
Database &db;
UrlProvider &urlProvider;
ICache &cache;
IParser &parser;
template <class T> inline std::unique_ptr<T> produce(Session &userSession)
{
return std::make_unique<T>(handlerConfig, templ, db, userSession, urlProvider, cache, parser);
}
public:
HandlerFactory(HandlerConfig &handlerConfig, Template &templ, Database &db, UrlProvider &urlprovider, ICache &cache, IParser &parser)
: handlerConfig(handlerConfig), templ(templ), db(db), urlProvider(urlprovider), cache(cache), parser(parser)
{
}
std::unique_ptr<Handler> createHandler(const std::string &action, Session &userSession);
};
#endif // HANDLERFACTORY_H