Implicit Sharing for class VCurveLength.
--HG-- branch : develop
This commit is contained in:
parent
8f274990e0
commit
a16402f747
|
@ -26,4 +26,5 @@ HEADERS += \
|
||||||
container/vsplinelength.h \
|
container/vsplinelength.h \
|
||||||
container/vinternalvariable_p.h \
|
container/vinternalvariable_p.h \
|
||||||
container/vvariable_p.h \
|
container/vvariable_p.h \
|
||||||
container/vincrement_p.h
|
container/vincrement_p.h \
|
||||||
|
container/vcurvelength_p.h
|
||||||
|
|
|
@ -27,19 +27,20 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vcurvelength.h"
|
#include "vcurvelength.h"
|
||||||
|
#include "vcurvelength_p.h"
|
||||||
#include "../widgets/vapplication.h"
|
#include "../widgets/vapplication.h"
|
||||||
#include "../geometry/vabstractcurve.h"
|
#include "../geometry/vabstractcurve.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VCurveLength::VCurveLength()
|
VCurveLength::VCurveLength()
|
||||||
:VInternalVariable(), id(NULL_ID), parentId(NULL_ID)
|
:VInternalVariable(), d(new VCurveLengthData)
|
||||||
{
|
{
|
||||||
SetType(VarType::Unknown);
|
SetType(VarType::Unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve)
|
VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve)
|
||||||
:VInternalVariable(), id(id), parentId(parentId)
|
:VInternalVariable(), d(new VCurveLengthData(id, parentId))
|
||||||
{
|
{
|
||||||
SetType(VarType::Unknown);
|
SetType(VarType::Unknown);
|
||||||
SCASSERT(curve != nullptr);
|
SCASSERT(curve != nullptr);
|
||||||
|
@ -49,7 +50,7 @@ VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAb
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VCurveLength::VCurveLength(const VCurveLength &var)
|
VCurveLength::VCurveLength(const VCurveLength &var)
|
||||||
:VInternalVariable(var), id(var.GetId()), parentId(var.GetParentId())
|
:VInternalVariable(var), d(var.d)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -60,8 +61,7 @@ VCurveLength &VCurveLength::operator=(const VCurveLength &var)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
VInternalVariable::operator=(var);
|
VInternalVariable::operator=(var);
|
||||||
this->id = var.GetId();
|
d = var.d;
|
||||||
this->parentId = var.GetParentId();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,12 +72,36 @@ VCurveLength::~VCurveLength()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VCurveLength::Filter(quint32 id)
|
bool VCurveLength::Filter(quint32 id)
|
||||||
{
|
{
|
||||||
if (parentId != 0)//Do not check if value zero
|
if (d->parentId != 0)//Do not check if value zero
|
||||||
{// Not all curves have parents. Only those who was created after cutting the parent curve.
|
{// Not all curves have parents. Only those who was created after cutting the parent curve.
|
||||||
return this->id == id || parentId == id;
|
return d->id == id || d->parentId == id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return this->id == id;
|
return d->id == id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
quint32 VCurveLength::GetId() const
|
||||||
|
{
|
||||||
|
return d->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VCurveLength::SetId(const quint32 &id)
|
||||||
|
{
|
||||||
|
d->id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
quint32 VCurveLength::GetParentId() const
|
||||||
|
{
|
||||||
|
return d->parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VCurveLength::SetParentId(const quint32 &value)
|
||||||
|
{
|
||||||
|
d->parentId = value;
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "vinternalvariable.h"
|
#include "vinternalvariable.h"
|
||||||
|
|
||||||
class VAbstractCurve;
|
class VAbstractCurve;
|
||||||
|
class VCurveLengthData;
|
||||||
|
|
||||||
class VCurveLength : public VInternalVariable
|
class VCurveLength : public VInternalVariable
|
||||||
{
|
{
|
||||||
|
@ -43,23 +44,14 @@ public:
|
||||||
virtual ~VCurveLength();
|
virtual ~VCurveLength();
|
||||||
|
|
||||||
virtual bool Filter(quint32 id);
|
virtual bool Filter(quint32 id);
|
||||||
|
|
||||||
quint32 GetId() const;
|
quint32 GetId() const;
|
||||||
|
void SetId(const quint32 &id);
|
||||||
|
|
||||||
quint32 GetParentId() const;
|
quint32 GetParentId() const;
|
||||||
protected:
|
void SetParentId(const quint32 &value);
|
||||||
quint32 id;
|
private:
|
||||||
quint32 parentId;
|
QSharedDataPointer<VCurveLengthData> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline quint32 VCurveLength::GetId() const
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline quint32 VCurveLength::GetParentId() const
|
|
||||||
{
|
|
||||||
return parentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // VCURVELENGTH_H
|
#endif // VCURVELENGTH_H
|
||||||
|
|
58
src/app/container/vcurvelength_p.h
Normal file
58
src/app/container/vcurvelength_p.h
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vcurvelength_p.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 20 8, 2014
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentine project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2014 Valentina project
|
||||||
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef VCURVELENGTH_P_H
|
||||||
|
#define VCURVELENGTH_P_H
|
||||||
|
|
||||||
|
#include <QSharedData>
|
||||||
|
#include "../options.h"
|
||||||
|
|
||||||
|
class VCurveLengthData : public QSharedData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
VCurveLengthData()
|
||||||
|
:id(NULL_ID), parentId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
VCurveLengthData(const quint32 &id, const quint32 &parentId)
|
||||||
|
:id(id), parentId(parentId)
|
||||||
|
{}
|
||||||
|
|
||||||
|
VCurveLengthData(const VCurveLengthData &var)
|
||||||
|
:QSharedData(var), id(var.id), parentId(var.parentId)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual ~VCurveLengthData() {}
|
||||||
|
|
||||||
|
quint32 id;
|
||||||
|
quint32 parentId;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // VCURVELENGTH_P_H
|
|
@ -43,8 +43,8 @@ VSplineLength::VSplineLength(const quint32 &id, const quint32 &parentId, const Q
|
||||||
SetType(VarType::SplineLength);
|
SetType(VarType::SplineLength);
|
||||||
SetName(name);
|
SetName(name);
|
||||||
SetValue(value);
|
SetValue(value);
|
||||||
this->id = id;
|
SetId(id);
|
||||||
this->parentId = parentId;
|
SetParentId(parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user