Implicit Sharing for class VIncrement.

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-20 19:31:15 +03:00
parent 327705da44
commit 8f274990e0
4 changed files with 88 additions and 27 deletions

View File

@ -25,4 +25,5 @@ HEADERS += \
container/vlinelength.h \
container/vsplinelength.h \
container/vinternalvariable_p.h \
container/vvariable_p.h
container/vvariable_p.h \
container/vincrement_p.h

View File

@ -27,6 +27,7 @@
*************************************************************************/
#include "vincrement.h"
#include "vincrement_p.h"
#include "../options.h"
//---------------------------------------------------------------------------------------------------------------------
@ -34,7 +35,7 @@
* @brief VIncrement create enpty increment
*/
VIncrement::VIncrement()
:VVariable(), id(NULL_ID)
:VVariable(), d(new VIncrementData)
{
SetType(VarType::Increment);
}
@ -50,14 +51,14 @@ VIncrement::VIncrement()
* @param description description of increment
*/
VIncrement::VIncrement(const QString &name, quint32 id, qreal base, qreal ksize, qreal kheight, QString description)
:VVariable(name, base, ksize, kheight, description), id(id)
:VVariable(name, base, ksize, kheight, description), d(new VIncrementData(id))
{
SetType(VarType::Increment);
}
//---------------------------------------------------------------------------------------------------------------------
VIncrement::VIncrement(const VIncrement &incr)
:VVariable(incr), id(incr.getId())
:VVariable(incr), d(incr.d)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -68,10 +69,30 @@ VIncrement &VIncrement::operator=(const VIncrement &incr)
return *this;
}
VVariable::operator=(incr);
this->id = incr.getId();
d = incr.d;
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VIncrement::~VIncrement()
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getId return id of row
* @return id
*/
quint32 VIncrement::getId() const
{
return d->id;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setId set id of row
* @param value id
*/
void VIncrement::setId(const quint32 &value)
{
d->id = value;
}

View File

@ -31,6 +31,8 @@
#include "vvariable.h"
class VIncrementData;
/**
* @brief The VIncrement class keep data row of increment table
*/
@ -47,28 +49,7 @@ public:
quint32 getId() const;
void setId(const quint32 &value);
private:
/** @brief id each increment have unique identificator */
quint32 id;
QSharedDataPointer<VIncrementData> d;
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getId return id of row
* @return id
*/
inline quint32 VIncrement::getId() const
{
return id;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setId set id of row
* @param value id
*/
inline void VIncrement::setId(const quint32 &value)
{
id = value;
}
#endif // VINCREMENTTABLEROW_H

View File

@ -0,0 +1,58 @@
/************************************************************************
**
** @file vincrement_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 VINCREMENT_P_H
#define VINCREMENT_P_H
#include <QSharedData>
#include "../options.h"
class VIncrementData : public QSharedData
{
public:
VIncrementData()
:id(NULL_ID)
{}
VIncrementData(quint32 id)
:id(id)
{}
VIncrementData(const VIncrementData &incr)
:QSharedData(incr), id(incr.id)
{}
virtual ~VIncrementData() {}
/** @brief id each increment have unique identificator */
quint32 id;
};
#endif // VINCREMENT_P_H