#ifndef CT_ABSTRACTITEMATTRIBUTET_H #define CT_ABSTRACTITEMATTRIBUTET_H #include "ct_attributes/abstract/ct_abstractitemattribute.h" #include "ct_coordinates/abstract/ct_abstractcoordinatesystem.h" template class CT_AbstractItemAttributeT : public CT_AbstractItemAttribute { public: CT_AbstractItemAttributeT(const CT_OutAbstractItemAttributeModel *model, const CT_AbstractCategory *category, const CT_AbstractResult *result); CT_AbstractItemAttributeT(const QString &modelName, const QString &categoryName, const CT_AbstractResult *result); /** * @brief Use only this constructor for model ! */ CT_AbstractItemAttributeT(const QString &categoryName); /** * @brief ok = false if the specialization does not exist */ bool toBool(const CT_AbstractItemDrawable *item, bool *ok) const; /** * @brief ok = false if the specialization does not exist */ double toDouble(const CT_AbstractItemDrawable *item, bool *ok) const; /** * @brief ok = false if the specialization does not exist */ float toFloat(const CT_AbstractItemDrawable *item, bool *ok) const; /** * @brief ok = false if the specialization does not exist */ long double toLongDouble(const CT_AbstractItemDrawable *item, bool *ok) const; /** * @brief ok = false if the specialization does not exist */ int toInt(const CT_AbstractItemDrawable *item, bool *ok) const; /** * @brief ok = false if the specialization does not exist */ quint64 toUInt64(const CT_AbstractItemDrawable *item, bool *ok) const; /** * @brief ok = false if the specialization does not exist */ size_t toSizeT(const CT_AbstractItemDrawable *item, bool *ok) const; /** * @brief ok = true in all case and the value is converted to a QString. */ virtual QString toString(const CT_AbstractItemDrawable *item, bool *ok) const; /** * @brief Returns the data */ virtual VType data(const CT_AbstractItemDrawable *item) const = 0; /** * @brief Type of value */ CT_AbstractCategory::ValueType type() const; /** * @brief Type of value to String */ QString typeToString() const; }; //specialization to convert a type to another on compilation // BOOLEAN -> BOOLEAN template<> inline bool CT_AbstractItemAttributeT::toBool(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // LONG DOUBLE -> LONG DOUBLE template<> inline long double CT_AbstractItemAttributeT::toLongDouble(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // DOUBLE -> DOUBLE template<> inline double CT_AbstractItemAttributeT::toDouble(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // DOUBLE -> LONG DOUBLE template<> inline long double CT_AbstractItemAttributeT::toLongDouble(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // FLOAT -> FLOAT template<> inline float CT_AbstractItemAttributeT::toFloat(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // FLOAT -> DOUBLE template<> inline double CT_AbstractItemAttributeT::toDouble(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // FLOAT -> LONG DOUBLE template<> inline long double CT_AbstractItemAttributeT::toLongDouble(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // SIGNED INTEGER -> SIGNED INTEGER template<> inline int CT_AbstractItemAttributeT::toInt(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // SIGNED INTEGER -> FLOAT template<> inline float CT_AbstractItemAttributeT::toFloat(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // SIGNED INTEGER -> DOUBLE template<> inline double CT_AbstractItemAttributeT::toDouble(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // SIGNED INTEGER -> LONG DOUBLE template<> inline long double CT_AbstractItemAttributeT::toLongDouble(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // UNSIGNED INTEGER 64bits -> UNSIGNED INTEGER 64bits template<> inline quint64 CT_AbstractItemAttributeT::toUInt64(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // UNSIGNED INTEGER 64bits -> FLOAT template<> inline float CT_AbstractItemAttributeT::toFloat(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // UNSIGNED INTEGER 64bits -> DOUBLE template<> inline double CT_AbstractItemAttributeT::toDouble(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // UNSIGNED INTEGER 64bits -> LONG DOUBLE template<> inline long double CT_AbstractItemAttributeT::toLongDouble(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // SIZE_T -> SIZE_T template<> inline size_t CT_AbstractItemAttributeT::toSizeT(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } #ifndef ENVIRONMENT64 // SIZE_T -> FLOAT template<> inline float CT_AbstractItemAttributeT::toFloat(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // SIZE_T -> DOUBLE template<> inline double CT_AbstractItemAttributeT::toDouble(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } // SIZE_T -> LONG DOUBLE template<> inline long double CT_AbstractItemAttributeT::toLongDouble(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } #endif // QSTRING -> QSTRING template<> inline QString CT_AbstractItemAttributeT::toString(const CT_AbstractItemDrawable *item, bool *ok) const { if(ok != NULL) { *ok = true; } return data(item); } #include "ct_attributes/abstract/ct_abstractitemattributet.hpp" #endif // CT_ABSTRACTITEMATTRIBUTET_H