00001 // $Id: MIHMessageRegistry.ct 1789 2011-05-19 09:31:33Z tho $ 00002 // 00003 // Copyright (C) 2011 00004 // Fraunhofer (FOKUS) 00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY 00006 // Thorsten Horstmann <tho@berlios.de> 00007 // 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the 00020 // Free Software Foundation, Inc., 00021 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 00026 // Custom includes 00027 #include "Exceptions.hh" 00028 00029 #define prefix_ 00030 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00031 // senf::MIHMessageRegistry 00032 00033 template <typename MIHPacket> 00034 prefix_ void senf::MIHMessageRegistry::registerMessageType() 00035 { 00036 key_t key (MIHPacket::type::MESSAGE_ID+0); 00037 map_.insert(key, new detail::MIHMessageRegistryEntry<MIHPacket>() ); 00038 } 00039 00040 template <typename MIHPacket> 00041 prefix_ senf::MIHMessageRegistry::RegistrationProxy<MIHPacket>::RegistrationProxy() 00042 { 00043 MIHMessageRegistry::instance().registerMessageType<MIHPacket>(); 00044 } 00045 00046 template <typename MIHPacket> 00047 prefix_ void senf::detail::MIHMessageRegistryEntry<MIHPacket, true>::validate(senf::Packet message) 00048 const 00049 { 00050 if (! message.is<MIHPacket>()) 00051 throw InvalidMIHPacketException("invalid packet chain"); 00052 MIHPacket::type::validate(message.as<MIHPacket>()); 00053 } 00054 00055 00056 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00057 #undef prefix_ 00058 00059 00060 // Local Variables: 00061 // mode: c++ 00062 // fill-column: 100 00063 // comment-column: 40 00064 // c-file-style: "senf" 00065 // indent-tabs-mode: nil 00066 // ispell-local-dictionary: "american" 00067 // compile-command: "scons -u test" 00068 // End: