All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ptypeList.h
Go to the documentation of this file.
1 #ifndef OSL_PTYPE_LIST_H
2 #define OSL_PTYPE_LIST_H
3 
4 #include "osl/ptype.h"
5 #include "osl/ptypeTraits.h"
6 #include <iosfwd>
7 #include <boost/static_assert.hpp>
8 namespace osl
9 {
11  namespace ptl{
12 
13  class NullPtype{
14  public:
15  static void show(std::ostream& os);
16  };
17 
18  template<Ptype T,class U>
19  struct PtypeList;
20 
21  template<class T>
22  struct IsPtypeList{
23  static const bool isPtypeList=false;
24  };
25 
26  template<>
28  static const bool isPtypeList=true;
29  };
30 
31  template<Ptype T,class U>
32  struct IsPtypeList<PtypeList<T,U> >{
33  static const bool isPtypeList=true;
34  };
35 
36 
37  template<Ptype T,class U>
38  // static assertでUが
39  struct PtypeList{
41  static const Ptype value=T;
42  typedef U Tail;
43  static void show(std::ostream& os);
44  };
45 
46 
47 #define PTYPELIST_1(T1) PtypeList<T1,NullPtype>
48 #define PTYPELIST_2(T1,T2) PtypeList<T1,PTYPELIST_1(T2) >
49 #define PTYPELIST_3(T1,T2,T3) PtypeList<T1,PTYPELIST_2(T2,T3) >
50 #define PTYPELIST_4(T1,T2,T3,T4) PtypeList<T1,PTYPELIST_3(T2,T3,T4) >
51 #define PTYPELIST_5(T1,T2,T3,T4,T5) PtypeList<T1,PTYPELIST_4(T2,T3,T4,T5) >
52 #define PTYPELIST_6(T1,T2,T3,T4,T5,T6)\
53  PtypeList<T1,PTYPELIST_5(T2,T3,T4,T5,T6) >
54 #define PTYPELIST_7(T1,T2,T3,T4,T5,T6,T7)\
55  PtypeList<T1,PTYPELIST_6(T2,T3,T4,T5,T6,T7) >
56 #define PTYPELIST_8(T1,T2,T3,T4,T5,T6,T7,T8)\
57  PtypeList<T1,PTYPELIST_7(T2,T3,T4,T5,T6,T7,T8) >
58 #define PTYPELIST_9(T1,T2,T3,T4,T5,T6,T7,T8,T9)\
59  PtypeList<T1,PTYPELIST_8(T2,T3,T4,T5,T6,T7,T8,T9) >
60 #define PTYPELIST_10(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10)\
61  PtypeList<T1,PTYPELIST_9(T2,T3,T4,T5,T6,T7,T8,T9,T10) >
62 #define PTYPELIST_11(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11)\
63  PtypeList<T1,PTYPELIST_10(T2,T3,T4,T5,T6,T7,T8,T9,T10,T11) >
64 #define PTYPELIST_12(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12)\
65  PtypeList<T1,PTYPELIST_11(T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12) >
66 #define PTYPELIST_13(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13)\
67  PtypeList<T1,PTYPELIST_12(T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13) >
68 #define PTYPELIST_14(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14)\
69  PtypeList<T1,PTYPELIST_13(T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14) >
70 #define PTYPELIST_15(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15)\
71  PtypeList<T1,PTYPELIST_14(T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15) >
72 #define PTYPELIST_16(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16)\
73  PtypeList<T1,PTYPELIST_15(T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16) >
74 
76 
77 
81  template<class PTList,Ptype T>
82  struct IsMember;
83 
84  template<Ptype T>
85  struct IsMember<NullPtype,T>{
86  static const bool value=false;
87  };
88  template<Ptype T>
90 
91  template<Ptype T1,Ptype T2,class U>
92  struct IsMember<PtypeList<T2,U>,T1 >{
93  static const bool value=IsMember<U,T1>::value;
94  };
95  template<Ptype T1,Ptype T2,class U>
96  const bool IsMember<PtypeList<T2,U>,T1 >::value;
97 
98  template<Ptype T,class U>
99  struct IsMember<PtypeList<T,U>,T >{
100  static const bool value=true;
101  };
102  template<Ptype T,class U>
103  const bool IsMember<PtypeList<T,U>,T >::value;
104 
108  template<class PTList,class CheckPtype> struct Filter;
109 
110  template<class CheckPtype>
111  struct Filter<NullPtype,CheckPtype>{
112  typedef NullPtype Result;
113  };
114 
115  template<Ptype T,class U,bool condition,class CheckPtype> struct FilterDispatch;
116 
117  template<Ptype T,class U,class CheckPtype>
118  struct FilterDispatch<T,U,true,CheckPtype>{
120  };
121 
122  template<Ptype T,class U,class CheckPtype>
123  struct FilterDispatch<T,U,false,CheckPtype>{
125  };
126 
127  template<Ptype T,class U,class CheckPtype >
128  struct Filter< PtypeList<T,U>,CheckPtype>{
130  };
131 
135  struct CheckIsBasic{
136  template<Ptype T>
137  struct PtypeToBool{
138  static const bool value=PtypeTraits<T>::isBasic;
139  };
140  };
141 
146  template<unsigned int moveMask>
148  template<Ptype T>
149  struct PtypeToBool{
150  static const bool value=(PtypeTraits<T>::moveMask & moveMask)!=0;
151  };
152  };
153  }
154 
155 };
156 
157 #endif /* OSL_PTYPE_LIST_H */
158 // ;;; Local Variables:
159 // ;;; mode:c++
160 // ;;; c-basic-offset:2
161 // ;;; End:
162