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) else {return 0;}
161 #define INDI_VALIDATE_CALLBACK_PROPS(prop1, prop2) INDI_VALIDATE_CALLBACK_PROPS_IMPL( prop1, prop2 )
170 #define INDI_VALIDATE_CALLBACK_PROPS_DERIVED_IMPL(prop1, prop2) \
171 if(prop1.createUniqueKey() != prop2.createUniqueKey()) \
173 INDI_VALIDATE_LOG_ERROR_DERIVED(prop1, prop2) \
177 #ifdef XWCTEST_INDI_CALLBACK_VALIDATION
180 #define INDI_VALIDATE_CALLBACK_PROPS_DERIVED(prop1, prop2) INDI_VALIDATE_CALLBACK_PROPS_DERIVED_IMPL(prop1, prop2) else {return 0;}
196 #define INDI_VALIDATE_CALLBACK_PROPS_DERIVED(prop1, prop2) INDI_VALIDATE_CALLBACK_PROPS_DERIVED_IMPL( prop1, prop2)
207 #define INDI_NEWCALLBACK(prop) st_newCallBack_ ## prop
216 #define INDI_SETCALLBACK(prop) st_setCallBack_ ## prop
229 #define REG_INDI_NEWPROP(prop, propName, type) \
230 if( registerIndiPropertyNew( prop, propName, type, pcf::IndiProperty::ReadWrite, pcf::IndiProperty::Idle, INDI_NEWCALLBACK(prop)) < 0) \
232 return log<software_error,-1>({__FILE__,__LINE__, "failed to register new property"}); \
247 #define REG_INDI_NEWPROP_NOCB(prop, propName, type) \
248 if( registerIndiPropertyNew( prop, propName, type, pcf::IndiProperty::ReadOnly, pcf::IndiProperty::Idle, 0) < 0) \
250 return log<software_error,-1>({__FILE__,__LINE__, "failed to register read only property"}); \
264 #define REG_INDI_SETPROP(prop, devName, propName) \
265 if( registerIndiPropertySet( prop,devName, propName, INDI_SETCALLBACK(prop)) < 0) \
267 return log<software_error,-1>({__FILE__,__LINE__, "failed to register set property"}); \
285 #define CREATE_REG_INDI_NEW_NUMBERF( prop, name, min, max, step, format, label, group) \
286 if( createStandardIndiNumber<float>( prop, name, min, max, step, format, label, group) < 0) \
288 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiNumber"}); \
291 if( registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
293 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
312 #define CREATE_REG_INDI_NEW_NUMBERI( prop, name, min, max, step, format, label, group) \
313 if( createStandardIndiNumber<int>( prop, name, min, max, step, format, label, group) < 0) \
315 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiNumber"}); \
318 if( registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
320 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
339 #define CREATE_REG_INDI_NEW_NUMBERU( prop, name, min, max, step, format, label, group) \
340 if( createStandardIndiNumber<unsigned>( prop, name, min, max, step, format, label, group) < 0) \
342 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiNumber"}); \
345 if( registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
347 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
359 #define CREATE_REG_INDI_NEW_TOGGLESWITCH( prop, name) \
360 if( createStandardIndiToggleSw( prop, name) < 0) \
362 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiToggleSw"}); \
365 if( registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
367 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
379 #define CREATE_REG_INDI_NEW_TOGGLESWITCH_NOCB( prop, name) \
380 if( createStandardIndiToggleSw( prop, name) < 0) \
382 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiToggleSw"}); \
385 if( registerIndiPropertyNew( prop, nullptr) < 0) \
387 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \
399 #define CREATE_REG_INDI_NEW_REQUESTSWITCH( prop, name) \
400 if( createStandardIndiRequestSw( prop, name) < 0) \
402 log<software_error>({__FILE__,__LINE__, "error from createStandardIndiRequestSw"}); \
405 if( registerIndiPropertyNew( prop, INDI_NEWCALLBACK(prop)) < 0) \
407 log<software_error>({__FILE__,__LINE__, "error from registerIndiPropertyNew"}); \