Macros.h
Go to the documentation of this file.
1 /*
2  * File: Macros.h
3  * Author: denis
4  *
5  * This file contains macros that are useful for DAQDataFormats initializations and such
6  * Most of these macros should be used in the Header files only
7  *
8  * Created on February 19, 2012, 10:38 AM
9  */
10 
11 #ifndef MACROS_H
12 #define MACROS_H
13 
14 #include "DAQDataFormats/FunctionBind.h"
15 
16 //---------------------------------------------------------------------------------
17 /// These macros are used to put definitions of function pointers in the Header of the first version of the class
18 /// Put them in the Header!!!!!!!!!!!!!!!!!!!
19 //---------------------------------------------------------------------------------
20 
21 /// Define Get function pointer. Put it in the header of the first class. Custom output units
22 #define INIT_CUSTOM_DELEGATE(FULLFUNCTIONNAME, OUTPUT, ...) protected: DELEGATE(CURRENT_CLASS, _function_##FULLFUNCTIONNAME, OUTPUT,__VA_ARGS__ )
23 
24 /// Define Get function pointer. Put it in the header of the first class. Custom output units
25 #define INIT_CUSTOM_GET_FUNCTION(FULLFUNCTIONNAME, OUTPUT_UNITS) INIT_CUSTOM_DELEGATE(FULLFUNCTIONNAME, OUTPUT_UNITS) const;
26 
27 /// Define Set function pointer. Put it in the header of the first class. Custom input units
28 #define INIT_CUSTOM_SET_FUNCTION(FULLFUNCTIONNAME, INPUT_UNITS) INIT_CUSTOM_DELEGATE(FULLFUNCTIONNAME, bool, INPUT_UNITS);
29 
30 /// Define both Get and Set function pointers. Put it in the header of the first class. Custom units
31 #define INIT_GET_AND_SET_FUNCTION(FUNCT, UNITS) \
32  INIT_CUSTOM_GET_FUNCTION(get##FUNCT, UNITS) \
33  INIT_CUSTOM_SET_FUNCTION(set##FUNCT, UNITS)
34 
35 /// Define both Is and Set function pointers. Put it in the header of the first class
36 #define INIT_IS_AND_SET_FUNCTION(FUNCT) \
37  INIT_CUSTOM_GET_FUNCTION(is##FUNCT , bool) \
38  INIT_CUSTOM_SET_FUNCTION(set##FUNCT, bool)
39 
40 //---------------------------------------------------------------------------------
41 /// These macros are used to define and implement get and set methods in Main Class
42 /// Put them in the Header!!!!!!!!!!!!!!!!!!!
43 //---------------------------------------------------------------------------------
44 
45 /// Checking of the binding function if it's defined
46 #define CHECK_BINDING_FUNCTION(function) if (! function){ \
47  std::cout<<"Error!!! Function "<<__PRETTY_FUNCTION__<<" " \
48  <<"is not binded. For version "<<_version<<". " \
49  <<"Check the appropriate setFunctionPointers method." \
50  <<std::endl; \
51  exit(1); \
52  }
53 /// Execute and return the delegate
54 #define EXECUTE_FUNCTION(FULLFUNCTIONNAME) \
55  EXECUTE_GENERAL_FUNCTION(_function_##FULLFUNCTIONNAME)
56 
57 #define RETURN_FUNCTION(FULLFUNCTIONNAME) \
58  EXECUTE_ON_DEBUG(CHECK_BINDING_FUNCTION(_function_##FULLFUNCTIONNAME)); \
59  return EXECUTE_GENERAL_FUNCTION(_function_##FULLFUNCTIONNAME)
60 
61 //------------------------------------------------------------------------------
62 /// These macros are used to implement gets and sets of the fields
63 //------------------------------------------------------------------------------
64 #define IMPLEMENT_GENERAL_GET_IN_FIRST_VERSION_CLASS(PROTECTIVENESS, NAMESPACE, FUNC, UNITS) \
65 PROTECTIVENESS: UNITS get##FUNC() const { \
66  const uint32_t* pointer = &(RAWBUFF32[NAMESPACE::WORD_##FUNC]); \
67  return (UNITS) (BITFIELDGET(*pointer, NAMESPACE::MASK_##FUNC, NAMESPACE::SHIFT_##FUNC)); \
68 }
69 #define IMPLEMENT_GENERAL_GET_OR_IS_IN_FIRST_VERSION_CLASS_BOOL(PROTECTIVENESS, PREFUNCT, NAMESPACE, FUNC) \
70 PROTECTIVENESS: bool PREFUNCT##FUNC() const { \
71  const uint32_t* pointer = &(RAWBUFF32[NAMESPACE::WORD_##FUNC]); \
72  return uint32_tToBool(BITFIELDGET(*pointer, NAMESPACE::MASK_##FUNC, NAMESPACE::SHIFT_##FUNC)); \
73 }
74 #define IMPLEMENT_GENERAL_SET_IN_FIRST_VERSION_CLASS(PROTECTIVENESS, NAMESPACE, FUNC, UNITS) \
75 PROTECTIVENESS: bool set##FUNC(const UNITS value) { \
76  uint32_t* pointer = &(RAWBUFF32[NAMESPACE::WORD_##FUNC]); \
77  BITFIELDSET(*pointer, value, NAMESPACE::MASK_##FUNC, NAMESPACE::SHIFT_##FUNC); \
78  return true; \
79 }
80 #define IMPLEMENT_GENERAL_SET_IN_FIRST_VERSION_CLASS_BOOL(PROTECTIVENESS, NAMESPACE, FUNC) \
81 PROTECTIVENESS: bool set##FUNC(const bool value) { \
82  uint32_t* pointer = &(RAWBUFF32[NAMESPACE::WORD_##FUNC]); \
83  const uint32_t val = boolToUint32_t(value); \
84  BITFIELDSET(*pointer, val, NAMESPACE::MASK_##FUNC, NAMESPACE::SHIFT_##FUNC); \
85  return true; \
86 }
87 
88 /// Implement Get, Set method with namespace and units. And then with units=bool
89 #define IMPLEMENT_GET_IN_FIRST_VERSION_CLASS(NAMESPACE, FUNC, UNITS) IMPLEMENT_GENERAL_GET_IN_FIRST_VERSION_CLASS(public, NAMESPACE, FUNC, UNITS)
90 #define IMPLEMENT_SET_IN_FIRST_VERSION_CLASS(NAMESPACE, FUNC, UNITS) IMPLEMENT_GENERAL_SET_IN_FIRST_VERSION_CLASS(public, NAMESPACE, FUNC, UNITS)
91 #define IMPLEMENT_GET_IN_FIRST_VERSION_CLASS_BOOL(NAMESPACE, FUNC) IMPLEMENT_GENERAL_GET_OR_IS_IN_FIRST_VERSION_CLASS_BOOL(public, get, NAMESPACE, FUNC)
92 #define IMPLEMENT_SET_IN_FIRST_VERSION_CLASS_BOOL(NAMESPACE, FUNC) IMPLEMENT_GENERAL_SET_IN_FIRST_VERSION_CLASS_BOOL(public, NAMESPACE, FUNC)
93 #define IMPLEMENT_IS_IN_FIRST_VERSION_CLASS(NAMESPACE, FUNC) IMPLEMENT_GENERAL_GET_OR_IS_IN_FIRST_VERSION_CLASS_BOOL(public, is, NAMESPACE, FUNC)
94 
95 #define IMPLEMENT_GET_IN_FIRST_VERSION_CLASS_PROTECTED(NAMESPACE, FUNC, UNITS) IMPLEMENT_GENERAL_GET_IN_FIRST_VERSION_CLASS(protected, NAMESPACE, FUNC, UNITS)
96 #define IMPLEMENT_SET_IN_FIRST_VERSION_CLASS_PROTECTED(NAMESPACE, FUNC, UNITS) IMPLEMENT_GENERAL_SET_IN_FIRST_VERSION_CLASS(protected, NAMESPACE, FUNC, UNITS)
97 #define IMPLEMENT_GET_IN_FIRST_VERSION_CLASS_BOOL_PROTECTED(NAMESPACE, FUNC) IMPLEMENT_GENERAL_GET_OR_IS_IN_FIRST_VERSION_CLASS_BOOL(protected, get, NAMESPACE, FUNC)
98 #define IMPLEMENT_SET_IN_FIRST_VERSION_CLASS_BOOL_PROTECTED(NAMESPACE, FUNC) IMPLEMENT_GENERAL_SET_IN_FIRST_VERSION_CLASS(protected, NAMESPACE, FUNC)
99 #define IMPLEMENT_IS_IN_FIRST_VERSION_CLASS_PROTECTED(NAMESPACE, FUNC) IMPLEMENT_GENERAL_GET_OR_IS_IN_FIRST_VERSION_CLASS_BOOL(protected, is, NAMESPACE, FUNC)
100 
101 #define IMPLEMENT_GET(FUNC, UNITS) IMPLEMENT_GET_IN_FIRST_VERSION_CLASS(VERSION_NAMESPACE::CURRENT_FIELDS_SUB_NAMESPACE, FUNC, UNITS)
102 #define IMPLEMENT_SET(FUNC, UNITS) IMPLEMENT_SET_IN_FIRST_VERSION_CLASS(VERSION_NAMESPACE::CURRENT_FIELDS_SUB_NAMESPACE, FUNC, UNITS)
103 #define IMPLEMENT_GET_BOOL(FUNC) IMPLEMENT_GET_IN_FIRST_VERSION_CLASS_BOOL(VERSION_NAMESPACE::CURRENT_FIELDS_SUB_NAMESPACE, FUNC)
104 #define IMPLEMENT_SET_BOOL(FUNC) IMPLEMENT_SET_IN_FIRST_VERSION_CLASS_BOOL(VERSION_NAMESPACE::CURRENT_FIELDS_SUB_NAMESPACE, FUNC)
105 #define IMPLEMENT_IS(FUNC) IMPLEMENT_IS_IN_FIRST_VERSION_CLASS(VERSION_NAMESPACE::CURRENT_FIELDS_SUB_NAMESPACE, FUNC)
106 
107 #define IMPLEMENT_GET_NOVERSION(FUNC, UNITS) IMPLEMENT_GET_IN_FIRST_VERSION_CLASS(CURRENT_FIELDS_SUB_NAMESPACE, FUNC, UNITS)
108 #define IMPLEMENT_SET_NOVERSION(FUNC, UNITS) IMPLEMENT_SET_IN_FIRST_VERSION_CLASS(CURRENT_FIELDS_SUB_NAMESPACE, FUNC, UNITS)
109 #define IMPLEMENT_GET_NOVERSION_BOOL(FUNC) IMPLEMENT_GET_IN_FIRST_VERSION_CLASS_BOOL(CURRENT_FIELDS_SUB_NAMESPACE, FUNC)
110 #define IMPLEMENT_SET_NOVERSION_BOOL(FUNC) IMPLEMENT_SET_IN_FIRST_VERSION_CLASS_BOOL(CURRENT_FIELDS_SUB_NAMESPACE, FUNC)
111 #define IMPLEMENT_IS_NOVERSION(FUNC) IMPLEMENT_IS_IN_FIRST_VERSION_CLASS(CURRENT_FIELDS_SUB_NAMESPACE, FUNC)
112 
113 #define IMPLEMENT_GET_NOVERSION_PROTECTED(FUNC, UNITS) IMPLEMENT_GET_IN_FIRST_VERSION_CLASS_PROTECTED(CURRENT_FIELDS_SUB_NAMESPACE, FUNC, UNITS)
114 #define IMPLEMENT_SET_NOVERSION_PROTECTED(FUNC, UNITS) IMPLEMENT_SET_IN_FIRST_VERSION_CLASS_PROTECTED(CURRENT_FIELDS_SUB_NAMESPACE, FUNC, UNITS)
115 #define IMPLEMENT_GET_NOVERSION_BOOL_PROTECTED(FUNC) IMPLEMENT_GET_IN_FIRST_VERSION_CLASS_BOOL_PROTECTED(CURRENT_FIELDS_SUB_NAMESPACE, FUNC)
116 #define IMPLEMENT_SET_NOVERSION_BOOL_PROTECTED(FUNC) IMPLEMENT_SET_IN_FIRST_VERSION_CLASS_BOOL_PROTECTED(CURRENT_FIELDS_SUB_NAMESPACE, FUNC, UNITS)
117 #define IMPLEMENT_IS_NOVERSION_PROTECTED(FUNC) IMPLEMENT_IS_IN_FIRST_VERSION_CLASS_PROTECTED(CURRENT_FIELDS_SUB_NAMESPACE, FUNC)
118 
119 
120 #define IMPLEMENT_GET_AND_SET(FUNC, UNITS) \
121  IMPLEMENT_GET(FUNC, UNITS) \
122  IMPLEMENT_SET(FUNC, UNITS)
123 #define IMPLEMENT_GET_AND_SET_BOOL(FUNC) \
124  IMPLEMENT_GET_BOOL(FUNC) \
125  IMPLEMENT_SET_BOOL(FUNC)
126 #define IMPLEMENT_IS_AND_SET(FUNC) \
127  IMPLEMENT_IS(FUNC) \
128  IMPLEMENT_SET_BOOL(FUNC)
129 
130 #define IMPLEMENT_GET_AND_SET_NOVERSION(FUNC, UNITS) \
131  IMPLEMENT_GET_NOVERSION(FUNC, UNITS) \
132  IMPLEMENT_SET_NOVERSION(FUNC, UNITS)
133 #define IMPLEMENT_GET_AND_SET_NOVERSION_BOOL(FUNC) \
134  IMPLEMENT_GET_NOVERSION_BOOL(FUNC) \
135  IMPLEMENT_SET_NOVERSION_BOOL(FUNC)
136 #define IMPLEMENT_IS_AND_SET_NOVERSION(FUNC) \
137  IMPLEMENT_IS_NOVERSION(FUNC) \
138  IMPLEMENT_SET_NOVERSION_BOOL(FUNC)
139 
140 #define IMPLEMENT_GET_AND_SET_NOVERSION_PROTECTED(FUNC, UNITS) \
141  IMPLEMENT_GET_NOVERSION_PROTECTED(FUNC, UNITS) \
142  IMPLEMENT_SET_NOVERSION_PROTECTED(FUNC, UNITS)
143 #define IMPLEMENT_GET_AND_SET_NOVERSION_BOOL_PROTECTED(FUNC) \
144  IMPLEMENT_GET_NOVERSION_BOOL_PROTECTED(FUNC) \
145  IMPLEMENT_SET_NOVERSION_BOOL_PROTECTED(FUNC)
146 #define IMPLEMENT_IS_AND_SET_NOVERSION_PROTECTED(FUNC) \
147  IMPLEMENT_IS_NOVERSION_PROTECTED(FUNC) \
148  IMPLEMENT_SET_NOVERSION_BOOL_PROTECTED(FUNC)
149 
150 //------------------------------------------------------------------------------
151 #define DEFINE_SHIFT_FROM_MASK(FUNC) static const uint32_t SHIFT_##FUNC = daqdataformats::calculateShiftFromAGivenMask(MASK_##FUNC)
152 
153 //------------------------------------------------------------------------------
154 #define IMPLEMENT_FIRST_GET(FUNC, UNITS) \
155  IMPLEMENT_GET(FUNC, UNITS); \
156  INIT_CUSTOM_DELEGATE(get##FUNC, UNITS, ) const
157 #define IMPLEMENT_FIRST_SET(FUNC, UNITS) \
158  IMPLEMENT_SET(FUNC, UNITS); \
159  INIT_CUSTOM_DELEGATE(set##FUNC, bool , const UNITS)
160 #define IMPLEMENT_FIRST_GET_BOOL(FUNC) \
161  IMPLEMENT_GET_BOOL(FUNC); \
162  INIT_CUSTOM_DELEGATE(get##FUNC, bool, ) const
163 #define IMPLEMENT_FIRST_SET_BOOL(FUNC) \
164  IMPLEMENT_SET_BOOL(FUNC); \
165  INIT_CUSTOM_DELEGATE(set##FUNC, bool , const bool)
166 #define IMPLEMENT_FIRST_IS(FUNC) \
167  IMPLEMENT_IS(FUNC); \
168  INIT_CUSTOM_DELEGATE(is##FUNC, bool, ) const
169 
170 
171 #define IMPLEMENT_FIRST_GET_AND_SET(FUNC, UNITS)\
172  IMPLEMENT_FIRST_GET(FUNC, UNITS); \
173  IMPLEMENT_FIRST_SET(FUNC, UNITS)
174 #define IMPLEMENT_FIRST_GET_AND_SET_BOOL(FUNC) \
175  IMPLEMENT_FIRST_GET_BOOL(FUNC); \
176  IMPLEMENT_FIRST_SET_BOOL(FUNC)
177 #define IMPLEMENT_FIRST_IS_AND_SET(FUNC) \
178  IMPLEMENT_FIRST_IS(FUNC); \
179  IMPLEMENT_FIRST_SET_BOOL(FUNC)
180 
181 #define IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_0PAR(FUNC, CONSTNESS, OUTPUT) \
182  OUTPUT FUNC() CONSTNESS {RETURN_FUNCTION(FUNC)();}
183 #define IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_1PAR(FUNC, CONSTNESS, OUTPUT, INP1) \
184  OUTPUT FUNC(INP1 a) CONSTNESS {RETURN_FUNCTION(FUNC)(a);}
185 #define IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_2PAR(FUNC, CONSTNESS, OUTPUT, INP1,INP2) \
186  OUTPUT FUNC(INP1 a,INP2 b) CONSTNESS {RETURN_FUNCTION(FUNC)(a,b);}
187 #define IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_3PAR(FUNC, CONSTNESS, OUTPUT, INP1,INP2,INP3) \
188  OUTPUT FUNC(INP1 a,INP2 b,INP3 c) CONSTNESS {RETURN_FUNCTION(FUNC)(a, b, c);}
189 #define IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_4PAR(FUNC, CONSTNESS, OUTPUT, INP1,INP2,INP3,INP4) \
190  OUTPUT FUNC(INP1 a,INP2 b,INP3 c,INP4 d) CONSTNESS {RETURN_FUNCTION(FUNC)(a,b,c,d);}
191 #define IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_5PAR(FUNC, CONSTNESS, OUTPUT, INP1,INP2,INP3,INP4,INP5) \
192  OUTPUT FUNC(INP1 a,INP2 b,INP3 c,INP4 d,INP5 e) CONSTNESS {RETURN_FUNCTION(FUNC)(a,b,c,d,e);}
193 
194 #define IMPLEMENT_VOID_RETURNING_FUNCTION_POINTER_0PAR(FUNC, CONSTNESS) \
195  void FUNC() CONSTNESS {EXECUTE_FUNCTION(FUNC)();}
196 #define IMPLEMENT_VOID_RETURNING_FUNCTION_POINTER_1PAR(FUNC, CONSTNESS, INP1) \
197  void FUNC(INP1 a) CONSTNESS {EXECUTE_FUNCTION(FUNC)(a);}
198 #define IMPLEMENT_VOID_RETURNING_FUNCTION_POINTER_2PAR(FUNC, CONSTNESS, INP1,INP2) \
199  void FUNC(INP1 a,INP2 b) CONSTNESS {EXECUTE_FUNCTION(FUNC)(a,b);}
200 #define IMPLEMENT_VOID_RETURNING_FUNCTION_POINTER_3PAR(FUNC, CONSTNESS, INP1,INP2,INP3) \
201  void FUNC(INP1 a,INP2 b,INP3 c) CONSTNESS {EXECUTE_FUNCTION(FUNC)(a, b, c);}
202 #define IMPLEMENT_VOID_RETURNING_FUNCTION_POINTER_4PAR(FUNC, CONSTNESS, INP1,INP2,INP3,INP4) \
203  void FUNC(INP1 a,INP2 b,INP3 c,INP4 d) CONSTNESS {EXECUTE_FUNCTION(FUNC)(a,b,c,d);}
204 #define IMPLEMENT_VOID_RETURNING_FUNCTION_POINTER_5PAR(FUNC, CONSTNESS, INP1,INP2,INP3,INP4,INP5) \
205  void FUNC(INP1 a,INP2 b,INP3 c,INP4 d,INP5 e) CONSTNESS {EXECUTE_FUNCTION(FUNC)(a,b,c,d,e);}
206 
207 //------------------------------------------------------------------------------
208 #define IMPLEMENT_GET_MAIN(FUNC, UNITS)\
209  IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_0PAR(get##FUNC, const, UNITS)
210 #define IMPLEMENT_SET_MAIN(FUNC, UNITS)\
211  IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_1PAR(set##FUNC, , bool, const UNITS)
212 #define IMPLEMENT_IS_MAIN(FUNC)\
213  IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_0PAR(is##FUNC , const, bool)
214 
215 
216 
217 #define IMPLEMENT_GET_AND_SET_MAIN(FUNC, UNITS) \
218  IMPLEMENT_GET_MAIN(FUNC, UNITS); \
219  IMPLEMENT_SET_MAIN(FUNC, UNITS)
220 #define IMPLEMENT_IS_AND_SET_MAIN(FUNC) \
221  IMPLEMENT_IS_MAIN(FUNC); \
222  IMPLEMENT_SET_MAIN(FUNC, bool)
223 
224 #define IMPLEMENT_MAIN_init IMPLEMENT_VOID_RETURNING_FUNCTION_POINTER_0PAR (init , )
225 #define IMPLEMENT_MAIN_print void print(std::ostream& os=std::cout) const {EXECUTE_FUNCTION(print)(os);}
226 #define IMPLEMENT_MAIN_sizeofdata IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_0PAR(sizeofdata , const, uint32_t)
227 #define IMPLEMENT_MAIN_readData IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_1PAR(readData , , void*, const void*)
228 #define IMPLEMENT_MAIN_setBufferSource IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_1PAR(setBufferSource, , bool , const void*)
229 
230 #define IMPLEMENT_MAIN_STANDARD \
231  IMPLEMENT_MAIN_init \
232  using PREVIOUS_VERSION_CLASS_NAME::print; \
233  IMPLEMENT_MAIN_print \
234  IMPLEMENT_MAIN_sizeofdata \
235  using PREVIOUS_VERSION_CLASS_NAME::readData; \
236  IMPLEMENT_MAIN_readData
237 
238 //------------------------------------------------------------------------------
239 #define INIT_FIRST(FUNC, CONSTNESS, OUTPUT_UNITS, ...) \
240  public: OUTPUT_UNITS FUNC(__VA_ARGS__) CONSTNESS; \
241  INIT_CUSTOM_DELEGATE(FUNC, OUTPUT_UNITS,__VA_ARGS__) CONSTNESS
242 
243 #define INIT_FIRST_GET(FUNC, UNITS) INIT_FIRST(get##FUNC, const, UNITS, )
244 #define INIT_FIRST_SET(FUNC, UNITS) INIT_FIRST(set##FUNC, , bool, const UNITS)
245 #define INIT_FIRST_GET_AND_SET(FUNC, UNITS) \
246  INIT_FIRST_GET(FUNC, UNITS); \
247  INIT_FIRST_SET(FUNC, UNITS)
248 
249 //------------------------------------------------------------------------------
250 #define BIND_FUNCTION_TO_CUSTOM_FUNCTION(FUNC,CLASS,FIRSTVERSION_NAMESPACE,BINDING,CONSTNESS,OUTPUT,...) \
251  _function_##FUNC = (DELEGATE(FIRSTVERSION_NAMESPACE::CLASS, , OUTPUT, __VA_ARGS__) CONSTNESS)&BINDING
252 
253 #define BIND_FUNCTION(FUNC,CLASS,FIRSTVERSION_NAMESPACE,BINDINGVERSION_NAMESPACE,CONSTNESS,OUTPUT,...) \
254  BIND_FUNCTION_TO_CUSTOM_FUNCTION(FUNC,CLASS,FIRSTVERSION_NAMESPACE,BINDINGVERSION_NAMESPACE::CLASS::FUNC,CONSTNESS,OUTPUT,__VA_ARGS__)
255 
256 
257 #define BIND_CUSTOM_FUNCTION(FUNC, FIRSTVERSION_NAMESPACE, CONSTNESS, OUTPUT,...) BIND_FUNCTION(FUNC, CURRENT_CLASS, FIRSTVERSION_NAMESPACE, CURRENT_VERSION_NAMESPACE, CONSTNESS, OUTPUT, __VA_ARGS__)
258 
259 
260 #define BIND_GET(FUNC, FIRSTVERSION_NAMESPACE, OUTPUT) BIND_FUNCTION(get##FUNC,CURRENT_CLASS,FIRSTVERSION_NAMESPACE,CURRENT_VERSION_NAMESPACE, const, OUTPUT, )
261 #define BIND_SET(FUNC, FIRSTVERSION_NAMESPACE, INPUT) BIND_FUNCTION(set##FUNC,CURRENT_CLASS,FIRSTVERSION_NAMESPACE,CURRENT_VERSION_NAMESPACE, , bool , const INPUT)
262 #define BIND_IS(FUNC , FIRSTVERSION_NAMESPACE) BIND_FUNCTION(is##FUNC ,CURRENT_CLASS,FIRSTVERSION_NAMESPACE,CURRENT_VERSION_NAMESPACE, const, bool, )
263 
264 #define BIND_GET_AND_SET(FUNC, FIRSTVERSION_NAMESPACE, OUTPUT) \
265  BIND_GET(FUNC, FIRSTVERSION_NAMESPACE, OUTPUT); \
266  BIND_SET(FUNC, FIRSTVERSION_NAMESPACE, OUTPUT);
267 
268 #define BIND_IS_AND_SET(...) \
269  BIND_IS(__VA_ARGS__); \
270  BIND_SET(__VA_ARGS__, bool);
271 
272 
273 /// Binding standard functions
274 #define BIND_STADARD_FUNCTION(FUNC) _function_##FUNC = (FUNC##_t) &CURRENT_VERSION_NAMESPACE::CURRENT_CLASS::FUNC;
275 
276 #define BIND_STADARD_FUNCTIONS \
277  BIND_STADARD_FUNCTION(init); \
278  BIND_STADARD_FUNCTION(print); \
279  BIND_STADARD_FUNCTION(setBufferSource); \
280  BIND_STADARD_FUNCTION(readData);
281 
282 
283 
284 //------------------------------------------------------------------------------
285 //
286 #define IMPLEMENT_FIGUREOUT_VERSION_STATIC_WITH_CUSTOM_GET_VERSION(CLASS, GETVERSIONFUNCTION) \
287  version_t figureOutTheVersion (const void* buffer) const {return figureOutTheVersionStatic(buffer);} \
288  static version_t figureOutTheVersionStatic(const void* buffer){ \
289  CLASS header_zero((void*)buffer, 0); \
290  return (version_t)header_zero.GETVERSIONFUNCTION(); \
291  }
292 
293 
294 /// This should be in the header
295 #define IMPLEMENT_FIGUREOUT_VERSION_STATIC(CLASS) IMPLEMENT_FIGUREOUT_VERSION_STATIC_WITH_CUSTOM_GET_VERSION(CLASS, getVersion)
296 
297 #endif /* MACROS_H */
298