// (C) Copyright Jonathan Turkanis 2004.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
// Disclaimer: Not a Boost library.
#ifndef BOOST_IDL_SUBINTERFACE_HPP_INCLUDED
#define BOOST_IDL_SUBINTERFACE_HPP_INCLUDED
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/interfaces/access.hpp>
#include <boost/interfaces/detail/flags.hpp>
#include <boost/interfaces/detail/generate.hpp>
#include <boost/interfaces/detail/macros/template_decl.hpp>
#include <boost/interfaces/detail/macros/template_args.hpp>
#include <boost/interfaces/interface_fwd.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/transform_view.hpp>
#include <boost/preprocessor/control/expr_if.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
namespace boost { namespace interfaces {
//------------------Definition of helper templates----------------------------//
namespace detail {
template<typename Subinterface, typename Superinterfaces>
struct subinterface_traits {
template< typename Derived,
typename Flags = flags::default_,
typename Base = detail::empty_base >
struct generator_impl {
struct get_generator {
template<typename Interface>
struct apply {
typedef typename Interface::template
generator<Derived, Flags, Base> type;
};
};
typedef typename
mpl::transform_view<
Superinterfaces,
get_generator
>::type generators;
typedef typename
mpl::fold<
generators,
empty_base,
generate
>::type type;
typedef typename type::interface_table interface_table;
};
template< typename Derived,
typename Flags = flags::default_,
typename Base = detail::empty_base >
struct generator
: generator_impl<Derived, Flags, Base>::type
{ };
struct type : generator<Subinterface> {
template< typename Derived,
typename Flags = flags::default_,
typename Base = detail::empty_base >
struct generator
: subinterface_traits<Subinterface, Superinterfaces>
::template generator<Derived, Flags, Base>
{ };
};
};
} // End namespace detail.
//------------------Definition of class template subinterface-----------------//
template<typename Subinterface, typename Superinterfaces>
class subinterface
: public detail::subinterface_traits<
Subinterface, Superinterfaces
>::type
{
private:
friend class interface_core_access;
typedef typename
detail::subinterface_traits<
Subinterface, Superinterfaces
>::type base_type;
protected:
typedef subinterface subinterface_;
public:
typedef Superinterfaces superinterfaces;
typedef typename base_type::interface_table interface_table;
};
//------------------Definition of subinterface macros-------------------------//
#define BOOST_SUBINTERFACE_BEGIN(name) \
struct BOOST_PP_CAT(name, _subinterface_impl_) \
: ::boost::mpl::identity< ::boost::mpl::list< \
/**/
#define BOOST_SUBINTERFACE_TEMPLATE_BEGIN(name, arity) \
BOOST_SUBINTERFACE_BEGIN(name) \
/**/
#define BOOST_SUPERINTERFACE(name) name,
#define BOOST_SUBINTERFACE_END_IMPL(name, arity) ::boost::mpl::na> > { }; \
BOOST_IDL_TEMPLATE_DECL(arity, XXX_) \
struct name : ::boost::interfaces::subinterface< \
name BOOST_IDL_TEMPLATE_ARGS(arity, XXX_), \
BOOST_PP_EXPR_IF(arity, typename) \
BOOST_PP_CAT(name, _subinterface_impl_) \
BOOST_IDL_TEMPLATE_ARGS(arity, XXX_)::type \
> \
{ \
friend class ::boost::interfaces::access; \
typedef BOOST_PP_EXPR_IF(arity, typename) \
::boost::interfaces::subinterface< \
name BOOST_IDL_TEMPLATE_ARGS(arity, XXX_), \
BOOST_PP_EXPR_IF(arity, typename) \
BOOST_PP_CAT(name, _subinterface_impl_) \
BOOST_IDL_TEMPLATE_ARGS(arity, XXX_)::type \
> base_type; \
typedef BOOST_PP_EXPR_IF(arity, typename) \
base_type::interface_table interface_table; \
template<typename XXX_> \
struct interface_functions \
: base_type::template interface_functions<XXX_>, \
::boost::interfaces::detail::table_holder<interface_table, XXX_> \
{ \
using ::boost::interfaces::detail \
::table_holder<interface_table, XXX_>::m_table_; \
}; \
BOOST_IDL_CTORS(name, XXX_) \
BOOST_IDL_CORE_INTERFACE_SUPPORT(name) \
}; \
template< typename XXX_ BOOST_PP_COMMA_IF(arity) \
BOOST_PP_ENUM_PARAMS(arity, typename YYY_) > \
::boost::type_traits::yes_type \
is_interface_helper( name BOOST_IDL_TEMPLATE_ARGS(arity, YYY_)*, \
XXX_*, \
typename \
::boost::interfaces::detail::enable_if_same< \
XXX_, \
name BOOST_IDL_TEMPLATE_ARGS(arity, YYY_) \
>::type* = 0 ); \
/**/
#define BOOST_SUBINTERFACE_END(name) BOOST_SUBINTERFACE_END_IMPL(name, 0)
#define BOOST_SUBINTERFACE_TEMPLATE_END(name, arity) \
BOOST_SUBINTERFACE_END_IMPL(name, arity) \
/**/
} } // End namespaces interfaces, boost.
#endif // #ifndef BOOST_IDL_SUBINTERFACE_HPP_INCLUDED
//// (C) Copyright Jonathan Turkanis 2004.
//// Distributed under the Boost Software License, Version 1.0. (See accompanying
//// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
//
//// Disclaimer: Not a Boost library.
//
//#ifndef BOOST_IDL_SUBINTERFACE_HPP_INCLUDED
//#define BOOST_IDL_SUBINTERFACE_HPP_INCLUDED
//
//#if defined(_MSC_VER) && (_MSC_VER >= 1020)
//# pragma once
//#endif
//
//#include <boost/interfaces/access.hpp>
//#include <boost/interfaces/detail/flags.hpp>
//#include <boost/interfaces/detail/generate.hpp>
//#include <boost/interfaces/detail/template_params.hpp>
//#include <boost/interfaces/interface_fwd.hpp>
//#include <boost/mpl/at.hpp>
//#include <boost/mpl/aux_/na.hpp>
//#include <boost/mpl/fold.hpp>
//#include <boost/mpl/identity.hpp>
//#include <boost/mpl/list.hpp>
//#include <boost/mpl/range_c.hpp>
//#include <boost/mpl/size.hpp>
//#include <boost/mpl/transform_view.hpp>
//#include <boost/preprocessor/control/expr_if.hpp>
//#include <boost/preprocessor/punctuation/comma_if.hpp>
//#include <boost/preprocessor/repetition/enum_params.hpp>
//
//namespace boost { namespace interfaces {
//
////------------------Definition of helper templates----------------------------//
//
//namespace detail {
//
//template<typename Subinterface, typename Superinterfaces>
//struct subinterface_traits {
// template< typename Derived,
// typename Flags = flags::default_,
// typename Base = detail::empty_base >
// struct generator_impl {
// struct get_generator {
// template<typename Interface>
// struct apply {
// typedef typename Interface::template
// generator<Derived, Flags, Base> type;
// };
// };
// typedef typename
// mpl::transform_view<
// Superinterfaces,
// get_generator
// >::type generators;
// typedef typename
// mpl::fold<
// generators,
// empty_base,
// generate
// >::type type;
// typedef typename type::interface_table interface_table;
// };
//
// template< typename Derived,
// typename Flags = flags::default_,
// typename Base = detail::empty_base >
// struct generator
// : generator_impl<Derived, Flags, Base>::type
// { };
//
// struct type : generator<Subinterface> {
// template< typename Derived,
// typename Flags = flags::default_,
// typename Base = detail::empty_base >
// struct generator
// : subinterface_traits<Subinterface, Superinterfaces>
// ::template generator<Derived, Flags, Base>
// { };
// };
//};
//
//} // End namespace detail.
//
////------------------Definition of class template subinterface-----------------//
//
//template<typename Subinterface, typename Superinterfaces>
//class subinterface
// : public detail::subinterface_traits<
// Subinterface, Superinterfaces
// >::type
//{
//private:
// friend class interface_core_access;
// typedef typename
// detail::subinterface_traits<
// Subinterface, Superinterfaces
// >::type base_type;
//protected:
// typedef subinterface subinterface_;
//public:
// typedef Superinterfaces superinterfaces;
// typedef typename base_type::interface_table interface_table;
//};
//
////------------------Definition of subinterface macros-------------------------//
//
//#define BOOST_SUBINTERFACE_BEGIN(name) \
// struct BOOST_PP_CAT(name, _subinterface_impl_) \
// : ::boost::mpl::identity< ::boost::mpl::list< \
// /**/
//
//#define BOOST_SUBINTERFACE_TEMPLATE_BEGIN(name, arity) \
// BOOST_SUBINTERFACE_BEGIN(name) \
// /**/
//
//#define BOOST_SUPERINTERFACE(name) name,
//
//#define BOOST_SUBINTERFACE_END_IMPL(name, arity) ::boost::mpl::na> > { }; \
// BOOST_IDL_TEMPLATE_DECL(arity, XXX_) \
// struct name : ::boost::interfaces::subinterface< \
// name BOOST_IDL_TEMPLATE_ARGS(arity, XXX_), \
// BOOST_PP_EXPR_IF(arity, typename) \
// BOOST_PP_CAT(name, _subinterface_impl_) \
// BOOST_IDL_TEMPLATE_ARGS(arity, XXX_)::type \
// > \
// { \
// friend class ::boost::interfaces::access; \
// typedef BOOST_PP_EXPR_IF(arity, typename) \
// ::boost::interfaces::subinterface< \
// name BOOST_IDL_TEMPLATE_ARGS(arity, XXX_), \
// BOOST_PP_EXPR_IF(arity, typename) \
// BOOST_PP_CAT(name, _subinterface_impl_) \
// BOOST_IDL_TEMPLATE_ARGS(arity, XXX_)::type \
// > base_type; \
// typedef BOOST_PP_EXPR_IF(arity, typename) \
// base_type::interface_table interface_table; \
// template<typename XXX_> \
// struct interface_functions \
// : base_type::template interface_functions<XXX_> \
// { static const interface_table m_table_; }; \
// BOOST_IDL_CTORS(name, XXX_) \
// BOOST_IDL_CORE_INTERFACE_SUPPORT(name) \
// }; \
// BOOST_IDL_TEMPLATE_DECL(arity, XXX_) \
// template<typename XXX_> \
// const BOOST_PP_EXPR_IF(arity, typename) name \
// BOOST_IDL_TEMPLATE_ARGS(arity, XXX_)::interface_table \
// name BOOST_IDL_TEMPLATE_ARGS(arity, XXX_)::template \
// interface_functions<XXX_>::m_table_ = \
// ::boost::mpl::identity<XXX_>(); \
// template< typename XXX_ BOOST_PP_COMMA_IF(arity) \
// BOOST_PP_ENUM_PARAMS(arity, typename YYY_) > \
// ::boost::type_traits::yes_type \
// is_interface_helper( name BOOST_IDL_TEMPLATE_ARGS(arity, YYY_)*, \
// XXX_*, \
// typename \
// ::boost::interfaces::detail::enable_if_same< \
// XXX_, \
// name BOOST_IDL_TEMPLATE_ARGS(arity, YYY_) \
// >::type* = 0 ); \
// /**/
//
//#define BOOST_SUBINTERFACE_END(name) BOOST_SUBINTERFACE_END_IMPL(name, 0)
//
//#define BOOST_SUBINTERFACE_TEMPLATE_END(name, arity) \
// BOOST_SUBINTERFACE_END_IMPL(name, arity) \
// /**/
//
//} } // End namespaces interfaces, boost.
//
//#endif // #ifndef BOOST_IDL_SUBINTERFACE_HPP_INCLUDED