refs #84 removed the CValueObject::compare method and added a friend function BlackMisc::compare to replace it.

The new compare is implemented using "multimethods" described in the book Advanced C++ Programming Styles and Idioms by James Coplien.

First, the isA method is used to determine which of the values being compared is the most general. (For example, CLength is more general than CAltitude.)
Then the compareImpl method is called on the most general value, with the other value as an argument.
If there is not a direct inheritance relation between the two values (or they are the same class) then the comparison is invalid and a assert is triggered.
This commit is contained in:
Mathew Sutcliffe
2014-01-14 00:45:19 +00:00
parent e40c93fe1b
commit db4c05dd9f
48 changed files with 1015 additions and 119 deletions

View File

@@ -164,6 +164,21 @@ namespace BlackMisc
*/
virtual QString convertToQString(bool i18n = false) const;
/*!
* \copydoc CValueObject::getMetaTypeId
*/
virtual int getMetaTypeId() const;
/*!
* \copydoc CValueObject::isA
*/
virtual bool isA(int metaTypeId) const;
/*!
* \copydoc CValueObject::compareImpl
*/
virtual int compareImpl(const CValueObject &other) const;
/*!
* \brief Stream to DBus <<
* \param argument