// $Id$
//
-// Copyright (C) 2006
+// Copyright (C) 2006
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
// Stefan Bund <stefan.bund@fokus.fraunhofer.de>
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+/** \file
+ \brief Policy Framework internal header
+ */
+
#ifndef IH_SocketPolicy_
#define IH_SocketPolicy_ 1
#include <boost/mpl/and.hpp>
#include <boost/utility.hpp> // for enable_if
-#include "GenericSockAddr.hh"
-
///////////////////////////////ih.p////////////////////////////////////////
-namespace senf {
+/// \cond disabled
+// Hide this code from doxygen
+namespace senf {
# define SENF_SOCKET_POLICIES_N BOOST_PP_SEQ_SIZE( SENF_SOCKET_POLICIES )
-
- // This REALLY is bad ... but we just need an Address member in
- // AddressingPolicyBase as long as ClientSocketHandle /
- // ServerSocketHandle don't make use of enable_if for each and
- // every member they define ...
- struct AddressingPolicyBase
- {
- virtual ~ AddressingPolicyBase() {}
-
- typedef GenericSockAddr Address;
- };
-
-# define SP_DeclareBase(x1,x2,SomePolicy) \
- struct BOOST_PP_CAT(SomePolicy,Base) \
- { virtual ~ BOOST_PP_CAT(SomePolicy,Base) () {} }; \
+# define SP_DeclareAlias(x1,x2,SomePolicy) \
typedef BOOST_PP_CAT(SomePolicy,Base) BOOST_PP_CAT(Unspecified,SomePolicy);
- BOOST_PP_SEQ_FOR_EACH( SP_DeclareBase, , BOOST_PP_SEQ_POP_FRONT( SENF_SOCKET_POLICIES ) )
+ BOOST_PP_SEQ_FOR_EACH( SP_DeclareAlias, , SENF_SOCKET_POLICIES )
+
+# undef SP_DeclareAlias
-# undef SP_DeclareBase
-
struct SocketPolicyBase
{
virtual ~SocketPolicyBase() {}
-# define SP_DeclareTypedef(x1,x2,SomePolicy) \
- typedef BOOST_PP_CAT(SomePolicy,Base) SomePolicy; \
- BOOST_PP_CAT(SomePolicy,Base) BOOST_PP_CAT(BOOST_PP_CAT(the,SomePolicy),_); \
- virtual BOOST_PP_CAT(SomePolicy,Base) const & BOOST_PP_CAT(the,SomePolicy) () const \
- { return BOOST_PP_CAT(BOOST_PP_CAT(the,SomePolicy),_); }
+# define SP_Declare(x1,x2,SomePolicy) \
+ virtual BOOST_PP_CAT(SomePolicy,Base) const & BOOST_PP_CAT(the,SomePolicy) () const = 0;
- BOOST_PP_SEQ_FOR_EACH( SP_DeclareTypedef, , SENF_SOCKET_POLICIES )
+ BOOST_PP_SEQ_FOR_EACH( SP_Declare, , SENF_SOCKET_POLICIES )
-# undef SP_DeclareTypedef
+# undef SP_Declare
};
# define SP_TemplateArgs(x1,x2,n,SomePolicy) \
template <int N>
struct SocketPolicy_rv
{ int v[N+1]; };
-
+
template <class Base, class Policy, int N>
struct MakeSocketPolicy_merge
{};
BOOST_PP_IIF( BOOST_PP_EQUAL(n,m), Policy, typename Base::SomePolicy )
# define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_DEC( SENF_SOCKET_POLICIES_N ) )
-# define BOOST_PP_LOCAL_MACRO(n) \
- SocketPolicy_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>)> \
- { \
- typedef SocketPolicy< \
- BOOST_PP_SEQ_FOR_EACH_I( SP_DeclareMakeSocketPolicy_merge_member, n, SENF_SOCKET_POLICIES ) \
- > type; \
+# define BOOST_PP_LOCAL_MACRO(n) \
+ SocketPolicy_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>)> \
+ { \
+ typedef SocketPolicy< \
+ BOOST_PP_SEQ_FOR_EACH_I( SP_DeclareMakeSocketPolicy_merge_member, n, SENF_SOCKET_POLICIES ) \
+ > type; \
};
# include BOOST_PP_LOCAL_ITERATE()
};
# define SP_DeclareArguments(x1,x2,n,SomePolicy) \
- BOOST_PP_COMMA_IF( n ) \
- typename Base::SomePolicy *
+ BOOST_PP_COMMA_IF( n ) \
+ typename Base::SomePolicy *
template <class Base>
SocketPolicy_rv<1> SocketPolicy_checkcompat_(
# undef SP_DeclareArguments
template <class Base>
- SocketPolicy_rv<2> SocketPolicy_checkcompat_(
- BOOST_PP_ENUM_PARAMS( SENF_SOCKET_POLICIES_N, void * BOOST_PP_INTERCEPT ) );
+ SocketPolicy_rv<2> SocketPolicy_checkcompat_( ... );
template <int Size>
struct SocketPolicy_checkcompat
}
+/// \endcond
+
///////////////////////////////ih.e////////////////////////////////////////
#endif
\f
// Local Variables:
// mode: c++
+// fill-column: 100
// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
// End: