switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Packets / 80221Bundle / MIHMessageRegistry.ih
1 // $Id$
2 //
3 // Copyright (C) 2010
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Thorsten Horstmann <tho@berlios.de>
27
28 /** \file
29     \brief MIH Message-Registry internal header */
30
31 #ifndef IH_SENF_Packets_80221Bundle_MIHMessageRegistry_
32 #define IH_SENF_Packets_80221Bundle_MIHMessageRegistry_ 1
33
34 // Custom includes
35
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37 namespace senf {
38
39     namespace detail {
40
41         template<class T, typename Signature>
42         struct has_static_validate_member
43         {
44             template<Signature *>
45             struct helper;
46
47             template<class U>
48             static char test(helper<&U::validate> *);
49
50             template<class U>
51             static char (&test(...))[2];
52
53             static const bool value = sizeof(test<T>(0))==1;
54         };
55
56
57         struct MIHMessageRegistry_EntryBase {
58             virtual ~MIHMessageRegistry_EntryBase() {}
59             virtual void validate(senf::Packet message) const = 0;
60         };
61
62
63         template <class MIHPacket,
64             bool use_validate_member = has_static_validate_member<typename MIHPacket::type, void(MIHPacket)>::value>
65         struct MIHMessageRegistryEntry : MIHMessageRegistry_EntryBase
66         {
67             virtual void validate(senf::Packet message) const {}
68         };
69
70         template <class MIHPacket>
71         struct MIHMessageRegistryEntry<MIHPacket, true> : MIHMessageRegistry_EntryBase
72         {
73             virtual void validate(senf::Packet message) const;
74         };
75
76     }
77 }
78 //-/////////////////////////////////////////////////////////////////////////////////////////////////
79 #endif
80
81
82 \f
83 // Local Variables:
84 // mode: c++
85 // fill-column: 100
86 // c-file-style: "senf"
87 // indent-tabs-mode: nil
88 // ispell-local-dictionary: "american"
89 // compile-command: "scons -u test"
90 // comment-column: 40
91 // End: