OpenSDN source code
factory_macros.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 //
7 // Generated by base/factory_macros.py
8 //
9 
10 #define FACTORY_TYPE_N0(_Module, _T)\
11  public:\
12  template <class U>\
13  static typename boost::enable_if<boost::is_same<U, _T>, void>::type\
14  Register(boost::function<_T *()> function) {\
15  _Module *obj = GetInstance();\
16  obj->make_ ## _T ## _ = function;\
17  }\
18  template <class U>\
19  static typename boost::enable_if<boost::is_same<U, _T>, _T *>::type\
20  Create() {\
21  _Module *obj = GetInstance();\
22  return obj->make_ ## _T ## _();\
23  }\
24  private:\
25  boost::function<_T *()> make_ ## _T ##_\
26 
27 #define FACTORY_PARAM_TYPE_N0(_Module, _T, _P)\
28  public:\
29  template <class U, int UP>\
30  static typename boost::enable_if_c<\
31  boost::is_same<U, _T>::value && (UP == (_P)), void>::type\
32  Register(boost::function<_T *()> function) {\
33  _Module *obj = GetInstance();\
34  obj->make_ ## _T ## _ ## _P ## _ = function;\
35  }\
36  template <class U, int UP>\
37  static typename boost::enable_if_c<\
38  boost::is_same<U, _T>::value && (UP == (_P)), _T *>::type\
39  Create() {\
40  _Module *obj = GetInstance();\
41  return obj->make_ ## _T ## _ ## _P ##_();\
42  }\
43  private:\
44  boost::function<_T *()> make_ ## _T ## _ ## _P ## _\
45 
46 #define FACTORY_TYPE_N1(_Module, _T, A0)\
47  public:\
48  template <class U>\
49  static typename boost::enable_if<boost::is_same<U, _T>, void>::type\
50  Register(boost::function<_T *(A0)> function) {\
51  _Module *obj = GetInstance();\
52  obj->make_ ## _T ## _ = function;\
53  }\
54  template <class U>\
55  static typename boost::enable_if<boost::is_same<U, _T>, _T *>::type\
56  Create(A0 a0) {\
57  _Module *obj = GetInstance();\
58  return obj->make_ ## _T ## _(a0);\
59  }\
60  private:\
61  boost::function<_T *(A0)> make_ ## _T ##_\
62 
63 #define FACTORY_PARAM_TYPE_N1(_Module, _T, _P, A0)\
64  public:\
65  template <class U, int UP>\
66  static typename boost::enable_if_c<\
67  boost::is_same<U, _T>::value && (UP == (_P)), void>::type\
68  Register(boost::function<_T *(A0)> function) {\
69  _Module *obj = GetInstance();\
70  obj->make_ ## _T ## _ ## _P ## _ = function;\
71  }\
72  template <class U, int UP>\
73  static typename boost::enable_if_c<\
74  boost::is_same<U, _T>::value && (UP == (_P)), _T *>::type\
75  Create(A0 a0) {\
76  _Module *obj = GetInstance();\
77  return obj->make_ ## _T ## _ ## _P ##_(a0);\
78  }\
79  private:\
80  boost::function<_T *(A0)> make_ ## _T ## _ ## _P ## _\
81 
82 #define FACTORY_TYPE_N2(_Module, _T, A0, A1)\
83  public:\
84  template <class U>\
85  static typename boost::enable_if<boost::is_same<U, _T>, void>::type\
86  Register(boost::function<_T *(A0, A1)> function) {\
87  _Module *obj = GetInstance();\
88  obj->make_ ## _T ## _ = function;\
89  }\
90  template <class U>\
91  static typename boost::enable_if<boost::is_same<U, _T>, _T *>::type\
92  Create(A0 a0, A1 a1) {\
93  _Module *obj = GetInstance();\
94  return obj->make_ ## _T ## _(a0, a1);\
95  }\
96  private:\
97  boost::function<_T *(A0, A1)> make_ ## _T ##_\
98 
99 #define FACTORY_PARAM_TYPE_N2(_Module, _T, _P, A0, A1)\
100  public:\
101  template <class U, int UP>\
102  static typename boost::enable_if_c<\
103  boost::is_same<U, _T>::value && (UP == (_P)), void>::type\
104  Register(boost::function<_T *(A0, A1)> function) {\
105  _Module *obj = GetInstance();\
106  obj->make_ ## _T ## _ ## _P ## _ = function;\
107  }\
108  template <class U, int UP>\
109  static typename boost::enable_if_c<\
110  boost::is_same<U, _T>::value && (UP == (_P)), _T *>::type\
111  Create(A0 a0, A1 a1) {\
112  _Module *obj = GetInstance();\
113  return obj->make_ ## _T ## _ ## _P ##_(a0, a1);\
114  }\
115  private:\
116  boost::function<_T *(A0, A1)> make_ ## _T ## _ ## _P ## _\
117 
118 #define FACTORY_TYPE_N3(_Module, _T, A0, A1, A2)\
119  public:\
120  template <class U>\
121  static typename boost::enable_if<boost::is_same<U, _T>, void>::type\
122  Register(boost::function<_T *(A0, A1, A2)> function) {\
123  _Module *obj = GetInstance();\
124  obj->make_ ## _T ## _ = function;\
125  }\
126  template <class U>\
127  static typename boost::enable_if<boost::is_same<U, _T>, _T *>::type\
128  Create(A0 a0, A1 a1, A2 a2) {\
129  _Module *obj = GetInstance();\
130  return obj->make_ ## _T ## _(a0, a1, a2);\
131  }\
132  private:\
133  boost::function<_T *(A0, A1, A2)> make_ ## _T ##_\
134 
135 #define FACTORY_PARAM_TYPE_N3(_Module, _T, _P, A0, A1, A2)\
136  public:\
137  template <class U, int UP>\
138  static typename boost::enable_if_c<\
139  boost::is_same<U, _T>::value && (UP == (_P)), void>::type\
140  Register(boost::function<_T *(A0, A1, A2)> function) {\
141  _Module *obj = GetInstance();\
142  obj->make_ ## _T ## _ ## _P ## _ = function;\
143  }\
144  template <class U, int UP>\
145  static typename boost::enable_if_c<\
146  boost::is_same<U, _T>::value && (UP == (_P)), _T *>::type\
147  Create(A0 a0, A1 a1, A2 a2) {\
148  _Module *obj = GetInstance();\
149  return obj->make_ ## _T ## _ ## _P ##_(a0, a1, a2);\
150  }\
151  private:\
152  boost::function<_T *(A0, A1, A2)> make_ ## _T ## _ ## _P ## _\
153 
154 #define FACTORY_TYPE_N4(_Module, _T, A0, A1, A2, A3)\
155  public:\
156  template <class U>\
157  static typename boost::enable_if<boost::is_same<U, _T>, void>::type\
158  Register(boost::function<_T *(A0, A1, A2, A3)> function) {\
159  _Module *obj = GetInstance();\
160  obj->make_ ## _T ## _ = function;\
161  }\
162  template <class U>\
163  static typename boost::enable_if<boost::is_same<U, _T>, _T *>::type\
164  Create(A0 a0, A1 a1, A2 a2, A3 a3) {\
165  _Module *obj = GetInstance();\
166  return obj->make_ ## _T ## _(a0, a1, a2, a3);\
167  }\
168  private:\
169  boost::function<_T *(A0, A1, A2, A3)> make_ ## _T ##_\
170 
171 #define FACTORY_PARAM_TYPE_N4(_Module, _T, _P, A0, A1, A2, A3)\
172  public:\
173  template <class U, int UP>\
174  static typename boost::enable_if_c<\
175  boost::is_same<U, _T>::value && (UP == (_P)), void>::type\
176  Register(boost::function<_T *(A0, A1, A2, A3)> function) {\
177  _Module *obj = GetInstance();\
178  obj->make_ ## _T ## _ ## _P ## _ = function;\
179  }\
180  template <class U, int UP>\
181  static typename boost::enable_if_c<\
182  boost::is_same<U, _T>::value && (UP == (_P)), _T *>::type\
183  Create(A0 a0, A1 a1, A2 a2, A3 a3) {\
184  _Module *obj = GetInstance();\
185  return obj->make_ ## _T ## _ ## _P ##_(a0, a1, a2, a3);\
186  }\
187  private:\
188  boost::function<_T *(A0, A1, A2, A3)> make_ ## _T ## _ ## _P ## _\
189 
190 #define FACTORY_TYPE_N5(_Module, _T, A0, A1, A2, A3, A4)\
191  public:\
192  template <class U>\
193  static typename boost::enable_if<boost::is_same<U, _T>, void>::type\
194  Register(boost::function<_T *(A0, A1, A2, A3, A4)> function) {\
195  _Module *obj = GetInstance();\
196  obj->make_ ## _T ## _ = function;\
197  }\
198  template <class U>\
199  static typename boost::enable_if<boost::is_same<U, _T>, _T *>::type\
200  Create(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {\
201  _Module *obj = GetInstance();\
202  return obj->make_ ## _T ## _(a0, a1, a2, a3, a4);\
203  }\
204  private:\
205  boost::function<_T *(A0, A1, A2, A3, A4)> make_ ## _T ##_\
206 
207 #define FACTORY_PARAM_TYPE_N5(_Module, _T, _P, A0, A1, A2, A3, A4)\
208  public:\
209  template <class U, int UP>\
210  static typename boost::enable_if_c<\
211  boost::is_same<U, _T>::value && (UP == (_P)), void>::type\
212  Register(boost::function<_T *(A0, A1, A2, A3, A4)> function) {\
213  _Module *obj = GetInstance();\
214  obj->make_ ## _T ## _ ## _P ## _ = function;\
215  }\
216  template <class U, int UP>\
217  static typename boost::enable_if_c<\
218  boost::is_same<U, _T>::value && (UP == (_P)), _T *>::type\
219  Create(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {\
220  _Module *obj = GetInstance();\
221  return obj->make_ ## _T ## _ ## _P ##_(a0, a1, a2, a3, a4);\
222  }\
223  private:\
224  boost::function<_T *(A0, A1, A2, A3, A4)> make_ ## _T ## _ ## _P ## _\
225 
226 #define FACTORY_TYPE_N6(_Module, _T, A0, A1, A2, A3, A4, A5)\
227  public:\
228  template <class U>\
229  static typename boost::enable_if<boost::is_same<U, _T>, void>::type\
230  Register(boost::function<_T *(A0, A1, A2, A3, A4, A5)> function) {\
231  _Module *obj = GetInstance();\
232  obj->make_ ## _T ## _ = function;\
233  }\
234  template <class U>\
235  static typename boost::enable_if<boost::is_same<U, _T>, _T *>::type\
236  Create(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {\
237  _Module *obj = GetInstance();\
238  return obj->make_ ## _T ## _(a0, a1, a2, a3, a4, a5);\
239  }\
240  private:\
241  boost::function<_T *(A0, A1, A2, A3, A4, A5)> make_ ## _T ##_\
242 
243 #define FACTORY_PARAM_TYPE_N6(_Module, _T, _P, A0, A1, A2, A3, A4, A5)\
244  public:\
245  template <class U, int UP>\
246  static typename boost::enable_if_c<\
247  boost::is_same<U, _T>::value && (UP == (_P)), void>::type\
248  Register(boost::function<_T *(A0, A1, A2, A3, A4, A5)> function) {\
249  _Module *obj = GetInstance();\
250  obj->make_ ## _T ## _ ## _P ## _ = function;\
251  }\
252  template <class U, int UP>\
253  static typename boost::enable_if_c<\
254  boost::is_same<U, _T>::value && (UP == (_P)), _T *>::type\
255  Create(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {\
256  _Module *obj = GetInstance();\
257  return obj->make_ ## _T ## _ ## _P ##_(a0, a1, a2, a3, a4, a5);\
258  }\
259  private:\
260  boost::function<_T *(A0, A1, A2, A3, A4, A5)> make_ ## _T ## _ ## _P ## _\
261 
262 #define FACTORY_TYPE_N7(_Module, _T, A0, A1, A2, A3, A4, A5, A6)\
263  public:\
264  template <class U>\
265  static typename boost::enable_if<boost::is_same<U, _T>, void>::type\
266  Register(boost::function<_T *(A0, A1, A2, A3, A4, A5, A6)> function) {\
267  _Module *obj = GetInstance();\
268  obj->make_ ## _T ## _ = function;\
269  }\
270  template <class U>\
271  static typename boost::enable_if<boost::is_same<U, _T>, _T *>::type\
272  Create(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {\
273  _Module *obj = GetInstance();\
274  return obj->make_ ## _T ## _(a0, a1, a2, a3, a4, a5, a6);\
275  }\
276  private:\
277  boost::function<_T *(A0, A1, A2, A3, A4, A5, A6)> make_ ## _T ##_\
278 
279 #define FACTORY_PARAM_TYPE_N7(_Module, _T, _P, A0, A1, A2, A3, A4, A5, A6)\
280  public:\
281  template <class U, int UP>\
282  static typename boost::enable_if_c<\
283  boost::is_same<U, _T>::value && (UP == (_P)), void>::type\
284  Register(boost::function<_T *(A0, A1, A2, A3, A4, A5, A6)> function) {\
285  _Module *obj = GetInstance();\
286  obj->make_ ## _T ## _ ## _P ## _ = function;\
287  }\
288  template <class U, int UP>\
289  static typename boost::enable_if_c<\
290  boost::is_same<U, _T>::value && (UP == (_P)), _T *>::type\
291  Create(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {\
292  _Module *obj = GetInstance();\
293  return obj->make_ ## _T ## _ ## _P ##_(a0, a1, a2, a3, a4, a5, a6);\
294  }\
295  private:\
296  boost::function<_T *(A0, A1, A2, A3, A4, A5, A6)> make_ ## _T ## _ ## _P ## _\
297 
298 #define FACTORY_TYPE_N8(_Module, _T, A0, A1, A2, A3, A4, A5, A6, A7)\
299  public:\
300  template <class U>\
301  static typename boost::enable_if<boost::is_same<U, _T>, void>::type\
302  Register(boost::function<_T *(A0, A1, A2, A3, A4, A5, A6, A7)> function) {\
303  _Module *obj = GetInstance();\
304  obj->make_ ## _T ## _ = function;\
305  }\
306  template <class U>\
307  static typename boost::enable_if<boost::is_same<U, _T>, _T *>::type\
308  Create(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {\
309  _Module *obj = GetInstance();\
310  return obj->make_ ## _T ## _(a0, a1, a2, a3, a4, a5, a6, a7);\
311  }\
312  private:\
313  boost::function<_T *(A0, A1, A2, A3, A4, A5, A6, A7)> make_ ## _T ##_\
314 
315 #define FACTORY_PARAM_TYPE_N8(_Module, _T, _P, A0, A1, A2, A3, A4, A5, A6, A7)\
316  public:\
317  template <class U, int UP>\
318  static typename boost::enable_if_c<\
319  boost::is_same<U, _T>::value && (UP == (_P)), void>::type\
320  Register(boost::function<_T *(A0, A1, A2, A3, A4, A5, A6, A7)> function) {\
321  _Module *obj = GetInstance();\
322  obj->make_ ## _T ## _ ## _P ## _ = function;\
323  }\
324  template <class U, int UP>\
325  static typename boost::enable_if_c<\
326  boost::is_same<U, _T>::value && (UP == (_P)), _T *>::type\
327  Create(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {\
328  _Module *obj = GetInstance();\
329  return obj->make_ ## _T ## _ ## _P ##_(a0, a1, a2, a3, a4, a5, a6, a7);\
330  }\
331  private:\
332  boost::function<_T *(A0, A1, A2, A3, A4, A5, A6, A7)> make_ ## _T ## _ ## _P ## _\
333