Jpp  pmt_effective_area_update_2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JClass.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JCLASS__
2 #define __JLANG__JCLASS__
3 
4 
5 /**
6  * \author mdejong
7  */
8 
9 namespace JLANG {}
10 namespace JPP { using namespace JLANG; }
11 
12 namespace JLANG {
13 
14 
15  /**
16  * Data structure for primitive types.
17  */
18  template<class T>
19  struct JPrimitive {
20 
21  typedef const T argument_type;
22 
23  enum { is_primitive = true };
24  };
25 
26 
27  /**
28  * Data structure for method argument types.
29  */
30  template<class T>
31  struct JArgument {
32 
33  typedef const T& argument_type;
34 
35  enum { is_primitive = false };
36  };
37 
38 
39  /**
40  * Specialisations of JArgument for primitive types.
41  */
42  template<> struct JArgument<bool> : public JPrimitive<bool> {};
43  template<> struct JArgument<char> : public JPrimitive<char> {};
44  template<> struct JArgument<unsigned char> : public JPrimitive<unsigned char> {};
45  template<> struct JArgument<short> : public JPrimitive<short> {};
46  template<> struct JArgument<unsigned short> : public JPrimitive<unsigned short> {};
47  template<> struct JArgument<int> : public JPrimitive<int> {};
48  template<> struct JArgument<unsigned int> : public JPrimitive<unsigned int> {};
49  template<> struct JArgument<long int> : public JPrimitive<long int> {};
50  template<> struct JArgument<unsigned long int> : public JPrimitive<unsigned long int> {};
51  template<> struct JArgument<long long int> : public JPrimitive<long long int> {};
52  template<> struct JArgument<unsigned long long int> : public JPrimitive<unsigned long long int> {};
53  template<> struct JArgument<float> : public JPrimitive<float> {};
54  template<> struct JArgument<double> : public JPrimitive<double> {};
55  template<> struct JArgument<long double> : public JPrimitive<long double> {};
56 
57 
58  /**
59  * Data structure to check whether given data type is an iterator.
60  */
61  template<class T>
62  struct is_iterator {
63 
64  static T make();
65 
66  typedef void* buffer[2];
67 
68  static buffer& test(...); //!< any type
69  template<class R> static typename R::iterator_category* test(R); //!< iterator
70  template<class R> static void* test(R *); //!< pointer
71 
72  static const bool value = sizeof(test(make())) == sizeof(void *);
73  };
74 
75 
76  /**
77  * Template for generic class types.
78  */
79  template<class T>
80  struct JClass {
81 
83  typedef T value_type;
86 
88  enum { is_reference = false };
89  enum { is_pointer = false };
90  enum { is_constant = false };
91  };
92 
93 
94  /**
95  * Specialisation of JClass for const class types.
96  */
97  template<class T>
98  struct JClass<const T> {
99 
101  typedef T value_type;
102  typedef const value_type& reference_type;
103  typedef const value_type* pointer_type;
104 
106  enum { is_reference = false };
107  enum { is_pointer = false };
108  enum { is_constant = true };
109  };
110 
111 
112  /**
113  * Specialisation of JClass for reference class types.
114  */
115  template<class T>
116  struct JClass<T&> {
117 
118  typedef T& argument_type;
119  typedef T value_type;
120  typedef value_type& reference_type;
121  typedef value_type* pointer_type;
122 
123  enum { is_primitive = JArgument<T>::is_primitive };
124  enum { is_reference = true };
125  enum { is_pointer = false };
126  enum { is_constant = false };
127  };
128 
129 
130  /**
131  * Specialisation of JClass for const reference class types.
132  */
133  template<class T>
134  struct JClass<const T&> {
135 
136  typedef const T& argument_type;
137  typedef T value_type;
138  typedef const value_type& reference_type;
139  typedef const value_type* pointer_type;
140 
141  enum { is_primitive = JArgument<T>::is_primitive };
142  enum { is_reference = true };
143  enum { is_pointer = false };
144  enum { is_constant = true };
145  };
146 
147 
148  /**
149  * Specialisation of JClass for pointer class types.
150  */
151  template<class T>
152  struct JClass<T*> {
153 
154  typedef T* argument_type;
155  typedef T value_type;
156  typedef value_type*& reference_type;
157  typedef value_type* pointer_type;
158 
159  enum { is_primitive = JArgument<T>::is_primitive };
160  enum { is_reference = false };
161  enum { is_pointer = true };
162  enum { is_constant = false };
163  };
164 
165 
166  /**
167  * Specialisation of JClass for const pointer class types.
168  */
169  template<class T>
170  struct JClass<const T*> {
171 
172  typedef const T* argument_type;
173  typedef T value_type;
174  typedef const value_type*& reference_type;
175  typedef const value_type* pointer_type;
176 
177  enum { is_primitive = JArgument<T>::is_primitive };
178  enum { is_reference = false };
179  enum { is_pointer = true };
180  enum { is_constant = true };
181  };
182 
183 
184  /**
185  * Specialisation of JClass for pointer class types.
186  */
187  template<class T>
188  struct JClass<T*&> {
189 
190  typedef T*& argument_type;
191  typedef T value_type;
192  typedef value_type*& reference_type;
193  typedef value_type* pointer_type;
194 
195  enum { is_primitive = JArgument<T>::is_primitive };
196  enum { is_reference = true };
197  enum { is_pointer = true };
198  enum { is_constant = false };
199  };
200 
201 
202  /**
203  * Specialisation of JClass for const pointer class types.
204  */
205  template<class T>
206  struct JClass<const T*&> {
207 
208  typedef const T*& argument_type;
209  typedef T value_type;
210  typedef const value_type*& reference_type;
211  typedef const value_type* pointer_type;
212 
213  enum { is_primitive = JArgument<T>::is_primitive };
214  enum { is_reference = true };
215  enum { is_pointer = true };
216  enum { is_constant = true };
217  };
218 }
219 
220 #endif
const value_type * pointer_type
Definition: JClass.hh:175
const value_type & reference_type
Definition: JClass.hh:138
const value_type * pointer_type
Definition: JClass.hh:139
JArgument< T >::argument_type argument_type
Definition: JClass.hh:100
const T argument_type
Definition: JClass.hh:21
Data structure for primitive types.
Definition: JClass.hh:19
static const bool value
Definition: JClass.hh:72
value_type & reference_type
Definition: JClass.hh:84
const value_type *& reference_type
Definition: JClass.hh:174
JArgument< T >::argument_type argument_type
Definition: JClass.hh:82
const T & argument_type
Definition: JClass.hh:33
value_type *& reference_type
Definition: JClass.hh:192
Data structure to check whether given data type is an iterator.
Definition: JClass.hh:62
value_type * pointer_type
Definition: JClass.hh:157
do set_variable OUTPUT_DIRECTORY $WORKDIR T
value_type *& reference_type
Definition: JClass.hh:156
value_type * pointer_type
Definition: JClass.hh:121
value_type * pointer_type
Definition: JClass.hh:85
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
void * buffer[2]
Definition: JClass.hh:66
const value_type * pointer_type
Definition: JClass.hh:211
static buffer & test(...)
any type
const value_type * pointer_type
Definition: JClass.hh:103
Template for generic class types.
Definition: JClass.hh:80
const value_type *& reference_type
Definition: JClass.hh:210
value_type * pointer_type
Definition: JClass.hh:193
const value_type & reference_type
Definition: JClass.hh:102
value_type & reference_type
Definition: JClass.hh:120
Data structure for method argument types.
Definition: JClass.hh:31