diff options
Diffstat (limited to 'src/Common/RequestManager.h')
-rw-r--r-- | src/Common/RequestManager.h | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h index aef6b90..48472d5 100644 --- a/src/Common/RequestManager.h +++ b/src/Common/RequestManager.h @@ -72,37 +72,37 @@ class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable { template<typename T> class RequestHandlerFactory0 : public RequestHandlerGroup { private: - std::set<std::string> types; + std::set<Core::String> types; public: - RequestHandlerFactory0(const std::string &type) { + RequestHandlerFactory0(const Core::String &type) { types.insert(type); } - virtual const std::set<std::string>& getPacketTypes() { + virtual const std::set<Core::String>& getPacketTypes() { return types; } - virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const std::string& /*type*/) { + virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const Core::String& /*type*/) { return boost::shared_ptr<RequestHandler>(new T(application)); } }; template<typename T, typename T1> class RequestHandlerFactory1 : public RequestHandlerGroup { private: - std::set<std::string> types; + std::set<Core::String> types; T1 arg1; public: - RequestHandlerFactory1(const std::string &type, T1 argT1) : arg1(argT1) { + RequestHandlerFactory1(const Core::String &type, T1 argT1) : arg1(argT1) { types.insert(type); } - virtual const std::set<std::string>& getPacketTypes() { + virtual const std::set<Core::String>& getPacketTypes() { return types; } - virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const std::string& /*type*/) { + virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const Core::String& /*type*/) { return boost::shared_ptr<RequestHandler>(new T(application, arg1)); } }; @@ -115,7 +115,7 @@ class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable { boost::uint16_t lastRequestId; - std::map<std::string, boost::shared_ptr<RequestHandlerGroup> > requestHandlerGroups; + std::map<Core::String, boost::shared_ptr<RequestHandlerGroup> > requestHandlerGroups; boost::uint16_t _getRequestId() { return lastRequestId+=2; @@ -145,17 +145,17 @@ class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable { void registerRequestHandlerGroup(boost::shared_ptr<RequestHandlerGroup> requestHandlerGroup) { boost::lock_guard<boost::shared_mutex> lock(mutex); - const std::set<std::string> &types = requestHandlerGroup->getPacketTypes(); - for(std::set<std::string>::const_iterator type = types.begin(); type != types.end(); ++type) + const std::set<Core::String> &types = requestHandlerGroup->getPacketTypes(); + for(std::set<Core::String>::const_iterator type = types.begin(); type != types.end(); ++type) requestHandlerGroups.insert(std::make_pair(*type, requestHandlerGroup)); } void unregisterRequestHandlerGroup(boost::shared_ptr<RequestHandlerGroup> requestHandlerGroup) { boost::lock_guard<boost::shared_mutex> lock(mutex); - const std::set<std::string> &types = requestHandlerGroup->getPacketTypes(); - for(std::set<std::string>::const_iterator type = types.begin(); type != types.end(); ++type) { - std::map<std::string, boost::shared_ptr<RequestHandlerGroup> >::iterator it = requestHandlerGroups.find(*type); + const std::set<Core::String> &types = requestHandlerGroup->getPacketTypes(); + for(std::set<Core::String>::const_iterator type = types.begin(); type != types.end(); ++type) { + std::map<Core::String, boost::shared_ptr<RequestHandlerGroup> >::iterator it = requestHandlerGroups.find(*type); if(it == requestHandlerGroups.end() || it->second != requestHandlerGroup) continue; @@ -164,15 +164,15 @@ class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable { } } - template <class T> void registerPacketType(const std::string &type) { + template <class T> void registerPacketType(const Core::String &type) { registerRequestHandlerGroup(boost::shared_ptr<RequestHandlerFactory0<T> >(new RequestHandlerFactory0<T>(type))); } - template <class T, class T1> void registerPacketType(const std::string &type, T1 arg1) { + template <class T, class T1> void registerPacketType(const Core::String &type, T1 arg1) { registerRequestHandlerGroup(boost::shared_ptr<RequestHandlerFactory1<T, T1> >(new RequestHandlerFactory1<T, T1>(type, arg1))); } - void unregisterPacketType(const std::string &type) { + void unregisterPacketType(const Core::String &type) { boost::lock_guard<boost::shared_mutex> lock(mutex); requestHandlerGroups.erase(type); } |