summaryrefslogtreecommitdiffstats
path: root/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/RequestHandlers/SimpleRequestHandlerGroup.h')
-rw-r--r--src/Common/RequestHandlers/SimpleRequestHandlerGroup.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h
new file mode 100644
index 0000000..86009f3
--- /dev/null
+++ b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h
@@ -0,0 +1,54 @@
+/*
+ * SimpleRequestHandlerGroup.h
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MAD_COMMON_REQUESTHANDLERS_SIMPLEREQUESTHANDLERGROUP_H_
+#define MAD_COMMON_REQUESTHANDLERS_SIMPLEREQUESTHANDLERGROUP_H_
+
+#include "../RequestHandlerGroup.h"
+
+namespace Mad {
+namespace Common {
+namespace RequestHandlers {
+
+class SimpleRequestHandlerGroup : public RequestHandlerGroup {
+ private:
+ std::set<std::string> types;
+ std::map<std::string, boost::function2<void, boost::shared_ptr<const XmlPacket>, XmlPacket*> > handlers;
+
+ protected:
+ void registerHandler(const std::string &type, const boost::function2<void, boost::shared_ptr<const XmlPacket>, XmlPacket*> &handler) {
+ types.insert(type);
+ handlers.insert(std::make_pair(type, handler));
+ }
+
+ SimpleRequestHandlerGroup() {}
+
+ public:
+ virtual const std::set<std::string>& getPacketTypes() {
+ return types;
+ }
+
+ virtual boost::shared_ptr<RequestHandler> createRequestHandler(const std::string &type);
+};
+
+}
+}
+}
+
+#endif /* MAD_COMMON_REQUESTHANDLERS_SIMPLEREQUESTHANDLERGROUP_H_ */