Index: sources/main.h =================================================================== diff -u -r2d09ae36f6b791e0415a87b6f14f582d4b434d7d -rb62ab443e75b76a91e35aca6ba2efd84e7199602 --- sources/main.h (.../main.h) (revision 2d09ae36f6b791e0415a87b6f14f582d4b434d7d) +++ sources/main.h (.../main.h) (revision b62ab443e75b76a91e35aca6ba2efd84e7199602) @@ -7,7 +7,7 @@ * * \file main.h * \author (last) Peter Lucia - * \date (last) 26-Jun-2020 + * \date (last) 15-Oct-2020 * \author (original) Behrouz NematiPour * \date (original) 28-Oct-2019 * @@ -16,7 +16,7 @@ // Qt #include - +#include // Project // TODO : A singleton parent class needs to be created @@ -33,6 +33,10 @@ vCLASS(vCLASS const &) = delete; \ vCLASS & operator = (vCLASS const &) = delete; \ public: \ + /*! \brief instance accessor + \details A singleton class single instance creator/accessor + \return reference to the class static instance + */\ static vCLASS &I() { \ static vCLASS _instance; \ return _instance; \ @@ -44,52 +48,83 @@ extern const char*gFakeData_default; extern bool gSendEmptyKeepAwake; extern bool gFakeSeqAtBegin; -extern bool gDisableHunhandledReport; +extern bool gDisableUnhandledReport; extern bool gDisableTimeout; //--------------------------------------------------------------------------------// //--------------------------------------------------------------------------------// #define DEBUG_PROPERTY_CHANGED(vVARIABLE, PREFIX) // qDebug() << "#" << #vVARIABLE << PREFIX##vVARIABLE; //--------------------------------------------------------------------------------// -#define PROPERTY_SLOT( vTYPE , vVARIABLE ) \ - protected : \ - void vVARIABLE ( const vTYPE & v##vVARIABLE ) { \ - static bool init = false; \ - if ( !init || _##vVARIABLE != v##vVARIABLE ) { \ - DEBUG_PROPERTY_CHANGED(vVARIABLE, v) \ - init = true; \ - _##vVARIABLE = v##vVARIABLE; \ - emit vVARIABLE##Changed( _##vVARIABLE ); \ - } \ +#define PROPERTY_SLOT( vTYPE , vVARIABLE ) \ + protected : \ + /*! \brief Property setter + \details The property setter which update the private variable \n + - if only the value has been changed \n + - or it's the first time property is set. \n + emits the Property notify (...Changed) signal on update. \n + the notify signal (...Changed) passes the new value as its parameter. \n + \param new value + */\ + void vVARIABLE ( const vTYPE & v##vVARIABLE ) { \ + static bool init = false; \ + if ( !init || _##vVARIABLE != v##vVARIABLE ) { \ + DEBUG_PROPERTY_CHANGED(vVARIABLE, v) \ + init = true; \ + _##vVARIABLE = v##vVARIABLE; \ + emit vVARIABLE##Changed( _##vVARIABLE ); \ + } \ } //--------------------------------------------------------------------------------// -#define TRIGGER_SLOT( vTYPE , vVARIABLE ) \ - protected: \ - void vVARIABLE ( const vTYPE & v##vVARIABLE ) { \ - DEBUG_PROPERTY_CHANGED(vVARIABLE, v) \ - _##vVARIABLE = v##vVARIABLE; \ - emit vVARIABLE##Triggered( _##vVARIABLE ); \ +#define TRIGGER_SLOT( vTYPE , vVARIABLE ) \ + protected: \ + /*! \brief Trigger setter + \details The Trigger setter which update the private variable \n + with no condition each time the value the passed. \n + emits the Trigger notify (...Triggered) signal after update. \n + the notify signal (...Triggered) passes the new value as its parameter.\n + \param new value + */\ + void vVARIABLE ( const vTYPE & v##vVARIABLE ) { \ + DEBUG_PROPERTY_CHANGED(vVARIABLE, v) \ + _##vVARIABLE = v##vVARIABLE; \ + emit vVARIABLE##Triggered( _##vVARIABLE ); \ } //--------------------------------------------------------------------------------// -#define PROPERTY_BASE(vTYPE , vVARIABLE , vDEFVALUE, vSIGNAL) \ - Q_PROPERTY( vTYPE vVARIABLE \ - READ vVARIABLE \ - WRITE vVARIABLE \ - NOTIFY vVARIABLE##vSIGNAL) \ - Q_SIGNALS: \ - void vVARIABLE##vSIGNAL( const vTYPE & v##vVARIABLE ); \ - private: \ - vTYPE _##vVARIABLE = vDEFVALUE; \ - protected: \ - vTYPE vVARIABLE () const { \ - return _##vVARIABLE ; \ - } +#define PROPERTY_BASE(vTYPE , vVARIABLE , vDEFVALUE, vSIGNAL) \ + /*! \brief Qt Property declaration + \details The Qt Property definition by Q_PROPERTY documentation. + */\ + Q_PROPERTY( vTYPE vVARIABLE \ + READ vVARIABLE \ + WRITE vVARIABLE \ + NOTIFY vVARIABLE##vSIGNAL) \ + Q_SIGNALS: \ + /*! \brief Property notify signal + \details The property notify signal (...Changed) + which will be emitted by property setter + - if only the value has been changed \n + - or it's the first time property is set. \n + \return current value + */\ + void vVARIABLE##vSIGNAL( const vTYPE & v##vVARIABLE ); \ + private: \ + vTYPE _##vVARIABLE = vDEFVALUE; \ + protected: \ + /*! \brief Property getter + \details The property getter which reads the private variable + \return current value + */\ + vTYPE vVARIABLE () const { \ + return _##vVARIABLE ; \ + } //--------------------------------------------------------------------------------// -#define PROPERTY( vTYPE , vVARIABLE , vDEFVALUE ) \ - PROPERTY_BASE( vTYPE , vVARIABLE , vDEFVALUE , Changed ) \ +#define PROPERTY( vTYPE , vVARIABLE , vDEFVALUE ) \ + \ + PROPERTY_BASE( vTYPE , vVARIABLE , vDEFVALUE , Changed ) \ PROPERTY_SLOT( vTYPE , vVARIABLE) //--------------------------------------------------------------------------------// -#define TRIGGER( vTYPE , vVARIABLE , vDEFVALUE ) \ - PROPERTY_BASE( vTYPE , vVARIABLE , vDEFVALUE , Triggered) \ +#define TRIGGER( vTYPE , vVARIABLE , vDEFVALUE ) \ + \ + PROPERTY_BASE( vTYPE , vVARIABLE , vDEFVALUE , Triggered) \ TRIGGER_SLOT( vTYPE , vVARIABLE) //--------------------------------------------------------------------------------// //--------------------------------------------------------------------------------// @@ -114,89 +149,153 @@ //--------------------------------------------------------------------------------// #define ACTION_RECEIVE_PRIVATE_SLOT(vTYPE) \ private Q_SLOTS: \ + /*! \brief Bridge slot + \details The bridge slot is for thread safety between classes for received message + and is used to emit its signal to pass the model data to next observer. + \param vData - The model data which has been received. + \note This method is private and the interface is signals only. (starts with 'on') + */\ void onActionReceive (const vTYPE &vData) { \ emit didActionReceive(vData); \ } //--------------------------------------------------------------------------------// #define ADJUST_TRANSMT_PRIVATE_SLOT_DEFINITION(vTYPE) \ private Q_SLOTS: \ + /*! \brief Adjustment slot + \details The bridge slot is for thread safety between classes for adjustment messages + and is used to emit its signal to pass the model data to next observer. + \param vData - The model data to be used for adjustment + \note This method is private and the interface is signals only. (starts with 'on') + This slot has to have its specific implementation and is not a bridge (not a signal emitter). + */\ void onAdjustment (const vTYPE &vData); //--------------------------------------------------------------------------------// #define ADJUST_TRANSMT_PRIVATE_SLOT(vTYPE) \ private Q_SLOTS: \ + /*! \brief Adjustment bridge slot + \details The bridge slot is for thread safety between classes for adjustment messages + and is used to emit its signal to pass the model data to next observer. + \param vData - The model data to be used for adjustment + \note This method is private and the interface is signals only. (starts with 'on') + */\ void onAdjustment (const vTYPE &vData) { \ emit didAdjustment( vData); \ } //--------------------------------------------------------------------------------// #define ADJUST_TRANSMT_PUBLIC_SLOT(vTYPE) \ public Q_SLOTS: \ + /*! \brief Adjustment invocable/exposed slot + \details This slot is able to be called within QML context + when an object of the class is instantiated in QML. + For thread safety it's calling its designated signal to notify observers. + \note This method is public and is the interface. (starts with 'do') + */\ void doAdjustment (const vTYPE &vData) { \ emit didAdjustment( vData); \ } //--------------------------------------------------------------------------------// #define ACTION_RECEIVE_SIGNAL(vTYPE) \ Q_SIGNALS: \ + /*! \brief Receive bridge signal + \details The bridge signal is for thread safety between classes for received message + and is used to be emitted in its slot to pass the model data to next observer. + \param vData - The model data which has been received. + \note This method is public to be exposed to the observers to be able to connect to it as the interface. (starts with 'did') + */\ void didActionReceive (const vTYPE &vData); //--------------------------------------------------------------------------------// -#define ACTION_TRANSMT_SIGNAL(vTYPE) \ -Q_SIGNALS: \ - void didActionTransmit(const vTYPE &vData); -//--------------------------------------------------------------------------------// #define ADJUST_TRANSMT_SIGNAL(vTYPE) \ Q_SIGNALS: \ + /*! \brief Adjustment bridge signal + \details The bridge signal is for thread safety between classes for received message + and is used to be emitted in its slot to pass the model data to next observer. + \param vData - The model data which has been received. + \note This method is public to be exposed to the observers to be able to connect to it as the interface. (starts with 'did') + */\ void didAdjustment (const vTYPE &vData); //--------------------------------------------------------------------------------// #define ACTION_RECEIVE_BRIDGE_DEFINITION(vTYPE) \ + \ ACTION_RECEIVE_PRIVATE_SLOT (vTYPE) \ - ACTION_RECEIVE_SIGNAL (vTYPE) + ACTION_RECEIVE_SIGNAL (vTYPE) \ //--------------------------------------------------------------------------------// #define ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT(vTYPE) \ + \ ADJUST_TRANSMT_PRIVATE_SLOT_DEFINITION (vTYPE) \ - ADJUST_TRANSMT_SIGNAL (vTYPE) + ADJUST_TRANSMT_SIGNAL (vTYPE) \ //--------------------------------------------------------------------------------// #define ADJUST_TRANSMT_BRIDGE_DEFINITION(vTYPE) \ + \ ADJUST_TRANSMT_PRIVATE_SLOT (vTYPE) \ - ADJUST_TRANSMT_SIGNAL (vTYPE) + ADJUST_TRANSMT_SIGNAL (vTYPE) \ //--------------------------------------------------------------------------------// #define ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC(vTYPE) \ + \ ADJUST_TRANSMT_PUBLIC_SLOT (vTYPE) \ - ADJUST_TRANSMT_SIGNAL (vTYPE) + ADJUST_TRANSMT_SIGNAL (vTYPE) \ + //--------------------------------------------------------------------------------// #define REGISTER_METATYPE(vTYPE) \ qRegisterMetaType < vTYPE > (#vTYPE); //--------------------------------------------------------------------------------// #define REGISTER_TYPE(vTYPE) \ qmlRegisterType < vTYPE > (#vTYPE, 0, 1, #vTYPE); #define GET_VARIABLE_NAME(VARIABLE) (#VARIABLE) -#define TREATMENT_PARAMETER(TYPE, NAME, DEFVALUE) \ -private: \ - TYPE _##NAME = DEFVALUE; \ - bool is##NAME##Set = false; \ -protected: \ - Q_PROPERTY(TYPE NAME \ - READ get_##NAME \ - WRITE set_##NAME \ - NOTIFY NAME##Changed) \ - void set_##NAME(const TYPE &p##NAME) { \ - static bool init = false; \ - if ( !init || _##NAME != p##NAME ) { \ - init = true; \ - _##NAME = p##NAME; \ - DEBUG_PROPERTY_CHANGED(NAME, _) \ - is##NAME##Set = true; \ - emit NAME##Changed(_##NAME); \ - onUserModifiedParameters(); \ - } \ - } \ - TYPE get_##NAME() const { \ - return _##NAME; \ - } \ - void reset_##NAME() { \ - _##NAME = DEFVALUE; \ - is##NAME##Set = false; \ - emit NAME##Changed(_##NAME); \ - } \ -Q_SIGNALS: \ - void NAME##Changed(const TYPE &p##NAME); \ +#define DEBUG_TREATMENT_PARAMETER(NAME, VARIABLE) // qDebug() << NAME << VARIABLE; +#define TREATMENT_PARAMETER(TYPE, NAME, DEFVALUE, MIN, MAX, RES) \ +private: \ + TYPE _##NAME = DEFVALUE; \ + TYPE _##NAME##Min = MIN; \ + TYPE _##NAME##Max = MAX; \ + TYPE _##NAME##Res = RES; \ + bool is##NAME##Set = false; \ +protected: \ + Q_PROPERTY(TYPE NAME \ + READ NAME \ + WRITE NAME \ + NOTIFY NAME##Changed) \ + Q_PROPERTY(TYPE NAME##Min \ + READ NAME##Min \ + WRITE NAME##Min \ + NOTIFY NAME##MinChanged) \ + Q_PROPERTY(TYPE NAME##Max \ + READ NAME##Max \ + WRITE NAME##Max \ + NOTIFY NAME##MaxChanged) \ + Q_PROPERTY(TYPE NAME##Res \ + READ NAME##Res \ + WRITE NAME##Res \ + NOTIFY NAME##ResChanged) \ + void NAME(const TYPE &v##NAME) { \ + if ( !is##NAME##Set || _##NAME != v##NAME ) { \ + _##NAME = v##NAME; \ + is##NAME##Set = true; \ + emit NAME##Changed(_##NAME); \ + doUserModifiedParameters(); \ + } \ + DEBUG_TREATMENT_PARAMETER(#NAME, _##NAME) \ + } \ + TYPE NAME##Min() const { return _##NAME##Min; } \ + void NAME##Min(const TYPE &v##NAME##Min) \ + { _##NAME##Min = v##NAME##Min; emit NAME##MinChanged(_##NAME##Min);} \ + TYPE NAME##Max() const { return _##NAME##Max; } \ + void NAME##Max(const TYPE &v##NAME##Max) \ + { _##NAME##Max = v##NAME##Max; emit NAME##MaxChanged(_##NAME##Max);} \ + TYPE NAME##Res() const { return _##NAME##Res; } \ + void NAME##Res(const TYPE &v##NAME##Res) \ + { _##NAME##Res = v##NAME##Res; emit NAME##ResChanged(_##NAME##Res);} \ + TYPE NAME() const { \ + return _##NAME; \ + } \ + void reset_##NAME() { \ + _##NAME = DEFVALUE; \ + is##NAME##Set = false; \ + emit NAME##Changed(_##NAME); \ + } \ +Q_SIGNALS: \ + void NAME##Changed(const TYPE &v##NAME); \ + void NAME##MinChanged(const TYPE &v##NAME); \ + void NAME##MaxChanged(const TYPE &v##NAME); \ + void NAME##ResChanged(const TYPE &v##NAME); \ void NAME##_ValidationFailed(const QString &reason);