#ifndef HANDLER_MAPPER_H
#define HANDLER_MAPPER_H

#include <map>

class CommandClient;

typedef void (CommandClient::*TMessageHandler)(message *);

class ValueNotInMessageException : public std::exception {
private:
	std::string name_;
public:
	ValueNotInMessageException(const std::string & name) {
		name_ = name;
	}
};

class HandlerWrapper {
private:	
	std::map<const std::string, TMessageHandler> mapping_;
public:
	TMessageHandler findHandler(const std::string & requestName) {
		std::map<const std::string, TMessageHandler>::const_iterator cit = mapping_.find(requestName);

		if (cit != mapping_.end()) {
			return (*cit).second;
		}
		else {
			return NULL;
		}
	}

	void addHandler(const std::string & requestName, TMessageHandler handler) {
		mapping_.insert(std::pair<const std::string, TMessageHandler>(requestName, handler));		
	}
};

#endif