aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/modelinglib/qmt/diagram_controller/dfactory.cpp
blob: 1d6a770b773cc101a912ca0747502498c66728cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/****************************************************************************
**
** Copyright (C) 2016 Jochen Becher
** Contact: https://www.qt.io/licensing/
**
** 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
** 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.
**
** 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.
**
****************************************************************************/

#include "dfactory.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"
#include "qmt/diagram/dconnection.h"

#include "qmt/model/melement.h"
#include "qmt/model/mobject.h"
#include "qmt/model/mclass.h"
#include "qmt/model/mcomponent.h"
#include "qmt/model/mpackage.h"
#include "qmt/model/mdiagram.h"
#include "qmt/model/mcanvasdiagram.h"
#include "qmt/model/mitem.h"
#include "qmt/model/mrelation.h"
#include "qmt/model/massociation.h"
#include "qmt/model/mdependency.h"
#include "qmt/model/minheritance.h"

namespace qmt {

DFactory::DFactory()
{
}

void DFactory::visitMElement(const MElement *element)
{
    Q_UNUSED(element)
    QMT_CHECK(m_product);
}

void DFactory::visitMObject(const MObject *object)
{
    auto diagramObject = dynamic_cast<DObject *>(m_product);
    QMT_ASSERT(diagramObject, return);
    diagramObject->setModelUid(object->uid());
    visitMElement(object);
}

void DFactory::visitMPackage(const MPackage *package)
{
    QMT_CHECK(!m_product);
    auto diagramPackage = new DPackage();
    m_product = diagramPackage;
    visitMObject(package);
}

void DFactory::visitMClass(const MClass *klass)
{
    QMT_CHECK(!m_product);
    auto diagramKlass = new DClass();
    m_product = diagramKlass;
    visitMObject(klass);
}

void DFactory::visitMComponent(const MComponent *component)
{
    QMT_CHECK(!m_product);
    auto diagramComponent = new DComponent();
    m_product = diagramComponent;
    visitMObject(component);
}

void DFactory::visitMDiagram(const MDiagram *diagram)
{
    QMT_CHECK(!m_product);
    auto diagramDiagram = new DDiagram();
    m_product = diagramDiagram;
    visitMObject(diagram);
}

void DFactory::visitMCanvasDiagram(const MCanvasDiagram *diagram)
{
    QMT_CHECK(!m_product);
    visitMDiagram(diagram);
}

void DFactory::visitMItem(const MItem *item)
{
    QMT_CHECK(!m_product);
    auto diagramItem = new DItem();
    m_product = diagramItem;
    visitMObject(item);
}

void DFactory::visitMRelation(const MRelation *relation)
{
    auto diagramRelation = dynamic_cast<DRelation *>(m_product);
    QMT_ASSERT(diagramRelation, return);
    diagramRelation->setModelUid(relation->uid());
    visitMElement(relation);
}

void DFactory::visitMDependency(const MDependency *dependency)
{
    QMT_CHECK(!m_product);
    auto diagramDependency = new DDependency();
    m_product = diagramDependency;
    visitMRelation(dependency);
}

void DFactory::visitMInheritance(const MInheritance *inheritance)
{
    QMT_CHECK(!m_product);
    auto diagramInheritance = new DInheritance();
    m_product = diagramInheritance;
    visitMRelation(inheritance);
}

void DFactory::visitMAssociation(const MAssociation *association)
{
    QMT_CHECK(!m_product);
    auto diagramAssociation = new DAssociation();
    m_product = diagramAssociation;
    visitMRelation(association);
}

void DFactory::visitMConnection(const MConnection *connection)
{
    QMT_CHECK(!m_product);
    auto diagramConnection = new DConnection();
    m_product = diagramConnection;
    visitMRelation(connection);
}

} // namespace qmt