Dispatch::Handler Dispatch::code2handler( Message::type_t type ) { typedef std::map<Message::type_t, Handler> map_type; static map_type handlers; if ( handlers.empty() ) { using namespace MessageTypes; handlers[ NameQuery ] = &Dispatch::namequery_handler; handlers[ NameReply ] = &Dispatch::namereply_handler; handlers[ Opponentname ] = &Dispatch::opponentname_handler; handlers[ Receive ] = &Dispatch::receive_handler; handlers[ Invalidmove ] = &Dispatch::invalidmove_handler; handlers[ Inform ] = &Dispatch::inform_handler; handlers[ Status ] = &Dispatch::status_handler; handlers[ Points ] = &Dispatch::points_handler; handlers[ PlayQuery ] = &Dispatch::playquery_handler; handlers[ PlayReply ] = &Dispatch::playreply_handler; handlers[ Give3Query ] = &Dispatch::give3query_handler; handlers[ Terminate ] = &Dispatch::terminate_handler; // handlers[Reset] = &Dispatch::reset_handler; handlers[ Give3Reply ] = &Dispatch::give3reply_handler; handlers[ PlayReply ] = &Dispatch::playreply_handler; } map_type::iterator resp = handlers.find( type ); if ( resp == handlers.end() ) { LOG_PLACE() << "No handler for " << type << ".\n"; return &Dispatch::error_handler; } return resp->second; }
bool empty() const { return pa.empty(); }