Refactoring.
Code style.
This commit is contained in:
parent
914a2c9d09
commit
8b29cd6b36
|
@ -29,26 +29,26 @@
|
|||
#ifndef VCONTAINER_H
|
||||
#define VCONTAINER_H
|
||||
|
||||
#include <qcompilerdetection.h>
|
||||
#include <QCoreApplication>
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QMessageLogger>
|
||||
#include <QSet>
|
||||
#include <QSharedPointer>
|
||||
#include <QSharedData>
|
||||
#include <QSharedDataPointer>
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QTypeInfo>
|
||||
#include <QtGlobal>
|
||||
#include <new>
|
||||
#include <qcompilerdetection.h>
|
||||
|
||||
#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<quint32, QSharedPointer<VGObject> >()),
|
||||
modelingObjects(QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>>::create()),
|
||||
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()),
|
||||
pieces(QSharedPointer<QHash<quint32, VPiece>>::create()),
|
||||
piecePaths(QSharedPointer<QHash<quint32, VPiecePath>>::create()),
|
||||
trVars(trVars),
|
||||
patternUnit(patternUnit),
|
||||
nspace(nspace)
|
||||
{}
|
||||
: calculationObjects(QHash<quint32, QSharedPointer<VGObject>>()),
|
||||
modelingObjects(QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>>::create()),
|
||||
variables(QHash<QString, QSharedPointer<VInternalVariable>>()),
|
||||
pieces(QSharedPointer<QHash<quint32, VPiece>>::create()),
|
||||
piecePaths(QSharedPointer<QHash<quint32, VPiecePath>>::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<quint32, QSharedPointer<VGObject> > calculationObjects;
|
||||
QHash<quint32, QSharedPointer<VGObject>> calculationObjects;
|
||||
QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>> 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 <typename T> auto GetVariable(const QString &name) const -> QSharedPointer<T>;
|
||||
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<VGObject> &obj) const;
|
||||
void RegisterUniqueName(VGObject *obj) const;
|
||||
void RegisterUniqueName(const QSharedPointer<VGObject> &obj) const;
|
||||
|
||||
auto AddGObject(VGObject *obj) -> quint32;
|
||||
auto AddGObject(const QSharedPointer<VGObject> &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<VAbstractCurve> &arc, const quint32 &id,
|
||||
const 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,
|
||||
quint32 parentId = NULL_ID);
|
||||
void AddLine(const quint32 &firstPointId, const quint32 &secondPointId);
|
||||
void AddArc(const QSharedPointer<VAbstractCurve> &arc, const quint32 &id, const 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,
|
||||
quint32 parentId = NULL_ID);
|
||||
|
||||
template <typename T>
|
||||
void AddUniqueVariable(T *var);
|
||||
template <typename T>
|
||||
void AddUniqueVariable(const QSharedPointer<T> &var);
|
||||
template <typename T>
|
||||
void AddVariable(T *var);
|
||||
template <typename T>
|
||||
void AddVariable(const QSharedPointer<T> &var);
|
||||
void RemoveVariable(const QString& name);
|
||||
void RemovePiece(quint32 id);
|
||||
template <typename T> void AddUniqueVariable(T *var);
|
||||
template <typename T> void AddUniqueVariable(const QSharedPointer<T> &var);
|
||||
template <typename T> void AddVariable(T *var);
|
||||
template <typename T> void AddVariable(const QSharedPointer<T> &var);
|
||||
void RemoveVariable(const QString &name);
|
||||
void RemovePiece(quint32 id);
|
||||
|
||||
template <class T>
|
||||
void UpdateGObject(quint32 id, T* obj);
|
||||
template <class T>
|
||||
void UpdateGObject(quint32 id, const QSharedPointer<T> &obj);
|
||||
void UpdatePiece(quint32 id, const VPiece &detail);
|
||||
void UpdatePiecePath(quint32 id, const VPiecePath &path);
|
||||
template <class T> void UpdateGObject(quint32 id, T *obj);
|
||||
template <class T> void UpdateGObject(quint32 id, const QSharedPointer<T> &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<VarType> &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<VarType> &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 <class T> auto qHash(const QSharedPointer<T> &p) -> uint;
|
||||
|
||||
template <typename T>
|
||||
void UpdateObject(const quint32 &id, const QSharedPointer<T> &point);
|
||||
template <typename T> void UpdateObject(const quint32 &id, const QSharedPointer<T> &point);
|
||||
|
||||
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
|
||||
|
||||
/*
|
||||
* 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>
|
||||
|
@ -287,16 +282,15 @@ template <typename T> 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 <typename T> auto VContainer::GetVariable(const QString &name) const -> QSharedPointer<T>
|
||||
{
|
||||
SCASSERT(name.isEmpty()==false)
|
||||
SCASSERT(name.isEmpty() == false)
|
||||
if (d->variables.contains(name))
|
||||
{
|
||||
try
|
||||
|
@ -317,15 +311,13 @@ template <typename T> auto VContainer::GetVariable(const QString &name) const ->
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VContainer::AddUniqueVariable(T *var)
|
||||
template <typename T> void VContainer::AddUniqueVariable(T *var)
|
||||
{
|
||||
AddUniqueVariable(QSharedPointer<T>(var));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VContainer::AddUniqueVariable(const QSharedPointer<T> &var)
|
||||
template <typename T> void VContainer::AddUniqueVariable(const QSharedPointer<T> &var)
|
||||
{
|
||||
AddVariable(var);
|
||||
|
||||
|
@ -336,15 +328,13 @@ void VContainer::AddUniqueVariable(const QSharedPointer<T> &var)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VContainer::AddVariable(T *var)
|
||||
template <typename T> void VContainer::AddVariable(T *var)
|
||||
{
|
||||
AddVariable(QSharedPointer<T>(var));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VContainer::AddVariable(const QSharedPointer<T> &var)
|
||||
template <typename T> void VContainer::AddVariable(const QSharedPointer<T> &var)
|
||||
{
|
||||
SCASSERT(not var->GetName().isEmpty())
|
||||
AddVariable(var, var->GetName());
|
||||
|
@ -356,8 +346,7 @@ void VContainer::AddVariable(const QSharedPointer<T> &var)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VContainer::AddVariable(const QSharedPointer<T> &var, const QString &name)
|
||||
template <typename T> void VContainer::AddVariable(const QSharedPointer<T> &var, const QString &name)
|
||||
{
|
||||
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
|
||||
{
|
||||
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 obj object
|
||||
*/
|
||||
template <class T>
|
||||
void VContainer::UpdateGObject(quint32 id, T* obj)
|
||||
template <class T> void VContainer::UpdateGObject(quint32 id, T *obj)
|
||||
{
|
||||
SCASSERT(obj != nullptr)
|
||||
UpdateGObject(id, QSharedPointer<T>(obj));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
void VContainer::UpdateGObject(quint32 id, const QSharedPointer<T> &obj)
|
||||
template <class T> void VContainer::UpdateGObject(quint32 id, const QSharedPointer<T> &obj)
|
||||
{
|
||||
SCASSERT(not obj.isNull())
|
||||
UpdateObject(id, obj);
|
||||
|
@ -420,8 +407,7 @@ void VContainer::UpdateGObject(quint32 id, const QSharedPointer<T> &obj)
|
|||
* @param id id of existing object
|
||||
* @param point object
|
||||
*/
|
||||
template <typename T>
|
||||
void VContainer::UpdateObject(const quint32 &id, const QSharedPointer<T> &point)
|
||||
template <typename T> void VContainer::UpdateObject(const quint32 &id, const QSharedPointer<T> &point)
|
||||
{
|
||||
Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712
|
||||
SCASSERT(point.isNull() == false)
|
||||
|
|
Loading…
Reference in New Issue
Block a user