PPI: Add missing TargetDgramWriter doku
[senf.git] / Socket / SocketPolicy.ih
index 6d41c69..b335280 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
 // Copyright (C) 2006
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -24,8 +24,8 @@
     \brief Policy Framework internal header
  */
 
-#ifndef IH_SocketPolicy_
-#define IH_SocketPolicy_ 1
+#ifndef IH_SENF_Socket_SocketPolicy_
+#define IH_SENF_Socket_SocketPolicy_ 1
 
 // Custom includes
 #include <boost/preprocessor/seq/for_each.hpp>
@@ -50,7 +50,8 @@
 #include <boost/mpl/and.hpp>
 #include <boost/utility.hpp> // for enable_if
 
-#include "Utils/pool_alloc_mixin.hh"
+#include "../Utils/mpl.hh"
+#include "../Utils/pool_alloc_mixin.hh"
 
 ///////////////////////////////ih.p////////////////////////////////////////
 
@@ -70,7 +71,7 @@ namespace senf {
 
     struct SocketPolicyBase
     {
-        virtual ~SocketPolicyBase() {}
+        virtual ~SocketPolicyBase();
 
 #       define SP_Declare(x1,x2,SomePolicy)                                                       \
             virtual BOOST_PP_CAT(SomePolicy,Base) const & BOOST_PP_CAT(the,SomePolicy) ()         \
@@ -110,13 +111,7 @@ namespace senf {
 
 namespace impl {
 
-    struct nil {};
-
-    template <int N>
-    struct SocketPolicy_rv
-    { int v[N+1]; };
-
-    template <class Base, class Policy, int N>
+    template <class Base, class Policy, int _>
     struct MakeSocketPolicy_merge
     {};
 
@@ -126,11 +121,11 @@ namespace impl {
 
 #    define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_DEC( SENF_SOCKET_POLICIES_N ) )
 #    define BOOST_PP_LOCAL_MACRO(n)                                                               \
-        SocketPolicy_rv<n> MakeSocketPolicy_merge_(                                               \
+        senf::mpl::rv<n> MakeSocketPolicy_merge_(                                                 \
             BOOST_PP_CAT( BOOST_PP_SEQ_ELEM( n, SENF_SOCKET_POLICIES ),Base)*);                   \
                                                                                                   \
         template <class Base, class Policy>                                                       \
-        struct MakeSocketPolicy_merge<Base,Policy,sizeof(SocketPolicy_rv<n>)>                     \
+        struct MakeSocketPolicy_merge<Base,Policy,n>                                              \
         {                                                                                         \
             typedef SocketPolicy<                                                                 \
                BOOST_PP_SEQ_FOR_EACH_I( SP_DeclareMakeSocketPolicy_merge_member,                  \
@@ -149,11 +144,11 @@ namespace impl {
         struct apply
             : MakeSocketPolicy_merge<Base,
                                      Policy,
-                                     sizeof(MakeSocketPolicy_merge_(static_cast<Policy*>(0)))>
+                                     SENF_MPL_RV(MakeSocketPolicy_merge_(static_cast<Policy*>(0)))>
         {};
 
         template <class Base>
-        struct apply<Base,nil>
+        struct apply<Base,mpl::nil>
         {
             typedef Base type;
         };
@@ -170,13 +165,13 @@ namespace impl {
         typename Base::SomePolicy *
 
     template <class Base>
-    SocketPolicy_rv<1> SocketPolicy_checkcompat_(
+    senf::mpl::rv<1> SocketPolicy_checkcompat_(
         BOOST_PP_SEQ_FOR_EACH_I( SP_DeclareArguments, , SENF_SOCKET_POLICIES ) );
 
 #   undef SP_DeclareArguments
 
     template <class Base>
-    SocketPolicy_rv<2> SocketPolicy_checkcompat_( ... );
+    senf::mpl::rv<2> SocketPolicy_checkcompat_( ... );
 
     template <int Size>
     struct SocketPolicy_checkcompat
@@ -184,7 +179,7 @@ namespace impl {
     {};
 
     template<>
-    struct SocketPolicy_checkcompat<sizeof(SocketPolicy_rv<1>)>
+    struct SocketPolicy_checkcompat<1>
         : public boost::true_type
     {};
 
@@ -195,7 +190,7 @@ namespace impl {
 
     template <class Base, class Derived>
     struct SocketPolicy_compatibility
-        : public SocketPolicy_checkcompat< sizeof(
+        : public SocketPolicy_checkcompat< SENF_MPL_RV(
             SocketPolicy_checkcompat_<Base>(
                 BOOST_PP_SEQ_FOR_EACH_I( SP_DeclareArguments, , SENF_SOCKET_POLICIES ) )) >
     {};
@@ -204,7 +199,7 @@ namespace impl {
 
     template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( SENF_SOCKET_POLICIES_N, 
                                                     class T, 
-                                                    senf::impl::nil ) >
+                                                    mpl::nil ) >
     class MakeSocketPolicy
         : public boost::mpl::if_< boost::is_convertible< T0*, SocketPolicyBase* >,
                                   impl::MakeSocketPolicy_impl<