Use static assert to check if minimal version is high enough to delete code that
needed for backward compatibility. --HG-- branch : develop
This commit is contained in:
parent
a78a516ce9
commit
a2acb032a2
|
@ -32,6 +32,7 @@
|
|||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../ifc/xml/vtoolrecord.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../ifc/xml/vpatternconverter.h"
|
||||
|
||||
class VDataTool;
|
||||
class VMainGraphicsScene;
|
||||
|
@ -171,12 +172,16 @@ private:
|
|||
void ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
||||
|
||||
// TODO. Delete if minimal supported version is 0.2.7
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 2, 7),
|
||||
"Time to refactor the code.");
|
||||
void ParseOldToolSpline(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
||||
|
||||
void ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
||||
void ParseToolCubicBezier(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
||||
|
||||
// TODO. Delete if minimal supported version is 0.2.7
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 2, 7),
|
||||
"Time to refactor the code.");
|
||||
void ParseOldToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
||||
|
||||
void ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include "vdomdocument.h"
|
||||
|
||||
#define CONVERTER_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
|
||||
|
||||
class VAbstractConverter :public VDomDocument
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VAbstractConverter)
|
||||
|
|
|
@ -46,6 +46,9 @@ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
|
|||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.2");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.2.xsd");
|
||||
|
||||
constexpr int VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
constexpr int VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPatternConverter::VPatternConverter(const QString &fileName)
|
||||
:VAbstractConverter(fileName)
|
||||
|
@ -57,30 +60,6 @@ VPatternConverter::VPatternConverter(const QString &fileName)
|
|||
VPatternConverter::~VPatternConverter()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VPatternConverter::MinVer() const
|
||||
{
|
||||
return GetVersion(PatternMinVerStr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VPatternConverter::MaxVer() const
|
||||
{
|
||||
return GetVersion(PatternMaxVerStr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPatternConverter::MinVerStr() const
|
||||
{
|
||||
return PatternMinVerStr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPatternConverter::MaxVerStr() const
|
||||
{
|
||||
return PatternMaxVerStr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPatternConverter::XSDSchema(int ver) const
|
||||
{
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
|
||||
static const QString PatternMaxVerStr;
|
||||
static const QString CurrentSchema;
|
||||
static constexpr int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
|
||||
static constexpr int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 2);
|
||||
|
||||
protected:
|
||||
virtual int MinVer() const Q_DECL_OVERRIDE;
|
||||
|
@ -105,4 +107,28 @@ private:
|
|||
static QMap<QString, QString> OldNamesToNewNames_InV0_2_1();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline int VPatternConverter::MinVer() const
|
||||
{
|
||||
return PatternMinVer;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline int VPatternConverter::MaxVer() const
|
||||
{
|
||||
return PatternMaxVer;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline QString VPatternConverter::MinVerStr() const
|
||||
{
|
||||
return PatternMinVerStr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline QString VPatternConverter::MaxVerStr() const
|
||||
{
|
||||
return PatternMaxVerStr;
|
||||
}
|
||||
|
||||
#endif // VPATTERNCONVERTER_H
|
||||
|
|
|
@ -43,6 +43,9 @@ const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0");
|
|||
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.3.3");
|
||||
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.3.3.xsd");
|
||||
|
||||
constexpr int VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
constexpr int VVITConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VVITConverter::VVITConverter(const QString &fileName)
|
||||
:VAbstractMConverter(fileName)
|
||||
|
@ -54,30 +57,6 @@ VVITConverter::VVITConverter(const QString &fileName)
|
|||
VVITConverter::~VVITConverter()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VVITConverter::MinVer() const
|
||||
{
|
||||
return GetVersion(MeasurementMinVerStr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VVITConverter::MaxVer() const
|
||||
{
|
||||
return GetVersion(MeasurementMaxVerStr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VVITConverter::MinVerStr() const
|
||||
{
|
||||
return MeasurementMinVerStr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VVITConverter::MaxVerStr() const
|
||||
{
|
||||
return MeasurementMaxVerStr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VVITConverter::XSDSchema(int ver) const
|
||||
{
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
|
||||
static const QString MeasurementMaxVerStr;
|
||||
static const QString CurrentSchema;
|
||||
static constexpr int MeasurementMinVer = CONVERTER_VERSION_CHECK(0, 2, 0);
|
||||
static constexpr int MeasurementMaxVer = CONVERTER_VERSION_CHECK(0, 3, 3);
|
||||
|
||||
protected:
|
||||
virtual int MinVer() const Q_DECL_OVERRIDE;
|
||||
|
@ -70,4 +72,28 @@ private:
|
|||
void ToV0_3_3();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline int VVITConverter::MinVer() const
|
||||
{
|
||||
return MeasurementMinVer;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline int VVITConverter::MaxVer() const
|
||||
{
|
||||
return MeasurementMaxVer;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline QString VVITConverter::MinVerStr() const
|
||||
{
|
||||
return MeasurementMinVerStr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline QString VVITConverter::MaxVerStr() const
|
||||
{
|
||||
return MeasurementMaxVerStr;
|
||||
}
|
||||
|
||||
#endif // VVITCONVERTER_H
|
||||
|
|
|
@ -43,6 +43,9 @@ const QString VVSTConverter::MeasurementMinVerStr = QStringLiteral("0.3.0");
|
|||
const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.4.2");
|
||||
const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/standard_measurements/v0.4.2.xsd");
|
||||
|
||||
constexpr int VVSTConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
constexpr int VVSTConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VVSTConverter::VVSTConverter(const QString &fileName)
|
||||
:VAbstractMConverter(fileName)
|
||||
|
@ -54,30 +57,6 @@ VVSTConverter::VVSTConverter(const QString &fileName)
|
|||
VVSTConverter::~VVSTConverter()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VVSTConverter::MinVer() const
|
||||
{
|
||||
return GetVersion(MeasurementMinVerStr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VVSTConverter::MaxVer() const
|
||||
{
|
||||
return GetVersion(MeasurementMaxVerStr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VVSTConverter::MinVerStr() const
|
||||
{
|
||||
return MeasurementMinVerStr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VVSTConverter::MaxVerStr() const
|
||||
{
|
||||
return MeasurementMaxVerStr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VVSTConverter::XSDSchema(int ver) const
|
||||
{
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
|
||||
static const QString MeasurementMaxVerStr;
|
||||
static const QString CurrentSchema;
|
||||
static constexpr int MeasurementMinVer = CONVERTER_VERSION_CHECK(0, 3, 0);
|
||||
static constexpr int MeasurementMaxVer = CONVERTER_VERSION_CHECK(0, 4, 2);
|
||||
|
||||
protected:
|
||||
virtual int MinVer() const Q_DECL_OVERRIDE;
|
||||
|
@ -68,4 +70,28 @@ private:
|
|||
void ToV0_4_2();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline int VVSTConverter::MinVer() const
|
||||
{
|
||||
return MeasurementMinVer;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline int VVSTConverter::MaxVer() const
|
||||
{
|
||||
return MeasurementMaxVer;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline QString VVSTConverter::MinVerStr() const
|
||||
{
|
||||
return MeasurementMinVerStr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline QString VVSTConverter::MaxVerStr() const
|
||||
{
|
||||
return MeasurementMaxVerStr;
|
||||
}
|
||||
|
||||
#endif // VMEASUREMENTCONVERTER_H
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "../../vgeometry/varc.h"
|
||||
#include "../../vgeometry/vsplinepath.h"
|
||||
#include "../dialogs/tools/dialoguniondetails.h"
|
||||
#include "../ifc/xml/vpatternconverter.h"
|
||||
|
||||
#include <QUndoStack>
|
||||
|
||||
|
@ -649,6 +650,8 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
|
|||
// Remove it if min version is 0.3.2
|
||||
// Instead:
|
||||
// UpdatePoints(data, d1.RemoveEdge(indexD1), i, children);
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 3, 2),
|
||||
"Time to refactor the code.");
|
||||
if (children.size() != countNodeD2)
|
||||
{
|
||||
UpdatePoints(data, d1.RemoveEdge(indexD1), i, children);
|
||||
|
@ -671,6 +674,8 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
|
|||
} while (pointsD2 < countNodeD2-1);
|
||||
// This check need for backward compatibility
|
||||
// Remove it if min version is 0.3.2
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 3, 2),
|
||||
"Time to refactor the code.");
|
||||
if (children.size() == countNodeD2)
|
||||
{
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue
Block a user