Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
| 2 | // (C) Copyright Tobias Schwinger |
| 3 | // |
| 4 | // Use modification and distribution are subject to the boost Software License, |
| 5 | // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt). |
| 6 | |
| 7 | //------------------------------------------------------------------------------ |
| 8 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 9 | #ifndef NDNBOOST_FT_DETAIL_TAGS_HPP_INCLUDED |
| 10 | #define NDNBOOST_FT_DETAIL_TAGS_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 11 | |
| 12 | #include <cstddef> |
| 13 | |
| 14 | #include <ndnboost/type_traits/integral_constant.hpp> |
| 15 | #include <ndnboost/mpl/bitxor.hpp> |
| 16 | |
| 17 | |
| 18 | namespace ndnboost { namespace function_types { |
| 19 | |
| 20 | namespace detail |
| 21 | { |
| 22 | typedef long bits_t; |
| 23 | |
| 24 | template<bits_t Value> struct constant |
| 25 | : ndnboost::integral_constant<bits_t,Value> |
| 26 | { }; |
| 27 | |
| 28 | template<bits_t Bits, bits_t Mask> struct property_tag |
| 29 | { |
| 30 | typedef constant<Bits> bits; |
| 31 | typedef constant<Mask> mask; |
| 32 | }; |
| 33 | |
| 34 | template<typename T> struct bits : T::bits { }; |
| 35 | template<typename T> struct mask : T::mask { }; |
| 36 | |
| 37 | // forward declaration, defined in pp_tags |
| 38 | template<bits_t Bits, bits_t CCID> struct encode_bits_impl; |
| 39 | |
| 40 | // forward declaration, defined in pp_tags |
| 41 | template<bits_t LHS_bits, bits_t LHS_mask, |
| 42 | bits_t RHS_bits, bits_t RHS_mask> |
| 43 | struct tag_ice; |
| 44 | |
| 45 | // forward declaration, defined in retag_default_cc |
| 46 | template<class Tag, class RegTag = Tag> struct retag_default_cc; |
| 47 | |
| 48 | template<bits_t Bits, bits_t CCID> struct encode_bits |
| 49 | : constant< |
| 50 | ::ndnboost::function_types::detail::encode_bits_impl<Bits,CCID>::value |
| 51 | > |
| 52 | { }; |
| 53 | |
| 54 | template<class LHS, class RHS> struct compound_tag |
| 55 | { |
| 56 | typedef constant< |
| 57 | ::ndnboost::function_types::detail::tag_ice |
| 58 | < ::ndnboost::function_types::detail::bits<LHS>::value |
| 59 | , ::ndnboost::function_types::detail::mask<LHS>::value |
| 60 | , ::ndnboost::function_types::detail::bits<RHS>::value |
| 61 | , ::ndnboost::function_types::detail::mask<RHS>::value |
| 62 | >::combined_bits |
| 63 | > bits; |
| 64 | |
| 65 | typedef constant< |
| 66 | ::ndnboost::function_types::detail::tag_ice |
| 67 | < ::ndnboost::function_types::detail::bits<LHS>::value |
| 68 | , ::ndnboost::function_types::detail::mask<LHS>::value |
| 69 | , ::ndnboost::function_types::detail::bits<RHS>::value |
| 70 | , ::ndnboost::function_types::detail::mask<RHS>::value |
| 71 | >::combined_mask |
| 72 | > mask; |
| 73 | }; |
| 74 | |
| 75 | template <class Base, class PropOld, class PropNew> |
| 76 | struct changed_tag |
| 77 | : Base |
| 78 | { |
| 79 | typedef mpl::bitxor_ |
| 80 | <typename Base::bits, typename PropOld::bits, typename PropNew::bits> |
| 81 | bits; |
| 82 | }; |
| 83 | |
| 84 | template<class Tag, class QueryTag> struct represents_impl |
| 85 | : ndnboost::integral_constant<bool, |
| 86 | ::ndnboost::function_types::detail::tag_ice |
| 87 | < ::ndnboost::function_types::detail::bits<Tag>::value |
| 88 | , ::ndnboost::function_types::detail::mask<Tag>::value |
| 89 | , ::ndnboost::function_types::detail::bits<QueryTag>::value |
| 90 | , ::ndnboost::function_types::detail::mask<QueryTag>::value |
| 91 | >::match |
| 92 | > |
| 93 | { }; |
| 94 | |
| 95 | } // namespace detail |
| 96 | |
| 97 | typedef detail::property_tag<0,0> null_tag; |
| 98 | |
| 99 | template<class Tag1, class Tag2, class Tag3 = null_tag, class Tag4 = null_tag> |
| 100 | struct tag |
| 101 | : detail::compound_tag< detail::compound_tag<Tag1,Tag2>, |
| 102 | detail::compound_tag<Tag3,Tag4> > |
| 103 | { }; |
| 104 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 105 | #ifndef NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 106 | template<class Tag1, class Tag2, class Tag3> struct tag<Tag1,Tag2,Tag3,null_tag> |
| 107 | : detail::compound_tag<detail::compound_tag<Tag1,Tag2>,Tag3> |
| 108 | { }; |
| 109 | template<class Tag1, class Tag2> struct tag<Tag1,Tag2,null_tag,null_tag> |
| 110 | : detail::compound_tag<Tag1,Tag2> |
| 111 | { }; |
| 112 | template<class Tag1> struct tag<Tag1,null_tag,null_tag,null_tag> |
| 113 | : Tag1 |
| 114 | { }; |
| 115 | #endif |
| 116 | |
| 117 | |
| 118 | template<class Tag, class QueryTag> struct represents |
| 119 | : detail::represents_impl<Tag, detail::retag_default_cc<QueryTag,Tag> > |
| 120 | { }; |
| 121 | |
| 122 | |
| 123 | template<class Tag, class QueryTag> struct extract |
| 124 | { |
| 125 | typedef detail::constant< |
| 126 | ::ndnboost::function_types::detail::tag_ice |
| 127 | < ::ndnboost::function_types::detail::bits<Tag>::value |
| 128 | , ::ndnboost::function_types::detail::mask<Tag>::value |
| 129 | , ::ndnboost::function_types::detail::bits<QueryTag>::value |
| 130 | , ::ndnboost::function_types::detail::mask<QueryTag>::value |
| 131 | >::extracted_bits |
| 132 | > bits; |
| 133 | |
| 134 | typedef detail::constant< |
| 135 | ::ndnboost::function_types::detail::mask<QueryTag>::value |
| 136 | > mask; |
| 137 | }; |
| 138 | |
| 139 | } } // namespace ::ndnboost::function_types |
| 140 | |
| 141 | #include <ndnboost/function_types/detail/pp_tags/preprocessed.hpp> |
| 142 | |
| 143 | namespace ndnboost { namespace function_types { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 144 | #define NDNBOOST_FT_cc_file <ndnboost/function_types/detail/pp_tags/cc_tag.hpp> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 145 | #include <ndnboost/function_types/detail/pp_loop.hpp> |
| 146 | } } // namespace ndnboost::function_types |
| 147 | |
| 148 | #endif |
| 149 | |