Refactoring.
Code style.
This commit is contained in:
parent
914a2c9d09
commit
8b29cd6b36
|
@ -29,26 +29,26 @@
|
||||||
#ifndef VCONTAINER_H
|
#ifndef VCONTAINER_H
|
||||||
#define VCONTAINER_H
|
#define VCONTAINER_H
|
||||||
|
|
||||||
#include <qcompilerdetection.h>
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMessageLogger>
|
#include <QMessageLogger>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QSharedData>
|
#include <QSharedData>
|
||||||
#include <QSharedDataPointer>
|
#include <QSharedDataPointer>
|
||||||
|
#include <QSharedPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTypeInfo>
|
#include <QTypeInfo>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <qcompilerdetection.h>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
|
||||||
#include "../ifc/exception/vexceptionbadid.h"
|
#include "../ifc/exception/vexceptionbadid.h"
|
||||||
#include "../vgeometry/vabstractcubicbezierpath.h"
|
#include "../vgeometry/vabstractcubicbezierpath.h"
|
||||||
#include "../vgeometry/vabstractcurve.h"
|
#include "../vgeometry/vabstractcurve.h"
|
||||||
#include "../vgeometry/vgobject.h"
|
#include "../vgeometry/vgobject.h"
|
||||||
|
#include "../vmisc/def.h"
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
|
@ -76,17 +76,17 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
||||||
class VContainerData final : public QSharedData //-V690
|
class VContainerData final : public QSharedData //-V690
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VContainerData(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace)
|
VContainerData(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace)
|
||||||
: calculationObjects(QHash<quint32, QSharedPointer<VGObject> >()),
|
: calculationObjects(QHash<quint32, QSharedPointer<VGObject>>()),
|
||||||
modelingObjects(QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>>::create()),
|
modelingObjects(QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>>::create()),
|
||||||
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()),
|
variables(QHash<QString, QSharedPointer<VInternalVariable>>()),
|
||||||
pieces(QSharedPointer<QHash<quint32, VPiece>>::create()),
|
pieces(QSharedPointer<QHash<quint32, VPiece>>::create()),
|
||||||
piecePaths(QSharedPointer<QHash<quint32, VPiecePath>>::create()),
|
piecePaths(QSharedPointer<QHash<quint32, VPiecePath>>::create()),
|
||||||
trVars(trVars),
|
trVars(trVars),
|
||||||
patternUnit(patternUnit),
|
patternUnit(patternUnit),
|
||||||
nspace(nspace)
|
nspace(nspace)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
VContainerData(const VContainerData &data)
|
VContainerData(const VContainerData &data)
|
||||||
: QSharedData(data),
|
: QSharedData(data),
|
||||||
|
@ -98,11 +98,12 @@ public:
|
||||||
trVars(data.trVars),
|
trVars(data.trVars),
|
||||||
patternUnit(data.patternUnit),
|
patternUnit(data.patternUnit),
|
||||||
nspace(data.nspace)
|
nspace(data.nspace)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~VContainerData();
|
virtual ~VContainerData();
|
||||||
|
|
||||||
QHash<quint32, QSharedPointer<VGObject> > calculationObjects;
|
QHash<quint32, QSharedPointer<VGObject>> calculationObjects;
|
||||||
QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>> modelingObjects;
|
QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>> modelingObjects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,6 +132,7 @@ QT_WARNING_POP
|
||||||
class VContainer
|
class VContainer
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(VContainer) // NOLINT
|
Q_DECLARE_TR_FUNCTIONS(VContainer) // NOLINT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VContainer(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace);
|
VContainer(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace);
|
||||||
VContainer(const VContainer &data);
|
VContainer(const VContainer &data);
|
||||||
|
@ -141,7 +143,8 @@ public:
|
||||||
auto operator=(const VContainer &data) -> VContainer &;
|
auto operator=(const VContainer &data) -> VContainer &;
|
||||||
#ifdef Q_COMPILER_RVALUE_REFS
|
#ifdef Q_COMPILER_RVALUE_REFS
|
||||||
VContainer(VContainer &&data) Q_DECL_NOTHROW;
|
VContainer(VContainer &&data) Q_DECL_NOTHROW;
|
||||||
auto operator=(VContainer &&data) Q_DECL_NOTHROW->VContainer &;
|
auto operator=(VContainer &&data) Q_DECL_NOTHROW
|
||||||
|
->VContainer &;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static auto UniqueNamespace() -> QString;
|
static auto UniqueNamespace() -> QString;
|
||||||
|
@ -166,27 +169,20 @@ public:
|
||||||
auto AddPiece(const VPiece &detail) -> quint32;
|
auto AddPiece(const VPiece &detail) -> quint32;
|
||||||
auto AddPiecePath(const VPiecePath &path) -> quint32;
|
auto AddPiecePath(const VPiecePath &path) -> quint32;
|
||||||
void AddLine(const quint32 &firstPointId, const quint32 &secondPointId);
|
void AddLine(const quint32 &firstPointId, const quint32 &secondPointId);
|
||||||
void AddArc(const QSharedPointer<VAbstractCurve> &arc, const quint32 &id,
|
void AddArc(const QSharedPointer<VAbstractCurve> &arc, const quint32 &id, const quint32 &parentId = NULL_ID);
|
||||||
const quint32 &parentId = NULL_ID);
|
|
||||||
void AddSpline(const QSharedPointer<VAbstractBezier> &curve, quint32 id, quint32 parentId = NULL_ID);
|
void AddSpline(const QSharedPointer<VAbstractBezier> &curve, quint32 id, quint32 parentId = NULL_ID);
|
||||||
void AddCurveWithSegments(const QSharedPointer<VAbstractCubicBezierPath> &curve, const quint32 &id,
|
void AddCurveWithSegments(const QSharedPointer<VAbstractCubicBezierPath> &curve, const quint32 &id,
|
||||||
quint32 parentId = NULL_ID);
|
quint32 parentId = NULL_ID);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> void AddUniqueVariable(T *var);
|
||||||
void AddUniqueVariable(T *var);
|
template <typename T> void AddUniqueVariable(const QSharedPointer<T> &var);
|
||||||
template <typename T>
|
template <typename T> void AddVariable(T *var);
|
||||||
void AddUniqueVariable(const QSharedPointer<T> &var);
|
template <typename T> void AddVariable(const QSharedPointer<T> &var);
|
||||||
template <typename T>
|
void RemoveVariable(const QString &name);
|
||||||
void AddVariable(T *var);
|
|
||||||
template <typename T>
|
|
||||||
void AddVariable(const QSharedPointer<T> &var);
|
|
||||||
void RemoveVariable(const QString& name);
|
|
||||||
void RemovePiece(quint32 id);
|
void RemovePiece(quint32 id);
|
||||||
|
|
||||||
template <class T>
|
template <class T> void UpdateGObject(quint32 id, T *obj);
|
||||||
void UpdateGObject(quint32 id, T* obj);
|
template <class T> void UpdateGObject(quint32 id, const QSharedPointer<T> &obj);
|
||||||
template <class T>
|
|
||||||
void UpdateGObject(quint32 id, const QSharedPointer<T> &obj);
|
|
||||||
void UpdatePiece(quint32 id, const VPiece &detail);
|
void UpdatePiece(quint32 id, const VPiece &detail);
|
||||||
void UpdatePiecePath(quint32 id, const VPiecePath &path);
|
void UpdatePiecePath(quint32 id, const VPiecePath &path);
|
||||||
|
|
||||||
|
@ -200,7 +196,7 @@ public:
|
||||||
void ClearUniqueIncrementNames() const;
|
void ClearUniqueIncrementNames() const;
|
||||||
void ClearExceptUniqueIncrementNames() const;
|
void ClearExceptUniqueIncrementNames() const;
|
||||||
|
|
||||||
void RemoveIncrement(const QString& name);
|
void RemoveIncrement(const QString &name);
|
||||||
|
|
||||||
void FillPiecesAreas(Unit unit);
|
void FillPiecesAreas(Unit unit);
|
||||||
|
|
||||||
|
@ -246,8 +242,7 @@ private:
|
||||||
|
|
||||||
template <class T> auto qHash(const QSharedPointer<T> &p) -> uint;
|
template <class T> auto qHash(const QSharedPointer<T> &p) -> uint;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> void UpdateObject(const quint32 &id, const QSharedPointer<T> &point);
|
||||||
void UpdateObject(const quint32 &id, const QSharedPointer<T> &point);
|
|
||||||
|
|
||||||
template <typename T> auto DataVar(const VarType &type) const -> const QMap<QString, QSharedPointer<T>>;
|
template <typename T> auto DataVar(const VarType &type) const -> const QMap<QString, QSharedPointer<T>>;
|
||||||
|
|
||||||
|
@ -257,8 +252,8 @@ private:
|
||||||
Q_DECLARE_TYPEINFO(VContainer, Q_MOVABLE_TYPE); // NOLINT
|
Q_DECLARE_TYPEINFO(VContainer, Q_MOVABLE_TYPE); // NOLINT
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defintion of templated member functions of VContainer
|
* Defintion of templated member functions of VContainer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> auto VContainer::GeometricObject(const quint32 &id) const -> const QSharedPointer<T>
|
template <typename T> auto VContainer::GeometricObject(const quint32 &id) const -> const QSharedPointer<T>
|
||||||
|
@ -287,16 +282,15 @@ template <typename T> auto VContainer::GeometricObject(const quint32 &id) const
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief GetVariable return varible by name
|
* @brief GetVariable return varible by name
|
||||||
* @param name variable's name
|
* @param name variable's name
|
||||||
* @return variable
|
* @return variable
|
||||||
*/
|
*/
|
||||||
template <typename T> auto VContainer::GetVariable(const QString &name) const -> QSharedPointer<T>
|
template <typename T> auto VContainer::GetVariable(const QString &name) const -> QSharedPointer<T>
|
||||||
{
|
{
|
||||||
SCASSERT(name.isEmpty()==false)
|
SCASSERT(name.isEmpty() == false)
|
||||||
if (d->variables.contains(name))
|
if (d->variables.contains(name))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -317,15 +311,13 @@ template <typename T> auto VContainer::GetVariable(const QString &name) const ->
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T> void VContainer::AddUniqueVariable(T *var)
|
||||||
void VContainer::AddUniqueVariable(T *var)
|
|
||||||
{
|
{
|
||||||
AddUniqueVariable(QSharedPointer<T>(var));
|
AddUniqueVariable(QSharedPointer<T>(var));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T> void VContainer::AddUniqueVariable(const QSharedPointer<T> &var)
|
||||||
void VContainer::AddUniqueVariable(const QSharedPointer<T> &var)
|
|
||||||
{
|
{
|
||||||
AddVariable(var);
|
AddVariable(var);
|
||||||
|
|
||||||
|
@ -336,15 +328,13 @@ void VContainer::AddUniqueVariable(const QSharedPointer<T> &var)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T> void VContainer::AddVariable(T *var)
|
||||||
void VContainer::AddVariable(T *var)
|
|
||||||
{
|
{
|
||||||
AddVariable(QSharedPointer<T>(var));
|
AddVariable(QSharedPointer<T>(var));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T> void VContainer::AddVariable(const QSharedPointer<T> &var)
|
||||||
void VContainer::AddVariable(const QSharedPointer<T> &var)
|
|
||||||
{
|
{
|
||||||
SCASSERT(not var->GetName().isEmpty())
|
SCASSERT(not var->GetName().isEmpty())
|
||||||
AddVariable(var, var->GetName());
|
AddVariable(var, var->GetName());
|
||||||
|
@ -356,8 +346,7 @@ void VContainer::AddVariable(const QSharedPointer<T> &var)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T> void VContainer::AddVariable(const QSharedPointer<T> &var, const QString &name)
|
||||||
void VContainer::AddVariable(const QSharedPointer<T> &var, const QString &name)
|
|
||||||
{
|
{
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -389,7 +378,7 @@ void VContainer::AddVariable(const QSharedPointer<T> &var, const QString &name)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class T> auto VContainer::qHash(const QSharedPointer<T> &p) -> uint
|
template <class T> auto VContainer::qHash(const QSharedPointer<T> &p) -> uint
|
||||||
{
|
{
|
||||||
return qHash( p.data() );
|
return qHash(p.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -398,16 +387,14 @@ template <class T> auto VContainer::qHash(const QSharedPointer<T> &p) -> uint
|
||||||
* @param id id of existing GObject
|
* @param id id of existing GObject
|
||||||
* @param obj object
|
* @param obj object
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T> void VContainer::UpdateGObject(quint32 id, T *obj)
|
||||||
void VContainer::UpdateGObject(quint32 id, T* obj)
|
|
||||||
{
|
{
|
||||||
SCASSERT(obj != nullptr)
|
SCASSERT(obj != nullptr)
|
||||||
UpdateGObject(id, QSharedPointer<T>(obj));
|
UpdateGObject(id, QSharedPointer<T>(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class T>
|
template <class T> void VContainer::UpdateGObject(quint32 id, const QSharedPointer<T> &obj)
|
||||||
void VContainer::UpdateGObject(quint32 id, const QSharedPointer<T> &obj)
|
|
||||||
{
|
{
|
||||||
SCASSERT(not obj.isNull())
|
SCASSERT(not obj.isNull())
|
||||||
UpdateObject(id, obj);
|
UpdateObject(id, obj);
|
||||||
|
@ -420,8 +407,7 @@ void VContainer::UpdateGObject(quint32 id, const QSharedPointer<T> &obj)
|
||||||
* @param id id of existing object
|
* @param id id of existing object
|
||||||
* @param point object
|
* @param point object
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T> void VContainer::UpdateObject(const quint32 &id, const QSharedPointer<T> &point)
|
||||||
void VContainer::UpdateObject(const quint32 &id, const QSharedPointer<T> &point)
|
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712
|
Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712
|
||||||
SCASSERT(point.isNull() == false)
|
SCASSERT(point.isNull() == false)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user