From e5afc2c6279566f9e752dd673028a994eb794d78 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Tue, 30 Apr 2013 20:12:47 +0100 Subject: [PATCH] made derived() private instead of protected in CRTP --- src/blackmisc/mathmatrixbase.h | 22 +++++++++--------- src/blackmisc/mathvector3dbase.h | 37 +++++++++++++++--------------- src/blackmisc/pqphysicalquantity.h | 37 +++++++++++++++--------------- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/blackmisc/mathmatrixbase.h b/src/blackmisc/mathmatrixbase.h index 8b3b6152b..570e64b52 100644 --- a/src/blackmisc/mathmatrixbase.h +++ b/src/blackmisc/mathmatrixbase.h @@ -20,17 +20,7 @@ namespace Math */ template class CMatrixBase : public BlackMisc::CBaseStreamStringifier { - -protected: - // no bug, Qt expects columns rows - QGenericMatrix m_matrix; //!< backing data - - /*! - * \brief Conversion to string - * \return - */ - QString stringForConverter() const; - +private: /*! * \brief Easy access to derived class (CRTP template parameter) * \return @@ -49,6 +39,16 @@ protected: return static_cast(this); } +protected: + // no bug, Qt expects columns rows + QGenericMatrix m_matrix; //!< backing data + + /*! + * \brief Conversion to string + * \return + */ + QString stringForConverter() const; + public: /*! * \brief Default constructor diff --git a/src/blackmisc/mathvector3dbase.h b/src/blackmisc/mathvector3dbase.h index 1fe7d6133..5dc29cf5b 100644 --- a/src/blackmisc/mathvector3dbase.h +++ b/src/blackmisc/mathvector3dbase.h @@ -23,6 +23,25 @@ class CMatrix3x1; // forward declaration */ template class CVector3DBase : public CBaseStreamStringifier { +private: + /*! + * \brief Easy access to derived class (CRTP template parameter) + * \return + */ + ImplVector const* derived() const + { + return static_cast(this); + } + + /*! + * \brief Easy access to derived class (CRTP template parameter) + * \return + */ + ImplVector* derived() + { + return static_cast(this); + } + protected: // using own value since Qt QVector3D stores internally as float @@ -61,24 +80,6 @@ protected: */ virtual QString stringForConverter() const; - /*! - * \brief Easy access to derived class (CRTP template parameter) - * \return - */ - ImplVector const* derived() const - { - return static_cast(this); - } - - /*! - * \brief Easy access to derived class (CRTP template parameter) - * \return - */ - ImplVector* derived() - { - return static_cast(this); - } - public: // getter and setters are implemented in the derived classes diff --git a/src/blackmisc/pqphysicalquantity.h b/src/blackmisc/pqphysicalquantity.h index 053fcf829..e5c3c7e3d 100644 --- a/src/blackmisc/pqphysicalquantity.h +++ b/src/blackmisc/pqphysicalquantity.h @@ -23,13 +23,30 @@ namespace PhysicalQuantities */ template class CPhysicalQuantity : public BlackMisc::CBaseStreamStringifier { - private: double m_unitValueD; //!< value backed by double qint32 m_unitValueI; //!< value backed by integer, allows sole integer arithmetic double m_convertedSiUnitValueD; //!< SI unit value bool m_isIntegerBaseValue; //!< flag integer? / double? + /*! + * \brief Easy access to derived class (CRTP template parameter) + * \return + */ + PQ const* derived() const + { + return static_cast(this); + } + + /*! + * \brief Easy access to derived class (CRTP template parameter) + * \return + */ + PQ* derived() + { + return static_cast(this); + } + protected: MU m_unit; //!< unit MU m_conversionSiUnit; //!< corresponding SI base unit @@ -59,24 +76,6 @@ protected: return this->unitValueRoundedWithUnit(-1); } - /*! - * \brief Easy access to derived class (CRTP template parameter) - * \return - */ - PQ const* derived() const - { - return static_cast(this); - } - - /*! - * \brief Easy access to derived class (CRTP template parameter) - * \return - */ - PQ* derived() - { - return static_cast(this); - } - /*! * \brief Init by integer * \param baseValue