AttributeSetProvider.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef _Set_Provider_h_
00042 #define _Set_Provider_h_
00043
00044 #include "boost/mpl/aux_/na.hpp"
00045 #include "boost/utility/enable_if.hpp"
00046 #include "boost/mpl/vector.hpp"
00047 #include "boost/mpl/is_sequence.hpp"
00048 #include "boost/mpl/sort.hpp"
00049 #include "boost/mpl/eval_if.hpp"
00050 #include "boost/mpl/bool.hpp"
00051
00052 #include "mw/attributes/AttributeSet.h"
00053 #include "mw/attributes/type_traits/is_attribute.h"
00054
00055 #include "assert/staticerror.h"
00056
00057 namespace famouso {
00058 namespace mw {
00059 namespace attributes {
00060 namespace detail {
00069 template <typename Attr, typename InnerEnable = void>
00070 struct assert_is_attribute_or_na {
00071 FAMOUSO_STATIC_ASSERT_ERROR(
00072 false,
00073 template_argument_no_attribute_and_not_na,
00074 (Attr));
00075
00076 typedef void type;
00077 };
00078
00079 template <>
00080 struct assert_is_attribute_or_na<boost::mpl::na, void> {
00081 typedef void type;
00082 };
00083
00084 template <typename Attr>
00085 struct assert_is_attribute_or_na<
00086 Attr,
00087 typename boost::enable_if<
00088 famouso::mw::attributes::type_traits::is_attribute<
00089 Attr
00090 >
00091 >::type
00092 > {
00093 typedef void type;
00094 };
00095
00096 template <typename T>
00097 struct is_sequence : boost::mpl::is_sequence<T> { };
00098
00099 template <>
00100 struct is_sequence<boost::mpl::na> {
00101 typedef is_sequence type;
00102
00103 static const bool value = false;
00104 };
00105
00106 struct SorterPredicate {
00107
00108 template <typename A1, typename A2>
00109 struct apply {
00110 static const bool value = A1::id > A2::id;
00111
00112 typedef apply type;
00113 };
00114
00115
00116 template <typename T1>
00117 struct apply<T1, boost::mpl::na> {
00118 static const bool value = true;
00119
00120 typedef apply type;
00121 };
00122
00123
00124 template <typename T2>
00125 struct apply<boost::mpl::na, T2> : public apply<T2, boost::mpl::na> {};
00126
00127 typedef SorterPredicate type;
00128 };
00129
00130 template <typename Seq>
00131 struct SortedAttributeSequence {
00132 typedef typename boost::mpl::sort<Seq, SorterPredicate>::type result;
00133
00134 typedef SortedAttributeSequence type;
00135 };
00136
00167 template <typename A1 = boost::mpl::na, typename A2 = boost::mpl::na,
00168 typename A3 = boost::mpl::na, typename A4 = boost::mpl::na,
00169 typename A5 = boost::mpl::na, typename A6 = boost::mpl::na,
00170 typename A7 = boost::mpl::na, typename A8 = boost::mpl::na,
00171 typename A9 = boost::mpl::na, typename A10 = boost::mpl::na,
00172 typename Enable = void>
00173 struct SetProvider {
00174
00175
00176
00177 private:
00178
00179
00180 typedef typename assert_is_attribute_or_na<A1>::type aa1;
00181 typedef typename assert_is_attribute_or_na<A2>::type aa2;
00182 typedef typename assert_is_attribute_or_na<A3>::type aa3;
00183 typedef typename assert_is_attribute_or_na<A4>::type aa4;
00184 typedef typename assert_is_attribute_or_na<A5>::type aa5;
00185 typedef typename assert_is_attribute_or_na<A6>::type aa6;
00186 typedef typename assert_is_attribute_or_na<A7>::type aa7;
00187 typedef typename assert_is_attribute_or_na<A8>::type aa8;
00188 typedef typename assert_is_attribute_or_na<A9>::type aa9;
00189 typedef typename assert_is_attribute_or_na<A10>::type aa10;
00190
00191
00192
00193 typedef typename SortedAttributeSequence<
00194 boost::mpl::vector<A1, A2, A3, A4, A5,
00195 A6, A7, A8, A9, A10
00196 >
00197 >::result attribs;
00198
00199 public:
00203 typedef attributes::AttributeSet<attribs> attrSet;
00204 };
00205
00206 template <typename ForwardSeq>
00207 struct SetProvider<ForwardSeq, boost::mpl::na, boost::mpl::na,
00208 boost::mpl::na, boost::mpl::na, boost::mpl::na,
00209 boost::mpl::na, boost::mpl::na, boost::mpl::na,
00210 boost::mpl::na,
00211 typename boost::enable_if<
00212 is_sequence<ForwardSeq>
00213 >::type> {
00214
00215
00216
00217 typedef typename SortedAttributeSequence<
00218 ForwardSeq
00219 >::result attribs;
00220
00221 public:
00225 typedef attributes::AttributeSet<attribs> attrSet;
00226 };
00227
00228 }
00229 }
00230 }
00231 }
00232
00233 #endif // _Set_Provider_