2016-01-15 14:58:39 +01:00
|
|
|
/****************************************************************************
|
2015-08-16 13:11:15 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 Jochen Becher
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-08-16 13:11:15 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2015-08-16 13:11:15 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2015-08-16 13:11:15 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "dclonevisitor.h"
|
|
|
|
|
|
|
|
|
|
#include "qmt/diagram/delement.h"
|
|
|
|
|
#include "qmt/diagram/dobject.h"
|
|
|
|
|
#include "qmt/diagram/dpackage.h"
|
|
|
|
|
#include "qmt/diagram/dclass.h"
|
|
|
|
|
#include "qmt/diagram/dcomponent.h"
|
|
|
|
|
#include "qmt/diagram/ddiagram.h"
|
|
|
|
|
#include "qmt/diagram/ditem.h"
|
|
|
|
|
#include "qmt/diagram/drelation.h"
|
|
|
|
|
#include "qmt/diagram/dinheritance.h"
|
|
|
|
|
#include "qmt/diagram/ddependency.h"
|
|
|
|
|
#include "qmt/diagram/dassociation.h"
|
2016-08-23 21:47:12 +02:00
|
|
|
#include "qmt/diagram/dconnection.h"
|
2015-08-16 13:11:15 +02:00
|
|
|
#include "qmt/diagram/dannotation.h"
|
|
|
|
|
#include "qmt/diagram/dboundary.h"
|
|
|
|
|
#include "qmt/infrastructure/qmtassert.h"
|
|
|
|
|
|
|
|
|
|
namespace qmt {
|
|
|
|
|
|
|
|
|
|
DCloneVisitor::DCloneVisitor()
|
2015-11-03 22:30:46 +01:00
|
|
|
: m_cloned(0)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDElement(const DElement *element)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(element);
|
2015-11-03 22:30:46 +01:00
|
|
|
QMT_CHECK(m_cloned);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDObject(const DObject *object)
|
|
|
|
|
{
|
2015-11-03 22:30:46 +01:00
|
|
|
QMT_CHECK(m_cloned);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDElement(object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDPackage(const DPackage *package)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DPackage(*package);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDObject(package);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDClass(const DClass *klass)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DClass(*klass);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDObject(klass);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDComponent(const DComponent *component)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DComponent(*component);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDObject(component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDDiagram(const DDiagram *diagram)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DDiagram(*diagram);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDObject(diagram);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDItem(const DItem *item)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DItem(*item);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDObject(item);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDRelation(const DRelation *relation)
|
|
|
|
|
{
|
2015-11-03 22:30:46 +01:00
|
|
|
QMT_CHECK(m_cloned);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDElement(relation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDInheritance(const DInheritance *inheritance)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DInheritance(*inheritance);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDRelation(inheritance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDDependency(const DDependency *dependency)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DDependency(*dependency);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDRelation(dependency);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDAssociation(const DAssociation *association)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DAssociation(*association);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDRelation(association);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-23 21:47:12 +02:00
|
|
|
void DCloneVisitor::visitDConnection(const DConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
if (!m_cloned)
|
|
|
|
|
m_cloned = new DConnection(*connection);
|
|
|
|
|
visitDRelation(connection);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-16 13:11:15 +02:00
|
|
|
void DCloneVisitor::visitDAnnotation(const DAnnotation *annotation)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DAnnotation(*annotation);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDElement(annotation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneVisitor::visitDBoundary(const DBoundary *boundary)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DBoundary(*boundary);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDElement(boundary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DCloneDeepVisitor::DCloneDeepVisitor()
|
2015-11-03 22:30:46 +01:00
|
|
|
: m_cloned(0)
|
2015-08-16 13:11:15 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDElement(const DElement *element)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(element);
|
2015-11-03 22:30:46 +01:00
|
|
|
QMT_CHECK(m_cloned);
|
2015-08-16 13:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDObject(const DObject *object)
|
|
|
|
|
{
|
2015-11-03 22:30:46 +01:00
|
|
|
QMT_CHECK(m_cloned);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDElement(object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDPackage(const DPackage *package)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DPackage(*package);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDObject(package);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDClass(const DClass *klass)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DClass(*klass);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDObject(klass);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDComponent(const DComponent *component)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DComponent(*component);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDObject(component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDDiagram(const DDiagram *diagram)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DDiagram(*diagram);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDObject(diagram);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDItem(const DItem *item)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DItem(*item);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDObject(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDRelation(const DRelation *relation)
|
|
|
|
|
{
|
2015-11-03 22:30:46 +01:00
|
|
|
QMT_CHECK(m_cloned);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDElement(relation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDInheritance(const DInheritance *inheritance)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DInheritance(*inheritance);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDRelation(inheritance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDDependency(const DDependency *dependency)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DDependency(*dependency);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDRelation(dependency);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDAssociation(const DAssociation *association)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DAssociation(*association);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDRelation(association);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-23 21:47:12 +02:00
|
|
|
void DCloneDeepVisitor::visitDConnection(const DConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
if (!m_cloned)
|
|
|
|
|
m_cloned = new DConnection(*connection);
|
|
|
|
|
visitDRelation(connection);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-16 13:11:15 +02:00
|
|
|
void DCloneDeepVisitor::visitDAnnotation(const DAnnotation *annotation)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DAnnotation(*annotation);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDElement(annotation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DCloneDeepVisitor::visitDBoundary(const DBoundary *boundary)
|
|
|
|
|
{
|
2015-11-14 16:59:30 +01:00
|
|
|
if (!m_cloned)
|
2015-11-03 22:30:46 +01:00
|
|
|
m_cloned = new DBoundary(*boundary);
|
2015-08-16 13:11:15 +02:00
|
|
|
visitDElement(boundary);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-14 16:59:30 +01:00
|
|
|
} // namespace qmt
|