dune-fem  2.4.1-rc
selector.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_PASS_COMMON_SELECTOR_HH
2 #define DUNE_FEM_PASS_COMMON_SELECTOR_HH
3 
4 #include <type_traits>
5 #include <tuple>
6 
7 #include <dune/common/tuples.hh>
8 #include <dune/common/tupleutility.hh>
9 #include <dune/common/typetraits.hh>
10 
12 
13 namespace Dune
14 {
15 
16  namespace Fem
17  {
18 
19  // ElementTuple
20  // ------------
21 
22  /*
23  * \brief A helper class that transforms a number of integers to a tuple.
24  * Result type is:
25  * \code
26  * std::tuple< Dune::integral_constant< int, N1 >, ..., Dune::integral_constant< int, Nk > >
27  * \endcode
28  *
29  * \note Terminatory integer values (-1) are cut off from tuple
30  */
31  template< int N1,
32  int N2,
33  int N3,
34  int N4,
35  int N5,
36  int N6,
37  int N7,
38  int N8,
39  int N9,
40  class Seed = std::tuple<>
41  >
43  {
44  typedef typename Dune::PushBackTuple< Seed, std::integral_constant< int, N1 > >::type AccumulatedType;
45 
46  public:
47  typedef typename ElementTuple< N2, N3, N4, N5, N6, N7, N8, N9, -1, AccumulatedType >::Type Type;
48  };
49 
50  template< class Seed >
51  class ElementTuple< -1, -1, -1, -1, -1, -1, -1, -1, -1, Seed >
52  {
53  public:
54  typedef Seed Type;
55  };
56 
57  // Selector
58  // --------
59 
64  template< class ElementTupleImp >
65  struct SelectorBase;
66 
67  template< class ElementTupleImp >
68  struct SelectorBase
69  {
71  typedef typename ElementTupleImp :: Type Type;
72 
73  // \brief number of elements in selector
74  static const int size = std::tuple_size< Type >::value;
75 
77  template< int N >
78  struct Contains
79  {
81  };
82 
83  private:
84  // Selector is a mere traits class, forbid construction
85  SelectorBase();
86  };
87 
92  template< int N1 = -1,
93  int N2 = -1,
94  int N3 = -1,
95  int N4 = -1,
96  int N5 = -1,
97  int N6 = -1,
98  int N7 = -1,
99  int N8 = -1,
100  int N9 = -1
101  >
102  struct Selector : public SelectorBase< Dune::Fem::ElementTuple< N1, N2, N3, N4, N5, N6, N7, N8, N9 > >
103  {
104  };
105 
106  } // namespace Fem
107 
108 } // namespace Dune
109 
110 #endif // #ifndef DUNE_FEM_PASS_COMMON_SELECTOR_HH
Definition: selector.hh:42
Definition: coordinate.hh:4
Definition: tupleutility.hh:168
ElementTupleImp::Type Type
tuple consisting of Dune::integral_constant< int, N_i >
Definition: selector.hh:71
A helper class that creates a selector tuple from given pass ids.
Definition: selector.hh:102
check, whether integer N is contained in selector
Definition: selector.hh:78
ElementTuple< N2, N3, N4, N5, N6, N7, N8, N9,-1, AccumulatedType >::Type Type
Definition: selector.hh:47
A helper class that creates a selector tuple from given pass ids.
Definition: selector.hh:65