summaryrefslogtreecommitdiffstats
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/RequestManager.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index 4704a0f..aef6b90 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -70,12 +70,12 @@ class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable {
- template<class T> class RequestHandlerFactory : public RequestHandlerGroup {
+ template<typename T> class RequestHandlerFactory0 : public RequestHandlerGroup {
private:
std::set<std::string> types;
public:
- RequestHandlerFactory(const std::string &type) {
+ RequestHandlerFactory0(const std::string &type) {
types.insert(type);
}
@@ -88,6 +88,25 @@ class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable {
}
};
+ template<typename T, typename T1> class RequestHandlerFactory1 : public RequestHandlerGroup {
+ private:
+ std::set<std::string> types;
+ T1 arg1;
+
+ public:
+ RequestHandlerFactory1(const std::string &type, T1 argT1) : arg1(argT1) {
+ types.insert(type);
+ }
+
+ virtual const std::set<std::string>& getPacketTypes() {
+ return types;
+ }
+
+ virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const std::string& /*type*/) {
+ return boost::shared_ptr<RequestHandler>(new T(application, arg1));
+ }
+ };
+
Application *application;
boost::shared_mutex mutex;
@@ -146,7 +165,11 @@ class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable {
}
template <class T> void registerPacketType(const std::string &type) {
- registerRequestHandlerGroup(boost::shared_ptr<RequestHandlerFactory<T> >(new RequestHandlerFactory<T>(type)));
+ registerRequestHandlerGroup(boost::shared_ptr<RequestHandlerFactory0<T> >(new RequestHandlerFactory0<T>(type)));
+ }
+
+ template <class T, class T1> void registerPacketType(const std::string &type, T1 arg1) {
+ registerRequestHandlerGroup(boost::shared_ptr<RequestHandlerFactory1<T, T1> >(new RequestHandlerFactory1<T, T1>(type, arg1)));
}
void unregisterPacketType(const std::string &type) {