00001 // $Id: MIHMessageRegistry.ih 1789 2011-05-19 09:31:33Z tho $ 00002 // 00003 // Copyright (C) 2010 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 #ifndef IH_SENF_Packets_80221Bundle_MIHMessageRegistry_ 00027 #define IH_SENF_Packets_80221Bundle_MIHMessageRegistry_ 1 00028 00029 // Custom includes 00030 00031 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00032 namespace senf { 00033 00034 namespace detail { 00035 00036 template<class T, typename Signature> 00037 struct has_static_validate_member 00038 { 00039 template<Signature *> 00040 struct helper; 00041 00042 template<class U> 00043 static char test(helper<&U::validate> *); 00044 00045 template<class U> 00046 static char (&test(...))[2]; 00047 00048 static const bool value = sizeof(test<T>(0))==1; 00049 }; 00050 00051 00052 struct MIHMessageRegistry_EntryBase { 00053 virtual ~MIHMessageRegistry_EntryBase() {} 00054 virtual void validate(senf::Packet message) const = 0; 00055 }; 00056 00057 00058 template <class MIHPacket, 00059 bool use_validate_member = has_static_validate_member<typename MIHPacket::type, void(MIHPacket)>::value> 00060 struct MIHMessageRegistryEntry : MIHMessageRegistry_EntryBase 00061 { 00062 virtual void validate(senf::Packet message) const {} 00063 }; 00064 00065 template <class MIHPacket> 00066 struct MIHMessageRegistryEntry<MIHPacket, true> : MIHMessageRegistry_EntryBase 00067 { 00068 virtual void validate(senf::Packet message) const; 00069 }; 00070 00071 } 00072 } 00073 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00074 #endif 00075 00076 00077 00078 // Local Variables: 00079 // mode: c++ 00080 // fill-column: 100 00081 // c-file-style: "senf" 00082 // indent-tabs-mode: nil 00083 // ispell-local-dictionary: "american" 00084 // compile-command: "scons -u test" 00085 // comment-column: 40 00086 // End: