From 8b29cd6b36f3f17dee15b146afb4a9f1680419d4 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 24 Jun 2023 09:33:01 +0300 Subject: [PATCH] Refactoring. Code style. --- src/libs/vpatterndb/vcontainer.h | 162 ++++++++++++++----------------- 1 file changed, 74 insertions(+), 88 deletions(-) diff --git a/src/libs/vpatterndb/vcontainer.h b/src/libs/vpatterndb/vcontainer.h index fba0a9c89..2d99d1e22 100644 --- a/src/libs/vpatterndb/vcontainer.h +++ b/src/libs/vpatterndb/vcontainer.h @@ -29,26 +29,26 @@ #ifndef VCONTAINER_H #define VCONTAINER_H -#include #include #include #include #include #include -#include #include #include +#include #include #include #include #include #include +#include -#include "../vmisc/def.h" #include "../ifc/exception/vexceptionbadid.h" #include "../vgeometry/vabstractcubicbezierpath.h" #include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vgobject.h" +#include "../vmisc/def.h" #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #include "../vmisc/diagnostic.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) @@ -76,33 +76,34 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") class VContainerData final : public QSharedData //-V690 { public: - VContainerData(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace) - : calculationObjects(QHash >()), - modelingObjects(QSharedPointer>>::create()), - variables(QHash > ()), - pieces(QSharedPointer>::create()), - piecePaths(QSharedPointer>::create()), - trVars(trVars), - patternUnit(patternUnit), - nspace(nspace) - {} + : calculationObjects(QHash>()), + modelingObjects(QSharedPointer>>::create()), + variables(QHash>()), + pieces(QSharedPointer>::create()), + piecePaths(QSharedPointer>::create()), + trVars(trVars), + patternUnit(patternUnit), + nspace(nspace) + { + } VContainerData(const VContainerData &data) - : QSharedData(data), - calculationObjects(data.calculationObjects), - modelingObjects(data.modelingObjects), - variables(data.variables), - pieces(data.pieces), - piecePaths(data.piecePaths), - trVars(data.trVars), - patternUnit(data.patternUnit), - nspace(data.nspace) - {} + : QSharedData(data), + calculationObjects(data.calculationObjects), + modelingObjects(data.modelingObjects), + variables(data.variables), + pieces(data.pieces), + piecePaths(data.piecePaths), + trVars(data.trVars), + patternUnit(data.patternUnit), + nspace(data.nspace) + { + } virtual ~VContainerData(); - QHash > calculationObjects; + QHash> calculationObjects; QSharedPointer>> modelingObjects; /** @@ -131,6 +132,7 @@ QT_WARNING_POP class VContainer { Q_DECLARE_TR_FUNCTIONS(VContainer) // NOLINT + public: VContainer(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace); VContainer(const VContainer &data); @@ -141,7 +143,8 @@ public: auto operator=(const VContainer &data) -> VContainer &; #ifdef Q_COMPILER_RVALUE_REFS VContainer(VContainer &&data) Q_DECL_NOTHROW; - auto operator=(VContainer &&data) Q_DECL_NOTHROW->VContainer &; + auto operator=(VContainer &&data) Q_DECL_NOTHROW + ->VContainer &; #endif static auto UniqueNamespace() -> QString; @@ -155,52 +158,45 @@ public: template auto GetVariable(const QString &name) const -> QSharedPointer; auto getId() const -> quint32; auto getNextId() const -> quint32; - void UpdateId(quint32 newId) const; - static void UpdateId(quint32 newId, const QString &nspace); + void UpdateId(quint32 newId) const; + static void UpdateId(quint32 newId, const QString &nspace); - void RegisterUniqueName(VGObject *obj) const; - void RegisterUniqueName(const QSharedPointer &obj) const; + void RegisterUniqueName(VGObject *obj) const; + void RegisterUniqueName(const QSharedPointer &obj) const; auto AddGObject(VGObject *obj) -> quint32; auto AddGObject(const QSharedPointer &obj) -> quint32; auto AddPiece(const VPiece &detail) -> quint32; auto AddPiecePath(const VPiecePath &path) -> quint32; - void AddLine(const quint32 &firstPointId, const quint32 &secondPointId); - void AddArc(const QSharedPointer &arc, const quint32 &id, - const quint32 &parentId = NULL_ID); - void AddSpline(const QSharedPointer &curve, quint32 id, quint32 parentId = NULL_ID); - void AddCurveWithSegments(const QSharedPointer &curve, const quint32 &id, - quint32 parentId = NULL_ID); + void AddLine(const quint32 &firstPointId, const quint32 &secondPointId); + void AddArc(const QSharedPointer &arc, const quint32 &id, const quint32 &parentId = NULL_ID); + void AddSpline(const QSharedPointer &curve, quint32 id, quint32 parentId = NULL_ID); + void AddCurveWithSegments(const QSharedPointer &curve, const quint32 &id, + quint32 parentId = NULL_ID); - template - void AddUniqueVariable(T *var); - template - void AddUniqueVariable(const QSharedPointer &var); - template - void AddVariable(T *var); - template - void AddVariable(const QSharedPointer &var); - void RemoveVariable(const QString& name); - void RemovePiece(quint32 id); + template void AddUniqueVariable(T *var); + template void AddUniqueVariable(const QSharedPointer &var); + template void AddVariable(T *var); + template void AddVariable(const QSharedPointer &var); + void RemoveVariable(const QString &name); + void RemovePiece(quint32 id); - template - void UpdateGObject(quint32 id, T* obj); - template - void UpdateGObject(quint32 id, const QSharedPointer &obj); - void UpdatePiece(quint32 id, const VPiece &detail); - void UpdatePiecePath(quint32 id, const VPiecePath &path); + template void UpdateGObject(quint32 id, T *obj); + template void UpdateGObject(quint32 id, const QSharedPointer &obj); + void UpdatePiece(quint32 id, const VPiece &detail); + void UpdatePiecePath(quint32 id, const VPiecePath &path); - void Clear(); - void ClearForFullParse(); - void ClearGObjects(); - void ClearCalculationGObjects(); - void ClearVariables(const VarType &type = VarType::Unknown); - void ClearVariables(const QVector &types); - void ClearUniqueNames() const; - void ClearUniqueIncrementNames() const; - void ClearExceptUniqueIncrementNames() const; + void Clear(); + void ClearForFullParse(); + void ClearGObjects(); + void ClearCalculationGObjects(); + void ClearVariables(const VarType &type = VarType::Unknown); + void ClearVariables(const QVector &types); + void ClearUniqueNames() const; + void ClearUniqueIncrementNames() const; + void ClearExceptUniqueIncrementNames() const; - void RemoveIncrement(const QString& name); + void RemoveIncrement(const QString &name); void FillPiecesAreas(Unit unit); @@ -246,8 +242,7 @@ private: template auto qHash(const QSharedPointer &p) -> uint; - template - void UpdateObject(const quint32 &id, const QSharedPointer &point); + template void UpdateObject(const quint32 &id, const QSharedPointer &point); template auto DataVar(const VarType &type) const -> const QMap>; @@ -257,8 +252,8 @@ private: Q_DECLARE_TYPEINFO(VContainer, Q_MOVABLE_TYPE); // NOLINT /* -* Defintion of templated member functions of VContainer -*/ + * Defintion of templated member functions of VContainer + */ //--------------------------------------------------------------------------------------------------------------------- template auto VContainer::GeometricObject(const quint32 &id) const -> const QSharedPointer @@ -287,16 +282,15 @@ template auto VContainer::GeometricObject(const quint32 &id) const return obj; } - //--------------------------------------------------------------------------------------------------------------------- /** -* @brief GetVariable return varible by name -* @param name variable's name -* @return variable -*/ + * @brief GetVariable return varible by name + * @param name variable's name + * @return variable + */ template auto VContainer::GetVariable(const QString &name) const -> QSharedPointer { - SCASSERT(name.isEmpty()==false) + SCASSERT(name.isEmpty() == false) if (d->variables.contains(name)) { try @@ -317,15 +311,13 @@ template auto VContainer::GetVariable(const QString &name) const -> } //--------------------------------------------------------------------------------------------------------------------- -template -void VContainer::AddUniqueVariable(T *var) +template void VContainer::AddUniqueVariable(T *var) { AddUniqueVariable(QSharedPointer(var)); } //--------------------------------------------------------------------------------------------------------------------- -template -void VContainer::AddUniqueVariable(const QSharedPointer &var) +template void VContainer::AddUniqueVariable(const QSharedPointer &var) { AddVariable(var); @@ -336,15 +328,13 @@ void VContainer::AddUniqueVariable(const QSharedPointer &var) } //--------------------------------------------------------------------------------------------------------------------- -template -void VContainer::AddVariable(T *var) +template void VContainer::AddVariable(T *var) { AddVariable(QSharedPointer(var)); } //--------------------------------------------------------------------------------------------------------------------- -template -void VContainer::AddVariable(const QSharedPointer &var) +template void VContainer::AddVariable(const QSharedPointer &var) { SCASSERT(not var->GetName().isEmpty()) AddVariable(var, var->GetName()); @@ -356,8 +346,7 @@ void VContainer::AddVariable(const QSharedPointer &var) } //--------------------------------------------------------------------------------------------------------------------- -template -void VContainer::AddVariable(const QSharedPointer &var, const QString &name) +template void VContainer::AddVariable(const QSharedPointer &var, const QString &name) { if (name.isEmpty()) { @@ -389,7 +378,7 @@ void VContainer::AddVariable(const QSharedPointer &var, const QString &name) //--------------------------------------------------------------------------------------------------------------------- template auto VContainer::qHash(const QSharedPointer &p) -> uint { - return qHash( p.data() ); + return qHash(p.data()); } //--------------------------------------------------------------------------------------------------------------------- @@ -398,16 +387,14 @@ template auto VContainer::qHash(const QSharedPointer &p) -> uint * @param id id of existing GObject * @param obj object */ -template -void VContainer::UpdateGObject(quint32 id, T* obj) +template void VContainer::UpdateGObject(quint32 id, T *obj) { SCASSERT(obj != nullptr) UpdateGObject(id, QSharedPointer(obj)); } //--------------------------------------------------------------------------------------------------------------------- -template -void VContainer::UpdateGObject(quint32 id, const QSharedPointer &obj) +template void VContainer::UpdateGObject(quint32 id, const QSharedPointer &obj) { SCASSERT(not obj.isNull()) UpdateObject(id, obj); @@ -420,8 +407,7 @@ void VContainer::UpdateGObject(quint32 id, const QSharedPointer &obj) * @param id id of existing object * @param point object */ -template -void VContainer::UpdateObject(const quint32 &id, const QSharedPointer &point) +template void VContainer::UpdateObject(const quint32 &id, const QSharedPointer &point) { Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712 SCASSERT(point.isNull() == false)