11 #ifndef app_indiMacros_hpp
12 #define app_indiMacros_hpp
22 #define SET_INDI_NEWCALLBACK(class, prop) static int st_ ## newCallBack ## _ ## prop( void * app, const pcf::IndiProperty &ipRecv)\
24 return static_cast<class *>(app)->newCallBack ## _ ## prop(ipRecv);\
35 #define SET_INDI_SETCALLBACK(class, prop) static int st_ ## setCallBack ## _ ## prop( void * app, const pcf::IndiProperty &ipRecv)\
37 return static_cast<class *>(app)->setCallBack ## _ ## prop(ipRecv);\
48 #define INDI_NEWCALLBACK_DECL(class, prop) int newCallBack_ ## prop(const pcf::IndiProperty &ipRecv); \
49 SET_INDI_NEWCALLBACK(class, prop)
59 #define INDI_SETCALLBACK_DECL(class, prop) int setCallBack_ ## prop(const pcf::IndiProperty &ipRecv); \
60 SET_INDI_SETCALLBACK(class, prop)
89 #define INDI_NEWCALLBACK_DEFN(class, prop) int class::newCallBack_ ## prop
118 #define INDI_SETCALLBACK_DEFN(class, prop) int class::setCallBack_ ## prop
120 #ifndef XWCTEST_INDI_CALLBACK_VALIDATION
121 #define INDI_VALIDATE_LOG_ERROR(prop1, prop2) log<software_error>({__FILE__,__LINE__, "INDI properties do not match in callback: " \
122 + prop1.createUniqueKey() + " != " + prop2.createUniqueKey()});
124 #define INDI_VALIDATE_LOG_ERROR_DERIVED(prop1, prop2) derivedT::template log<software_error>({__FILE__,__LINE__, "INDI properties do not match in callback: " \
125 + prop1.createUniqueKey() + " != " + prop2.createUniqueKey()});
127 #define INDI_VALIDATE_LOG_ERROR(prop1, prop2)
128 #define INDI_VALIDATE_LOG_ERROR_DERIVED(prop1,prop2)
135 #define INDI_VALIDATE_CALLBACK_PROPS_IMPL(prop1, prop2) \
136 if(prop1.createUniqueKey() != prop2.createUniqueKey()) \
138 INDI_VALIDATE_LOG_ERROR(prop1, prop2) \
142 #ifdef XWCTEST_INDI_CALLBACK_VALIDATION
145 #define INDI_VALIDATE_CALLBACK_PROPS(prop1, prop2) INDI_VALIDATE_CALLBACK_PROPS_IMPL(prop1, prop2) \
162 #define INDI_VALIDATE_CALLBACK_PROPS(prop1, prop2) INDI_VALIDATE_CALLBACK_PROPS_IMPL( prop1, prop2 )
171 #define INDI_VALIDATE_CALLBACK_PROPS_DERIVED_IMPL(prop1, prop2) \
172 if(prop1.createUniqueKey() != prop2.createUniqueKey()) \
174 INDI_VALIDATE_LOG_ERROR_DERIVED(prop1, prop2) \
178 #ifdef XWCTEST_INDI_CALLBACK_VALIDATION
181 #define INDI_VALIDATE_CALLBACK_PROPS_DERIVED(prop1, prop2) INDI_VALIDATE_CALLBACK_PROPS_DERIVED_IMPL(prop1, prop2) else {return 0;}
197 #define INDI_VALIDATE_CALLBACK_PROPS_DERIVED(prop1, prop2) INDI_VALIDATE_CALLBACK_PROPS_DERIVED_IMPL( prop1, prop2)
208 #define INDI_NEWCALLBACK(prop) st_newCallBack_ ## prop
217 #define INDI_SETCALLBACK(prop) st_setCallBack_ ## prop
230 #define REG_INDI_NEWPROP(prop, propName, type) \
231 if( registerIndiPropertyNew( prop, propName, type, pcf::IndiProperty::ReadWrite, pcf::IndiProperty::Idle, INDI_NEWCALLBACK(prop)) < 0) \
233 return log<software_error,-1>({__FILE__,__LINE__, "failed to register new property"}); \
248 #define REG_INDI_NEWPROP_NOCB(prop, propName, type) \
249 if( registerIndiPropertyNew( prop, propName, type, pcf::IndiProperty::ReadOnly, pcf::IndiProperty::Idle, 0) < 0) \
251 return log<software_error,-1>({__FILE__,__LINE__, "failed to register read only property"}); \
265 #define REG_INDI_NEWPROP_NOCB_DERIVED(prop, propName, type) \
266 if( derived().registerIndiPropertyNew( prop, propName, type, pcf::IndiProperty::ReadOnly, pcf::IndiProperty::Idle, 0) < 0) \
268 return derivedT::template log<software_error,-1>({__FILE__,__LINE__, "failed to register read only property"}); \
282 #define REG_INDI_SETPROP(prop, devName, propName) \
283 if( registerIndiPropertySet( prop,devName, propName, INDI_SETCALLBACK(prop)) < 0) \
285 return log<software_error,-1>({__FILE__,__LINE__, "failed to register set property"}); \
288 #define REG_INDI_SETPROP_DERIVED(prop, devName, propName) \
289 if( derived().template registerIndiPropertySet( prop,devName, propName, INDI_SETCALLBACK(prop)) < 0) \
291 return derivedT::template log<software_error,-1>({__FILE__,__LINE__, "failed to register set property"}); \
309 #define CREATE_REG_INDI_NEW_NUMBERF( prop, name, min, max, step, format, label, group) \
310 if( createStandardIndiNumber<float>( prop, name, min, max, step, format, label, group) < 0) \
312 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiNumber"}); \
315 if( registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
317 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
336 #define CREATE_REG_INDI_NEW_NUMBERI( prop, name, min, max, step, format, label, group) \
337 if( createStandardIndiNumber<int>( prop, name, min, max, step, format, label, group) < 0) \
339 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiNumber"}); \
342 if( registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
344 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
363 #define CREATE_REG_INDI_NEW_NUMBERU( prop, name, min, max, step, format, label, group) \
364 if( createStandardIndiNumber<unsigned>( prop, name, min, max, step, format, label, group) < 0) \
366 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiNumber"}); \
369 if( registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
371 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
385 #define CREATE_REG_INDI_RO_NUMBER( prop, name, label, group ) \
386 if( createROIndiNumber( prop, name, label, group ) < 0) \
388 log<software_error>({__FILE__,__LINE__, "error from createROIndiNumber"}); \
391 if( registerIndiPropertyReadOnly( prop ) < 0) \
393 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyReadOnly"}); \
405 #define CREATE_REG_INDI_NEW_TOGGLESWITCH( prop, name) \
406 if( createStandardIndiToggleSw( prop, name) < 0) \
408 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiToggleSw"}); \
411 if( registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
413 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
425 #define CREATE_REG_INDI_NEW_TOGGLESWITCH_NOCB( prop, name) \
426 if( createStandardIndiToggleSw( prop, name) < 0) \
428 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiToggleSw"}); \
431 if( registerIndiPropertyNew( prop, nullptr) < 0) \
433 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
445 #define CREATE_REG_INDI_NEW_REQUESTSWITCH( prop, name) \
446 if( createStandardIndiRequestSw( prop, name) < 0) \
448 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiRequestSw"}); \
451 if( registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
453 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
472 #define CREATE_REG_INDI_NEW_NUMBERF_DERIVED( prop, name, min, max, step, format, label, group) \
473 if( derived().template createStandardIndiNumber<float>( prop, name, min, max, step, format, label, group) < 0) \
475 derivedT::template log<software_error>({__FILE__,__LINE__, "error from createStandardIndiNumber"}); \
478 if( derived().template registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
480 derivedT::template log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
500 #define CREATE_REG_INDI_NEW_NUMBERI_DERIVED( prop, name, min, max, step, format, label, group) \
501 if( derived().template createStandardIndiNumber<int>( prop, name, min, max, step, format, label, group) < 0) \
503 derivedT::template log<software_error>({__FILE__,__LINE__, "error from createStandardIndiNumber"}); \
506 if( derived().template registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
508 derivedT::template log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
520 #define CREATE_REG_INDI_NEW_TOGGLESWITCH_DERIVED( prop, name ) \
521 if( derived().template createStandardIndiToggleSw( prop, name) < 0) \
523 derivedT::template log<software_error>({__FILE__,__LINE__, "error from createStandardIndiToggleSw"}); \
526 if( derived().template registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
528 derivedT::template log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
540 #define CREATE_REG_INDI_NEW_REQUESTSWITCH_DERIVED( prop, name) \
541 if( derived().template createStandardIndiRequestSw( prop, name) < 0) \
543 derivedT::template log<software_error>({__FILE__,__LINE__, "error from createStandardIndiRequestSw"}); \
546 if( derived().template registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
548 derivedT::template log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \