From bae337cbeb3c5c391a35f201a3bb0f7640afc588 Mon Sep 17 00:00:00 2001 From: Luis Paulo Torres de Oliveira Date: Wed, 13 Aug 2014 04:07:06 -0300 Subject: Add GCC-XML Backend Plugin, ACDC Plugin and UML Notation Plugin Change-Id: Ib562f00477748322c06e9dd0999a988816e6e419 Reviewed-by: Sandro S. Andrade --- .../duse-mt/src/libs/duseinterfaces/iplugin.cpp | 5 + .../uml/duse-mt/src/libs/duseinterfaces/iplugin.h | 6 + .../acdcarchitecturerecoveryalgorithm.json | 8 + .../acdcarchitecturerecoveryalgorithm.pro | 24 ++ ...carchitecturerecoveryalgorithm_dependencies.pri | 4 + .../acdcarchitecturerecoveryalgorithm_export.h | 53 ++++ .../acdcarchitecturerecoveryalgorithmplugin.cpp | 100 ++++++ .../acdcarchitecturerecoveryalgorithmplugin.h | 93 ++++++ .../dependencyrelationstreemanager.cpp | 117 +++++++ .../dependencyrelationstreemanager.h | 65 ++++ .../subgraphdominatorpattern.cpp | 173 ++++++++++ .../subgraphdominatorpattern.h | 70 ++++ .../architecturerecoverycore.pro | 4 + .../architecturerecoverycoreplugin.cpp | 33 +- .../architecturerecoverycoreplugin.h | 17 + .../iarchitecturerecoveryalgorithm.h | 2 +- .../iarchitecturerecoverybackend.h | 3 +- .../architecturerecoverypanel.cpp | 107 +++++++ .../architecturerecoverypanel.h | 90 ++++++ .../architecturerecoverypanel.json | 12 + .../architecturerecoverypanel.pro | 22 ++ .../architecturerecoverypanel.ui | 117 +++++++ .../architecturerecoverypanel_dependencies.pri | 7 + .../architecturerecoverypanelplugin.cpp | 66 ++++ .../architecturerecoverypanelplugin.h | 69 ++++ .../gccxmlarchitecturerecoverybackend.pro | 11 +- .../gccxmlarchitecturerecoverybackend_export.h | 53 ++++ .../gccxmlarchitecturerecoverybackendplugin.cpp | 351 +++++++++++---------- .../gccxmlarchitecturerecoverybackendplugin.h | 47 +-- .../xmlfilemanager.cpp | 92 ++++++ .../xmlfilemanager.h | 73 +++++ .../xmlfilereader.cpp | 150 +++++++++ .../xmlfilereader.h | 85 +++++ examples/uml/duse-mt/src/plugins/plugins.pro | 5 +- .../umlmodelingnotation/umlmodelingnotation.json | 8 + .../umlmodelingnotation/umlmodelingnotation.pro | 21 ++ .../umlmodelingnotation_dependencies.pri | 4 + .../umlmodelingnotation_export.h | 53 ++++ .../umlmodelingnotationplugin.cpp | 101 ++++++ .../umlmodelingnotationplugin.h | 77 +++++ 40 files changed, 2198 insertions(+), 200 deletions(-) create mode 100644 examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm.json create mode 100644 examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm.pro create mode 100644 examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm_dependencies.pri create mode 100644 examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm_export.h create mode 100644 examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithmplugin.cpp create mode 100644 examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithmplugin.h create mode 100644 examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/dependencyrelationstreemanager.cpp create mode 100644 examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/dependencyrelationstreemanager.h create mode 100644 examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/subgraphdominatorpattern.cpp create mode 100644 examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/subgraphdominatorpattern.h create mode 100644 examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.cpp create mode 100644 examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.h create mode 100644 examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.json create mode 100644 examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.pro create mode 100644 examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.ui create mode 100644 examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel_dependencies.pri create mode 100644 examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanelplugin.cpp create mode 100644 examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanelplugin.h create mode 100644 examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackend_export.h create mode 100644 examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilemanager.cpp create mode 100644 examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilemanager.h create mode 100644 examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilereader.cpp create mode 100644 examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilereader.h create mode 100644 examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation.json create mode 100644 examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation.pro create mode 100644 examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation_dependencies.pri create mode 100644 examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation_export.h create mode 100644 examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotationplugin.cpp create mode 100644 examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotationplugin.h (limited to 'examples/uml') diff --git a/examples/uml/duse-mt/src/libs/duseinterfaces/iplugin.cpp b/examples/uml/duse-mt/src/libs/duseinterfaces/iplugin.cpp index 2e0a0ebf..c5514646 100644 --- a/examples/uml/duse-mt/src/libs/duseinterfaces/iplugin.cpp +++ b/examples/uml/duse-mt/src/libs/duseinterfaces/iplugin.cpp @@ -52,5 +52,10 @@ IPlugin::~IPlugin() { } +QString IPlugin::name() +{ + return _name; +} + } diff --git a/examples/uml/duse-mt/src/libs/duseinterfaces/iplugin.h b/examples/uml/duse-mt/src/libs/duseinterfaces/iplugin.h index 136271e1..07c13739 100644 --- a/examples/uml/duse-mt/src/libs/duseinterfaces/iplugin.h +++ b/examples/uml/duse-mt/src/libs/duseinterfaces/iplugin.h @@ -46,6 +46,7 @@ #include "icore.h" #include +#include namespace DuSE { @@ -59,6 +60,11 @@ public: virtual ~IPlugin(); virtual bool initialize() = 0; + + virtual QString name(); + +protected: + QString _name; }; } diff --git a/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm.json b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm.json new file mode 100644 index 00000000..1952997f --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm.json @@ -0,0 +1,8 @@ +{ + "Category": "Architecture Recovery", + "Vendor": "Qt Project", + "Version": "1.0", + "DependencyList": [ + "ArchitectureRecoveryCorePlugin" + ] +} diff --git a/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm.pro b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm.pro new file mode 100644 index 00000000..f1964825 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm.pro @@ -0,0 +1,24 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2014-08-13T04:20:30 +# +#------------------------------------------------- + +include(../../duse-mt-plugin.pri) + +QT -= widgets gui + +DEFINES += ACDCARCHITECTURERECOVERYALGORITHM_LIBRARY + +HEADERS += \ + acdcarchitecturerecoveryalgorithm_export.h \ + acdcarchitecturerecoveryalgorithmplugin.h \ + dependencyrelationstreemanager.h \ + subgraphdominatorpattern.h + +SOURCES += \ + acdcarchitecturerecoveryalgorithmplugin.cpp \ + dependencyrelationstreemanager.cpp \ + subgraphdominatorpattern.cpp + +OTHER_FILES += acdcarchitecturerecoveryalgorithm.json diff --git a/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm_dependencies.pri b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm_dependencies.pri new file mode 100644 index 00000000..d7045bf4 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm_dependencies.pri @@ -0,0 +1,4 @@ +DUSEMT_PLUGIN_NAME = AcdcArchitectureRecoveryAlgorithm + +DUSEMT_PLUGIN_DEPENDS += \ + architecturerecoverycore diff --git a/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm_export.h b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm_export.h new file mode 100644 index 00000000..87d44411 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithm_export.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ACDCARCHITECTURERECOVERYALGORITHM_EXPORT_H +#define ACDCARCHITECTURERECOVERYALGORITHM_EXPORT_H + +#include + +#if defined(ACDCARCHITECTURERECOVERYALGORITHM_LIBRARY) +# define ACDCARCHITECTURERECOVERYALGORITHM_EXPORT Q_DECL_EXPORT +#else +# define ACDCARCHITECTURERECOVERYALGORITHM_EXPORT Q_DECL_IMPORT +#endif + +#endif // ACDCARCHITECTURERECOVERYALGORITHM_EXPORT_H diff --git a/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithmplugin.cpp b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithmplugin.cpp new file mode 100644 index 00000000..8a370d68 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithmplugin.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "acdcarchitecturerecoveryalgorithmplugin.h" + +#include + +namespace DuSE +{ + +AcdcArchitectureRecoveryAlgorithmPlugin::AcdcArchitectureRecoveryAlgorithmPlugin(QObject *parent) + : IPlugin(parent), _dependencyRelationsTreeManager(new DependencyRelationsTreeManager), + _subgraphDominatorPattern(new SubgraphDominatorPattern) +{ + _name = "ACDC"; +} + +bool AcdcArchitectureRecoveryAlgorithmPlugin::initialize() +{ + return true; +} + +void AcdcArchitectureRecoveryAlgorithmPlugin::run() +{ + _dependencyRelationsTreeManager->fillNodesTable(_nodesTable, _dependencyRelations); + _dependencyRelationsTreeManager->orderNodes(_nodesTable, _orderedNodes); + _subgraphDominatorPattern->executePattern(_orderedNodes, _dependencyRelations); + _subgraphs = _subgraphDominatorPattern->subgraphs(); + _orphanNodes = _subgraphDominatorPattern->orphanNodes(_subgraphs, _dependencyRelations); + _subgraphs.append(_orphanNodes); +} + +void AcdcArchitectureRecoveryAlgorithmPlugin::setDependencyRelations(QMultiMap m_dependencyRelations) +{ + _dependencyRelations = m_dependencyRelations; +} + +QList AcdcArchitectureRecoveryAlgorithmPlugin::subgraphs() +{ + return _subgraphs; +} + +void AcdcArchitectureRecoveryAlgorithmPlugin::setDevelopmentPlatform(IDevelopmentPlatform *m_developmentPlatform) +{ + _developmentPlatform = m_developmentPlatform; +} + +void AcdcArchitectureRecoveryAlgorithmPlugin::setModelingNotation(IModelingNotation *m_modelingNotation) +{ + _modelingNotation = m_modelingNotation; +} + +IDevelopmentPlatform *AcdcArchitectureRecoveryAlgorithmPlugin::developmentPlatform() +{ + return _developmentPlatform; +} + +IModelingNotation *AcdcArchitectureRecoveryAlgorithmPlugin::modelingNotation() +{ + return _modelingNotation; +} + +} diff --git a/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithmplugin.h b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithmplugin.h new file mode 100644 index 00000000..719485e7 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/acdcarchitecturerecoveryalgorithmplugin.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef ACDCARCHITECTURERECOVERYALGORITHMPLUGIN_H +#define ACDCARCHITECTURERECOVERYALGORITHMPLUGIN_H + +#include +#include + +#include +#include + +#include "dependencyrelationstreemanager.h" +#include "subgraphdominatorpattern.h" + +#include "acdcarchitecturerecoveryalgorithm_export.h" + +namespace DuSE +{ + +class ACDCARCHITECTURERECOVERYALGORITHM_EXPORT AcdcArchitectureRecoveryAlgorithmPlugin : public IPlugin, public IArchitectureRecoveryAlgorithm +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.liveblue.DuSE.IPlugin" FILE "acdcarchitecturerecoveryalgorithm.json") + +public: + AcdcArchitectureRecoveryAlgorithmPlugin(QObject *parent = 0); + + virtual bool initialize(); + + virtual void run(); + + void setDependencyRelations(QMultiMap m_dependencyRelations); + QList subgraphs(); + + virtual void setDevelopmentPlatform(IDevelopmentPlatform *m_developmentPlatform); + virtual void setModelingNotation(IModelingNotation *m_modelingNotation); + + virtual IDevelopmentPlatform* developmentPlatform(); + virtual IModelingNotation* modelingNotation(); + +private: + IDevelopmentPlatform *_developmentPlatform; + IModelingNotation *_modelingNotation; + QMultiMap _dependencyRelations; + DependencyRelationsTreeManager *_dependencyRelationsTreeManager; + QHash _nodesTable; + QStringList _orderedNodes; + SubgraphDominatorPattern *_subgraphDominatorPattern; + QList _subgraphs; + QStringList _orphanNodes; +}; + +} + +#endif // ACDCARCHITECTURERECOVERYALGORITHMPLUGIN_H diff --git a/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/dependencyrelationstreemanager.cpp b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/dependencyrelationstreemanager.cpp new file mode 100644 index 00000000..237ed055 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/dependencyrelationstreemanager.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "dependencyrelationstreemanager.h" + +namespace DuSE +{ + +DependencyRelationsTreeManager::DependencyRelationsTreeManager() +{ +} + +void DependencyRelationsTreeManager::fillNodesTable(QHash &nodesTable, const QMultiMap &dependencies) +{ + foreach (QString key, dependencies.uniqueKeys()) { + nodesTable.insert(key, dependencies.values(key).count()); + } + + foreach (QString value, dependencies.values()) { + if (!nodesTable.keys().contains(value)) { + nodesTable.insert(value, 0); + } + } +} + +void DependencyRelationsTreeManager::orderNodes(const QHash &nodesTable, QStringList &nodeList) +{ + int max = findMax(nodesTable); + + for (int i = 1; i <= max; ++i) { + foreach (QString node, nodesTable.keys()) { + int count = nodesTable.value(node); + + if (i == count) { + nodeList.append(node); + } + } + } +} + +int DependencyRelationsTreeManager::findMax(const QHash &nodesTable) +{ + int max = 0; + foreach (int count, nodesTable.values()) { + if (count > max) { + max = count; + } + } + + return max; +} + +QStringList DependencyRelationsTreeManager::targets(const QStringList &nodesList, const QMultiMap &dependencies) +{ + QStringList coveredNodes; + foreach (QString itemNode, nodesList) { + foreach (QString coveredNode, dependencies.values(itemNode)) { + if ((coveredNode != itemNode) && !coveredNodes.contains(coveredNode)) { + coveredNodes.append(coveredNode); + } + } + } + + return coveredNodes; +} + +QStringList DependencyRelationsTreeManager::sources(QString node, QMultiMap dependencies) +{ + QStringList sourceList; + + foreach (QString key, dependencies.keys()) { + if (dependencies.values(key).contains(node)) { + sourceList.append(key); + } + } + + return sourceList; +} + +} diff --git a/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/dependencyrelationstreemanager.h b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/dependencyrelationstreemanager.h new file mode 100644 index 00000000..c17faee6 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/dependencyrelationstreemanager.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef DEPENDENCYRELATIONSTREEMANAGER_H +#define DEPENDENCYRELATIONSTREEMANAGER_H + +#include +#include +#include + +namespace DuSE +{ + +class DependencyRelationsTreeManager +{ +public: + DependencyRelationsTreeManager(); + + void fillNodesTable(QHash &nodesTable, const QMultiMap &dependencies); + void orderNodes(const QHash &nodesTable, QStringList &nodeList); + int findMax(const QHash &nodesTable); + QStringList targets(const QStringList &nodesList, const QMultiMap &dependencies); + QStringList sources(QString node, QMultiMap dependencies); +}; + +} + +#endif // DEPENDENCYRELATIONSTREEMANAGER_H diff --git a/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/subgraphdominatorpattern.cpp b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/subgraphdominatorpattern.cpp new file mode 100644 index 00000000..17ebf6f9 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/subgraphdominatorpattern.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "subgraphdominatorpattern.h" + +namespace DuSE +{ + +SubgraphDominatorPattern::SubgraphDominatorPattern() +{ +} + +void SubgraphDominatorPattern::executePattern(const QStringList &orderedNodes, QMultiMap dependencies) +{ + // Para cada nó da lista de nós ordenados + foreach (QString node, orderedNodes) { + + // Chamar coveredSet + QStringList coveredNodes = coveredSet(node, dependencies); + + if (coveredNodes.contains(node) && (coveredNodes.count() == 1)) { + } else { + // Um Subgraph Dominator foi descoberto. Ele será adicionado na lista e será removido do Hash de dependências. + _subgraphs.append(coveredNodes); + } + } +} + +QStringList SubgraphDominatorPattern::coveredSet(QString node, QMultiMap dependencies) +{ + QStringList list; + QStringList covered; + + // Criar uma lista e colocar o nó lá dentro + list.append(node); + int currentListSize = 0; + int originalListSize = 0; + + do { + originalListSize = list.count(); + + // Guardar em covered os nós para os quais todos os nós da lista apontam, + // exceto os próprios nós (ou seja, não considera loops) da lista. + covered = _treeManager.targets(list, dependencies); + + // Cria uma lista falseOnes + QStringList falseOnes; + int currentCoveredSize = 0; + int originalCoveredSize = 0; + do { + originalCoveredSize = covered.count(); + + // Tirar uma cópia de covered e guardar em both + QStringList both = covered; + + // Adicionar a lista em both + foreach (QString itemNode, list) { + if (!both.contains(itemNode)) { + both.append(list); + } + } + + foreach (QString coveredNode, covered) { + bool nodeIsFalseOne = false; + QStringList sourceList = _treeManager.sources(coveredNode, dependencies); + foreach (QString source, sourceList) { + if (!both.contains(source)) { + nodeIsFalseOne = true; + break; + } + } + + if (nodeIsFalseOne == true) { + falseOnes.append(coveredNode); + } + } + + foreach (QString falseOne, falseOnes) { + covered.removeOne(falseOne); + } + currentCoveredSize = covered.count(); + } while (originalCoveredSize != currentCoveredSize); + + foreach (QString coveredNode, covered) { + if (!list.contains(coveredNode)) { + list.append(coveredNode); + } + } + currentListSize = list.count(); + } while (originalListSize != currentListSize); + + return list; +} + +QStringList SubgraphDominatorPattern::orphanNodes(const QList &subgraphs, QMultiMap dependencies) +{ + QStringList orphanContainer; + QStringList allNodes; + + foreach (QString dependent, dependencies.uniqueKeys()) { + if (!allNodes.contains(dependent)) { + allNodes.append(dependent); + } + foreach (QString dependency, dependencies.values(dependent)) { + if (!allNodes.contains(dependency)) { + allNodes.append(dependency); + } + } + } + + foreach (QString node, allNodes) { + bool nodeIsOrphan = true; + + foreach (QStringList subgraph, subgraphs) { + if (subgraph.contains(node)) { + nodeIsOrphan = false; + break; + } + } + + if (nodeIsOrphan == true) { + if (!orphanContainer.contains(node)) { + orphanContainer.append(node); + } + } + } + + return orphanContainer; +} + +QList SubgraphDominatorPattern::subgraphs() +{ + return _subgraphs; +} + +} diff --git a/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/subgraphdominatorpattern.h b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/subgraphdominatorpattern.h new file mode 100644 index 00000000..3f4d3ba3 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/acdcarchitecturerecoveryalgorithm/subgraphdominatorpattern.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef SUBGRAPHDOMINATORPATTERN_H +#define SUBGRAPHDOMINATORPATTERN_H + +#include +#include + +#include "dependencyrelationstreemanager.h" + +namespace DuSE +{ + +class SubgraphDominatorPattern +{ +public: + SubgraphDominatorPattern(); + + void executePattern(const QStringList &orderedNodes, QMultiMap dependencies); + QStringList coveredSet(QString node, QMultiMap dependencies); + QStringList orphanNodes(const QList &subgraphs, QMultiMap dependencies); + + QList subgraphs(); + +private: + QList _subgraphs; + DependencyRelationsTreeManager _treeManager; +}; + +} + +#endif // SUBGRAPHDOMINATORPATTERN_H diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycore.pro b/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycore.pro index 26b23ceb..3044c484 100644 --- a/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycore.pro +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycore.pro @@ -6,6 +6,8 @@ include(../../duse-mt-plugin.pri) +QT += gui widgets + HEADERS += architecturerecoverycoreplugin.h \ iarchitecturerecoverybackend.h \ imodelingnotation.h \ @@ -14,3 +16,5 @@ HEADERS += architecturerecoverycoreplugin.h \ SOURCES += architecturerecoverycoreplugin.cpp OTHER_FILES += architecturerecoverycore.json + +FORMS += diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycoreplugin.cpp b/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycoreplugin.cpp index 05d2abdb..3a2b420b 100644 --- a/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycoreplugin.cpp +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycoreplugin.cpp @@ -55,9 +55,40 @@ ArchitectureRecoveryCorePlugin::ArchitectureRecoveryCorePlugin(QObject *parent) bool ArchitectureRecoveryCorePlugin::initialize() { - qDebug() << ICore::self()->pluginController()->pluginsByType(); return true; } +void ArchitectureRecoveryCorePlugin::loadPluginsList() +{ +} + +void ArchitectureRecoveryCorePlugin::loadRecoveryBackends() +{ +} + +void ArchitectureRecoveryCorePlugin::loadRecoveryAlgorithms() +{ + +} + +void ArchitectureRecoveryCorePlugin::loadModelingNotations() +{ + +} + +QList ArchitectureRecoveryCorePlugin::recoveryBackends() +{ + return _recoveryBackends; } +QList ArchitectureRecoveryCorePlugin::recoveryAlgorithms() +{ + return _recoveryAlgorithms; +} + +QList ArchitectureRecoveryCorePlugin::modelingNotations() +{ + return _modelingNotations; +} + +} diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycoreplugin.h b/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycoreplugin.h index a83fa66f..df439048 100644 --- a/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycoreplugin.h +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverycore/architecturerecoverycoreplugin.h @@ -41,6 +41,9 @@ #ifndef ARCHITECTURERECOVERYCOREPLUGIN_H #define ARCHITECTURERECOVERYCOREPLUGIN_H +#include +#include +#include #include namespace DuSE @@ -55,6 +58,20 @@ public: ArchitectureRecoveryCorePlugin(QObject *parent = 0); virtual bool initialize(); + + void loadPluginsList(); + void loadRecoveryBackends(); + void loadRecoveryAlgorithms(); + void loadModelingNotations(); + QList recoveryBackends(); + QList recoveryAlgorithms(); + QList modelingNotations(); + +private: + QList _metaObjects; + QList _recoveryBackends; + QList _recoveryAlgorithms; + QList _modelingNotations; }; } diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverycore/iarchitecturerecoveryalgorithm.h b/examples/uml/duse-mt/src/plugins/architecturerecoverycore/iarchitecturerecoveryalgorithm.h index 9d69b125..71498f4a 100644 --- a/examples/uml/duse-mt/src/plugins/architecturerecoverycore/iarchitecturerecoveryalgorithm.h +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverycore/iarchitecturerecoveryalgorithm.h @@ -51,7 +51,7 @@ class IArchitectureRecoveryAlgorithm { public: - virtual void run() const = 0; + virtual void run() = 0; virtual void setDevelopmentPlatform(IDevelopmentPlatform *m_developmentPlatform) = 0; virtual void setModelingNotation(IModelingNotation *m_modelingNotation) = 0; diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverycore/iarchitecturerecoverybackend.h b/examples/uml/duse-mt/src/plugins/architecturerecoverycore/iarchitecturerecoverybackend.h index 9d7b2500..964c4de5 100644 --- a/examples/uml/duse-mt/src/plugins/architecturerecoverycore/iarchitecturerecoverybackend.h +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverycore/iarchitecturerecoverybackend.h @@ -42,13 +42,13 @@ #define IARCHITECTURERECOVERYBACKEND_H #include +#include namespace DuSE { class IArchitectureRecoveryBackend { - public: virtual QObjectList components() = 0; virtual QObjectList connectors() = 0; @@ -57,4 +57,3 @@ public: } #endif // IARCHITECTURERECOVERYBACKEND_H - diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.cpp b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.cpp new file mode 100644 index 00000000..457e03dd --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "architecturerecoverypanel.h" +#include "ui_architecturerecoverypanel.h" + +#include + +#include + +namespace DuSE +{ + +ArchitectureRecoveryPanel::ArchitectureRecoveryPanel(QWidget *parent) : + QDialog(parent), + ui(new Ui::ArchitectureRecoveryPanel) +{ + ui->setupUi(this); + + connect(ui->startPushButton, SIGNAL(clicked()), this, SLOT(run())); +} + +ArchitectureRecoveryPanel::~ArchitectureRecoveryPanel() +{ + delete ui; +} + +void ArchitectureRecoveryPanel::loadPanel() +{ + loadBackendPlugins(); + loadAlgorithmPlugins(); + loadNotationPlugins(); + show(); +} + +void ArchitectureRecoveryPanel::run() +{ + GccXmlArchitectureRecoveryBackendPlugin *gccXmlBackend = new GccXmlArchitectureRecoveryBackendPlugin; + AcdcArchitectureRecoveryAlgorithmPlugin *acdcAlgorithm = new AcdcArchitectureRecoveryAlgorithmPlugin; + UmlModelingNotationPlugin *umlNotation = new UmlModelingNotationPlugin; + + gccXmlBackend->run(); + DependencyRelations dependencyRelations = gccXmlBackend->components().at(0)->property("components").value(); + QString systemDirectory = gccXmlBackend->components().at(0)->property("systemDirectory").toString(); + + acdcAlgorithm->setDependencyRelations(dependencyRelations); + acdcAlgorithm->run(); + QList subgraphs = acdcAlgorithm->subgraphs(); + + umlNotation->setClusterList(subgraphs); + umlNotation->loadSubsystems(); + umlNotation->generateDiagram(systemDirectory); +} + +void ArchitectureRecoveryPanel::loadBackendPlugins() +{ + ui->backendComboBox->addItem("GCC-XML"); +} + +void ArchitectureRecoveryPanel::loadAlgorithmPlugins() +{ + ui->algorithmComboBox->addItem("ACDC (Algorithm for Compreehension-Driven Clustering)"); +} + +void ArchitectureRecoveryPanel::loadNotationPlugins() +{ + ui->notationComboBox->addItem("UML (Unified Modeling Language)"); +} + +} diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.h b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.h new file mode 100644 index 00000000..4d59cca2 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef ARCHITECTURERECOVERYPANEL_H +#define ARCHITECTURERECOVERYPANEL_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace DuSE +{ + +namespace Ui { + class ArchitectureRecoveryPanel; +} + +class ArchitectureRecoveryPanel : public QDialog +{ + Q_OBJECT + +public: + explicit ArchitectureRecoveryPanel(QWidget *parent = 0); + ~ArchitectureRecoveryPanel(); + + void loadBackendPlugins(); + void loadAlgorithmPlugins(); + void loadNotationPlugins(); + +public Q_SLOTS: + void loadPanel(); + void run(); + +private: + Ui::ArchitectureRecoveryPanel *ui; + QMap backendPluginsMap; + QMap algorithmPluginsMap; + QMap notationPluginsMap; + ArchitectureRecoveryCorePlugin *architectureRecoveryCore; +}; + +#endif // ARCHITECTURERECOVERYPANEL_H + +} + + diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.json b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.json new file mode 100644 index 00000000..3b9d9911 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.json @@ -0,0 +1,12 @@ +{ + "Category": "Architecture Recovery", + "Vendor": "Qt Project", + "Version": "1.0", + "DependencyList": [ + "ArchitectureRecoveryCorePlugin", + "GccXmlArchitectureRecoveryBackendPlugin", + "AcdcArchitectureRecoveryAlgorithmPlugin", + "UmlModelingNotationPlugin" + ] + +} diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.pro b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.pro new file mode 100644 index 00000000..f575d181 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.pro @@ -0,0 +1,22 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2013-11-03T17:38:51 +# +#------------------------------------------------- + +include(../../duse-mt-plugin.pri) + +QT += gui widgets modeling + +HEADERS += \ + architecturerecoverypanel.h \ + architecturerecoverypanelplugin.h + +SOURCES += \ + architecturerecoverypanel.cpp \ + architecturerecoverypanelplugin.cpp + +OTHER_FILES += architecturerecoverypanel.json + +FORMS += \ + architecturerecoverypanel.ui diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.ui b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.ui new file mode 100644 index 00000000..627a06f2 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel.ui @@ -0,0 +1,117 @@ + + + DuSE::ArchitectureRecoveryPanel + + + + 0 + 0 + 393 + 265 + + + + Dialog + + + + + 10 + 110 + 71 + 16 + + + + Algoritmo: + + + + + + 90 + 170 + 291 + 23 + + + + + + + 10 + 170 + 71 + 16 + + + + Notação: + + + + + + 10 + 10 + 381 + 16 + + + + Defina as etapas do processo de recuperação arquitetural: + + + true + + + + + + 279 + 220 + 101 + 23 + + + + Iniciar + + + + + + 10 + 50 + 71 + 16 + + + + Backend: + + + + + + 90 + 50 + 291 + 23 + + + + + + + 90 + 110 + 291 + 23 + + + + + + + diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel_dependencies.pri b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel_dependencies.pri new file mode 100644 index 00000000..40d209d3 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanel_dependencies.pri @@ -0,0 +1,7 @@ +DUSEMT_PLUGIN_NAME = ArchitectureRecoveryPanel + +DUSEMT_PLUGIN_DEPENDS += \ + architecturerecoverycore \ + gccxmlarchitecturerecoverybackend \ + acdcarchitecturerecoveryalgorithm \ + umlmodelingnotation diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanelplugin.cpp b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanelplugin.cpp new file mode 100644 index 00000000..9a8ee974 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanelplugin.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "architecturerecoverypanelplugin.h" + +#include +#include + +#include + +namespace DuSE +{ + +ArchitectureRecoveryPanelPlugin::ArchitectureRecoveryPanelPlugin(QObject *parent) + : IPlugin(parent), architectureRecoveryPanel(new ArchitectureRecoveryPanel) +{ +} + + +bool DuSE::ArchitectureRecoveryPanelPlugin::initialize() +{ + QAction *newArchitectureRecoveryProcessAction = new QAction(QIcon(), tr("New architecture recovery process"), this); + connect(newArchitectureRecoveryProcessAction, SIGNAL(triggered()), architectureRecoveryPanel, SLOT(loadPanel())); + ICore::self()->uiController()->addAction(newArchitectureRecoveryProcessAction, tr("menu_File")); + + return true; +} + +} diff --git a/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanelplugin.h b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanelplugin.h new file mode 100644 index 00000000..a865f28b --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/architecturerecoverypanel/architecturerecoverypanelplugin.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef ARCHITECTURERECOVERYPANELPLUGIN_H +#define ARCHITECTURERECOVERYPANELPLUGIN_H + +#include + +#include "architecturerecoverypanel.h" + +namespace DuSE +{ + +class ArchitectureRecoveryPanelPlugin : public IPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.liveblue.DuSE.IPlugin" FILE "architecturerecoverypanel.json") + +public: + ArchitectureRecoveryPanelPlugin(QObject *parent = 0); + + virtual bool initialize(); + + void run(); + +private: + ArchitectureRecoveryPanel *architectureRecoveryPanel; +}; + +} + +#endif // ARCHITECTURERECOVERYPANELPLUGIN_H diff --git a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackend.pro b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackend.pro index d4041016..9c4cf0ab 100644 --- a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackend.pro +++ b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackend.pro @@ -8,8 +8,15 @@ include(../../duse-mt-plugin.pri) QT += widgets gui -HEADERS += gccxmlarchitecturerecoverybackendplugin.h +DEFINES += GCCXMLARCHITECTURERECOVERYBACKEND_LIBRARY -SOURCES += gccxmlarchitecturerecoverybackendplugin.cpp +HEADERS += gccxmlarchitecturerecoverybackend_export.h \ + gccxmlarchitecturerecoverybackendplugin.h \ + xmlfilemanager.h \ + xmlfilereader.h + +SOURCES += gccxmlarchitecturerecoverybackendplugin.cpp \ + xmlfilemanager.cpp \ + xmlfilereader.cpp OTHER_FILES += gccxmlarchitecturerecoverybackend.json diff --git a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackend_export.h b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackend_export.h new file mode 100644 index 00000000..e96b5845 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackend_export.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GCCXMLARCHITECTURERECOVERYBACKEND_EXPORT_H +#define GCCXMLARCHITECTURERECOVERYBACKEND_EXPORT_H + +#include + +#if defined(GCCXMLARCHITECTURERECOVERYBACKEND_LIBRARY) +# define GCCXMLARCHITECTURERECOVERYBACKEND_EXPORT Q_DECL_EXPORT +#else +# define GCCXMLARCHITECTURERECOVERYBACKEND_EXPORT Q_DECL_IMPORT +#endif + +#endif // GCCXMLARCHITECTURERECOVERYBACKEND_EXPORT_H diff --git a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.cpp b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.cpp index e161b412..220bf417 100644 --- a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.cpp +++ b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.cpp @@ -42,7 +42,9 @@ #include #include +#include +#include #include #include @@ -54,244 +56,247 @@ namespace DuSE GccXmlArchitectureRecoveryBackendPlugin::GccXmlArchitectureRecoveryBackendPlugin(QObject *parent) : IPlugin(parent) { + _name = "C++ (GCC-XML)"; + qRegisterMetaType("DependencyRelations"); } bool GccXmlArchitectureRecoveryBackendPlugin::initialize() { - QAction *newArchitectureRecoveryProcessAction = new QAction(QIcon(), tr("New architecture recovery process"), this); - connect(newArchitectureRecoveryProcessAction, SIGNAL(triggered()), this, SLOT(newArchitectureRecoveryProcess())); - ICore::self()->uiController()->addAction(newArchitectureRecoveryProcessAction, tr("menu_File")); - qRegisterMetaType("ClassFunctions"); return true; } -void GccXmlArchitectureRecoveryBackendPlugin::setRootProjectDir(const QDir &rootProjectDir) -{ - _rootProjectDir = rootProjectDir; -} - -void GccXmlArchitectureRecoveryBackendPlugin::newArchitectureRecoveryProcess() -{ - QString directory = QFileDialog::getExistingDirectory(0, tr("Open code tree"), QDir::currentPath()); - _rootProjectDir = QDir(directory); - components(); -} QObjectList GccXmlArchitectureRecoveryBackendPlugin::components() { QObjectList components; - QStringList headers = _rootProjectDir.entryList(QStringList("*.h"), QDir::Files | QDir::NoSymLinks); - QStringList xmlFiles = generateXmlFiles(headers); - int xmlFilesSize = xmlFiles.size(); - for (int i = 0; i < xmlFilesSize; ++i) { - _xmlFileName = xmlFiles.at(i).toLocal8Bit().constData(); - - QObject *component = extractComponent(); - components.append(component); - } + QObject *componentsDependencyRelations = new QObject; + componentsDependencyRelations->setProperty("components", QVariant::fromValue(_dependencyRelations)); + componentsDependencyRelations->setProperty("systemDirectory", QVariant::fromValue(_rootProjectDirectoryString)); + components.append(componentsDependencyRelations); return components; } QObjectList GccXmlArchitectureRecoveryBackendPlugin::connectors() { - return QObjectList(); + QObjectList connectors; + + return connectors; } -QStringList GccXmlArchitectureRecoveryBackendPlugin::generateXmlFiles(const QStringList &codeFiles) const +void GccXmlArchitectureRecoveryBackendPlugin::run() { - int codeFilesSize = codeFiles.size(); - - for (int i = 0; i < codeFilesSize; ++i) { - QString file = codeFiles.at(i).toLocal8Bit().constData(); - QString fileDir = _rootProjectDir.absolutePath() + "/" + file; - QString xmlFileDir = _rootProjectDir.absolutePath() + "/" + file.replace(".h", ".xml"); - - QProcess process; - process.start("gccxml " + fileDir + " -fxml=" + xmlFileDir); - process.waitForFinished(); - } - - return _rootProjectDir.entryList(QStringList("*.xml"), QDir::Files | QDir::NoSymLinks); + runGccXml(); + recoverDependencyRelations(); } -bool GccXmlArchitectureRecoveryBackendPlugin::openXmlFile(const QString &filePath) +void GccXmlArchitectureRecoveryBackendPlugin::runGccXml() { - _xmlFile.setFileName(filePath); - _xmlReader = new QXmlStreamReader(&_xmlFile); + _rootProjectDirectoryString = QFileDialog::getExistingDirectory(0, "Escolha o diretório raíz do projeto", QDir::currentPath()); - if (!_xmlFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - return false; + if (_rootProjectDirectoryString.isEmpty()) { + QMessageBox errorMessage; + errorMessage.setInformativeText("Diretório inválido."); + errorMessage.show(); + } else { + _rootProjectDirectory = QDir(_rootProjectDirectoryString); + _xmlFilesList = _xmlFileManager->generateXmlFiles(_rootProjectDirectory); + _xmlCount = _xmlFilesList.count(); } - - return true; } -QStringList GccXmlArchitectureRecoveryBackendPlugin::findConstructorsFromXml() +void GccXmlArchitectureRecoveryBackendPlugin::recoverDependencyRelations() { - QStringList constructors; + QString fileName; - openXmlFile(_rootProjectDir.absolutePath() + "/" + _xmlFileName); - QString className = _xmlFileName; - className.replace(".xml", ""); - while (!_xmlReader->atEnd() && !_xmlReader->hasError()) { - QXmlStreamReader::TokenType token = _xmlReader->readNext(); + for (int i = 0; i < _xmlCount; ++i) { + fileName = _xmlFilesList.at(i).toLocal8Bit().constData(); - if (token == QXmlStreamReader::StartElement) { - if (_xmlReader->name() == "Constructor") { - QXmlStreamAttributes attributes = _xmlReader->attributes(); + _reader = new XmlFileReader(_rootProjectDirectory.absolutePath(), fileName); - QString attribute = attributes.value("demangled").toString(); - if (attribute.contains(className + "::", Qt::CaseInsensitive)) { - constructors.append(attribute); - } - } - } - } - if (_xmlFile.isOpen()) { - _xmlFile.close(); - } - - return constructors; -} + _reader->fillTagContainers(); -QObject *GccXmlArchitectureRecoveryBackendPlugin::extractComponent() -{ - QObject *component = new QObject; - QString className; - QStringList constructors = findConstructorsFromXml(); + _fileClasses.insert(fileName, _reader->fileClasses()); + _fileFields.insert(fileName, _reader->fileFields()); + _filePointers.insert(fileName, _reader->filePointers()); + _fileBases.insert(fileName, _reader->fileBases()); + _fileArguments.insert(fileName, _reader->fileArguments()); - if (!constructors.isEmpty()) { - QString expression = constructors.last(); - QStringList elements = expression.split("::"); - className = elements.at(0) + "::" + elements.at(1); + fieldAdjacencies(); + baseAdjacencies(); + argumentsAdjacencies(); - component->setObjectName(className); - } else { - className = _xmlFileName; - className.replace(".xml", ""); - component->setObjectName(className); + qDebug() << "Tamanho de dependencyRelations: " << _dependencyRelations.count(); } - - findFunctionsFromXml(component); - - return component; } -void GccXmlArchitectureRecoveryBackendPlugin::findFunctionsFromXml(QObject *component) +void GccXmlArchitectureRecoveryBackendPlugin::fieldAdjacencies() { - QHash > classFunctions; - - openXmlFile(_rootProjectDir.absolutePath() + "/" + _xmlFileName); - - QStringList expression = component->objectName().split("::"); - QString classNamespace = expression.first(); - - while (!_xmlReader->atEnd() && !_xmlReader->hasError()) { - QXmlStreamReader::TokenType token = _xmlReader->readNext(); - - if (token == QXmlStreamReader::StartElement) { - if ((_xmlReader->name() == "Method") || - (_xmlReader->name() == "Constructor") || - (_xmlReader->name() == "Destructor")) { - QString attribute = _xmlReader->attributes().value("demangled").toString(); + QString fileName; + + for (int i = 0; i < _xmlCount; ++i) { + + fileName = _xmlFilesList.at(i).toLocal8Bit().constData(); + + QMap classes = _fileClasses.value(fileName); + QList > fields = _fileFields.value(fileName); + QMap pointers = _filePointers.value(fileName); + + QString dependent; + QString dependency; + + QStringList classIds = classes.keys(); + foreach (QString classId, classIds) { + dependent = classes.value(classId); + for (int i = 0; i < fields.size(); ++i) { + QPair field = fields.at(i); + if (classId == field.first) { + if (classes.value(field.second).isEmpty()) { + QStringList pointersId = pointers.keys(); + foreach (QString pointerId, pointersId) { + if (field.second == pointerId) { + if (!classes.value(pointers.value(pointerId)).isEmpty()) { + dependency = classes.value(pointers.value(pointerId)); + } + } + } + } else { + dependency = classes.value(field.second); + } + } - if (attribute.contains(classNamespace + "::", Qt::CaseInsensitive)) { - classFunctions = classFunctionsContainer(attribute, classFunctions); + if (!_dependencyRelations.keys().contains(dependent)) { + if (!dependent.isEmpty() && !dependency.isEmpty()) { + _dependencyRelations.insert(dependent, dependency); + } + } else { + bool isNewDependencie = false; + QStringList dependencies = _dependencyRelations.values(dependent); + foreach (QString d, dependencies) { + if (dependency == d) { + isNewDependencie = true; + } + } + if (isNewDependencie == false) { + if (!dependent.isEmpty() && !dependency.isEmpty()) { + _dependencyRelations.insert(dependent, dependency); + } + } } + + dependency = ""; } } } - if (_xmlFile.isOpen()) { - _xmlFile.close(); - } - - component->setProperty("Functions", QVariant::fromValue(classFunctions)); } -QHash > GccXmlArchitectureRecoveryBackendPlugin::classFunctionsContainer(QString xmlAttribute, QHash > &classFunctions) +void GccXmlArchitectureRecoveryBackendPlugin::baseAdjacencies() { - QMultiHash function; + QString fileName; - QStringList signature = xmlAttribute.split("::"); - QString className = signature.at(0) + "::" + signature.at(1); - QString functionName = signature.at(2).left(signature.at(2).indexOf("(")); + for (int i = 0; i < _xmlCount; ++i) { - findFunctionParameters(functionName, function); - classFunctions.insert(className, function); + fileName = _xmlFilesList.at(i).toLocal8Bit().constData(); - return classFunctions; -} + QMap classes = _fileClasses.value(fileName); + QList > bases = _fileBases.value(fileName); -void GccXmlArchitectureRecoveryBackendPlugin::findFunctionParameters(const QString &functionName, QMultiHash &function) -{ - while (_xmlReader->readNextStartElement()) { - if (!_xmlReader->attributes().value("name").toString().isEmpty()) { - QString parameterName = _xmlReader->attributes().value("name").toString(); - QString typeID = _xmlReader->attributes().value("type").toString(); - - QString parameterTypeNumber = findTypeNumber(typeID); - QString parameterType = findType(parameterTypeNumber); - if (parameterType == "") { - parameterType = findType(typeID); - } + QString dependent; + QString dependency; - function.insert(functionName, parameterName + " " + parameterType); - } - } -} - -QString GccXmlArchitectureRecoveryBackendPlugin::findTypeNumber(const QString &typeID) -{ - QFile file(_rootProjectDir.absolutePath() + "/" + _xmlFileName); - QXmlStreamReader *typeNumberCollector = new QXmlStreamReader(&file); - file.open(QIODevice::ReadOnly | QIODevice::Text); - - while (!typeNumberCollector->atEnd() && !typeNumberCollector->hasError()) { - QXmlStreamReader::TokenType token = typeNumberCollector->readNext(); + QStringList classIds = classes.keys(); + foreach (QString classId, classIds) { + dependent = classes.value(classId); + for (int i = 0; i < bases.size(); ++i) { + QPair base = bases.at(i); + if (classId == base.first) { + dependency = classes.value(base.second); + } + } - if (token == QXmlStreamReader::StartElement) { - if (typeNumberCollector->name() == "PointerType") { - if (typeNumberCollector->attributes().value("id").toString() == typeID) { - break; + if (!_dependencyRelations.keys().contains(dependent)) { + if (!dependent.isEmpty() && !dependency.isEmpty()) { + _dependencyRelations.insert(dependent, dependency); + } + } else { + bool isNewDependencie = false; + QStringList dependencies = _dependencyRelations.values(dependent); + foreach (QString d, dependencies) { + if (dependency == d) { + isNewDependencie = true; + } + } + if (isNewDependencie == false) { + if (!dependent.isEmpty() && !dependency.isEmpty()) { + _dependencyRelations.insert(dependent, dependency); + } } } + + dependency = ""; } } - - QString typeNumber = typeNumberCollector->attributes().value("type").toString(); - - file.close(); - delete typeNumberCollector; - - return typeNumber; } -QString GccXmlArchitectureRecoveryBackendPlugin::findType(const QString &typeNumber) +void GccXmlArchitectureRecoveryBackendPlugin::argumentsAdjacencies() { - QFile file(_rootProjectDir.absolutePath() + "/" + _xmlFileName); - QXmlStreamReader *typeCollector = new QXmlStreamReader(&file); - file.open(QIODevice::ReadOnly | QIODevice::Text); - - while (!typeCollector->atEnd() && !typeCollector->hasError()) { - QXmlStreamReader::TokenType token = typeCollector->readNext(); + QString fileName; + + for (int i = 0; i < _xmlCount; ++i) { + + fileName = _xmlFilesList.at(i).toLocal8Bit().constData(); + + QMap classes = _fileClasses.value(fileName); + QList > arguments = _fileArguments.value(fileName); + QMap pointers = _filePointers.value(fileName); + + QString dependent; + QString dependency; + + QStringList classIds = classes.keys(); + foreach (QString classId, classIds) { + dependent = classes.value(classId); + for (int i = 0; i < arguments.size(); ++i) { + QPair argument = arguments.at(i); + if (classId == argument.first) { + if (classes.value(argument.second).isEmpty()) { + QStringList pointersId = pointers.keys(); + foreach (QString pointerId, pointersId) { + if (argument.second == pointerId) { + if (!classes.value(pointers.value(pointerId)).isEmpty()) { + dependency = classes.value(pointers.value(pointerId)); + } + } + } + } else { + dependency = classes.value(argument.second); + } + } + } - if (token == QXmlStreamReader::StartElement) { - if (typeCollector->name() == "Class") { - if (typeCollector->attributes().value("id").toString() == typeNumber) { - break; + if (!_dependencyRelations.keys().contains(dependent)) { + if (!dependent.isEmpty() && !dependency.isEmpty()) { + _dependencyRelations.insert(dependent, dependency); + } + } else { + bool isNewDependencie = false; + QStringList dependencies = _dependencyRelations.values(dependent); + foreach (QString d, dependencies) { + if (dependency == d) { + isNewDependencie = true; + } + } + if (isNewDependencie == false) { + if (!dependent.isEmpty() && !dependency.isEmpty()) { + _dependencyRelations.insert(dependent, dependency); + } } } + + dependency = ""; } } - - QString type = typeCollector->attributes().value("name").toString(); - - file.close(); - delete typeCollector; - - return type; } } diff --git a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.h b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.h index 8c14f3c1..e83efce8 100644 --- a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.h +++ b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/gccxmlarchitecturerecoverybackendplugin.h @@ -47,10 +47,16 @@ #include #include #include +#include #include #include #include +#include "xmlfilemanager.h" +#include "xmlfilereader.h" + +#include "gccxmlarchitecturerecoverybackend_export.h" + QT_BEGIN_NAMESPACE class QXmlStreamReader; QT_END_NAMESPACE @@ -58,7 +64,7 @@ QT_END_NAMESPACE namespace DuSE { -class GccXmlArchitectureRecoveryBackendPlugin : public IPlugin, public IArchitectureRecoveryBackend +class GCCXMLARCHITECTURERECOVERYBACKEND_EXPORT GccXmlArchitectureRecoveryBackendPlugin : public IPlugin, public IArchitectureRecoveryBackend { Q_OBJECT Q_PLUGIN_METADATA(IID "org.liveblue.DuSE.IPlugin" FILE "gccxmlarchitecturerecoverybackend.json") @@ -68,35 +74,36 @@ public: virtual bool initialize(); - void setRootProjectDir(const QDir &rootProjectDir); - virtual QObjectList components(); virtual QObjectList connectors(); + void run(); + void runGccXml(); + void recoverDependencyRelations(); + void fieldAdjacencies(); + void baseAdjacencies(); + void argumentsAdjacencies(); private Q_SLOTS: - void newArchitectureRecoveryProcess(); private: - QStringList generateXmlFiles(const QStringList &codeFiles) const; - bool openXmlFile(const QString &filePath); - QStringList findConstructorsFromXml(); - QObject *extractComponent(); - void findFunctionsFromXml(QObject *component); - QHash > classFunctionsContainer(QString xmlAttribute, QHash > &classFunctions); - void findFunctionParameters(const QString &functionName, QMultiHash &function); - QString findTypeNumber(const QString &typeID); - QString findType(const QString &typeNumber); - - QDir _rootProjectDir; - QFile _xmlFile; - QString _xmlFileName; - QXmlStreamReader *_xmlReader; + int _xmlCount; + QDir _rootProjectDirectory; + QString _rootProjectDirectoryString; + QStringList _xmlFilesList; + XmlFileManager *_xmlFileManager; + XmlFileReader *_reader; + QMap > _fileClasses; + QMap > > _fileFields; + QMap > _filePointers; + QMap > > _fileBases; + QMap > > _fileArguments; + QMultiMap _dependencyRelations; }; -typedef QHash > ClassFunctions; +typedef QMultiMap DependencyRelations; #endif // GCCXMLARCHITECTURERECOVERYBACKENDPLUGIN } -Q_DECLARE_METATYPE(DuSE::ClassFunctions); +Q_DECLARE_METATYPE(DuSE::DependencyRelations); diff --git a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilemanager.cpp b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilemanager.cpp new file mode 100644 index 00000000..fee7f8d5 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilemanager.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "xmlfilemanager.h" + +#include +#include +#include + +namespace DuSE +{ + +XmlFileManager::XmlFileManager() +{ +} + +QStringList XmlFileManager::generateXmlFiles(const QDir &rootProjectDir) const +{ + QStringList headers = rootProjectDir.entryList(QStringList("*.h"), QDir::Files | QDir::NoSymLinks); + + int codeFilesSize = headers.size(); + + for (int i = 0; i < codeFilesSize; ++i) { + QString file = headers.at(i).toLocal8Bit().constData(); + QString fileDir = rootProjectDir.absolutePath() + "/" + file; + QString xmlFileDir = rootProjectDir.absolutePath() + "/" + file.replace(".h", ".xml"); + + QProcess process; + process.start("gccxml " + fileDir + " -fxml=" + xmlFileDir); + process.waitForFinished(); + } + + return rootProjectDir.entryList(QStringList("*.xml"), QDir::Files | QDir::NoSymLinks); +} + +QXmlStreamReader *XmlFileManager::openXmlFile(const QString &filePath) +{ + _xmlFile.setFileName(filePath); + _xmlReader = new QXmlStreamReader(&_xmlFile); + + if (!_xmlFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + return new QXmlStreamReader; + } + + return _xmlReader; +} + +void XmlFileManager::closeXmlFile() +{ + if (_xmlFile.isOpen()) { + _xmlFile.close(); + } +} + +} diff --git a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilemanager.h b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilemanager.h new file mode 100644 index 00000000..cad93994 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilemanager.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef XMLFILEMANAGER_H +#define XMLFILEMANAGER_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QDir; +class QXmlStreamReader; +QT_END_NAMESPACE + +namespace DuSE +{ + +class XmlFileManager +{ +public: + XmlFileManager(); + + ~XmlFileManager(); + + QStringList generateXmlFiles(const QDir &rootProjectDir) const; + QXmlStreamReader* openXmlFile(const QString &filePath); + void closeXmlFile(); + +private: + QFile _xmlFile; + QXmlStreamReader *_xmlReader; +}; + +} + +#endif // XMLFILEMANAGER_H diff --git a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilereader.cpp b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilereader.cpp new file mode 100644 index 00000000..79ce4297 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilereader.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "xmlfilereader.h" + +#include + +namespace DuSE +{ + +XmlFileReader::XmlFileReader(QString rootDirectory, QString fileName) + : _rootProjectDir(rootDirectory), _fileName(fileName) +{ + _xmlFileManager = new XmlFileManager; +} + +void XmlFileReader::fillTagContainers() +{ + _xmlReader = _xmlFileManager->openXmlFile(_rootProjectDir + "/" + _fileName); + + while (!_xmlReader->atEnd() & !_xmlReader->hasError()) { + QXmlStreamReader::TokenType token = _xmlReader->readNext(); + QPair auxPair; + + if (token == QXmlStreamReader::StartElement) { + QXmlStreamAttributes attributes; + + if (_xmlReader->name() == "Class") { + attributes = _xmlReader->attributes(); + QString classId = attributes.value("id").toString(); + QString className = attributes.value("name").toString(); + if (!_fileClasses.values().contains(className)) { + _fileClasses.insert(classId, className); + } + + do { + if (_xmlReader->readNextStartElement()) { + if (_xmlReader->name() == "Base") { + attributes = _xmlReader->attributes(); + QString baseType = attributes.value("type").toString(); + auxPair.first = classId; + auxPair.second = baseType; + _fileBases.append(auxPair); + } + } + } while (_xmlReader->name() == "Base"); + } + + if (_xmlReader->name() == "Field") { + attributes = _xmlReader->attributes(); + QString fieldContext = attributes.value("context").toString(); + QString fieldType = attributes.value("type").toString(); + auxPair.first = fieldContext; + auxPair.second = fieldType; + _fileFields.append(auxPair); + } + + if (_xmlReader->name() == "PointerType") { + attributes = _xmlReader->attributes(); + QString pointerId = attributes.value("id").toString(); + QString pointerType = attributes.value("type").toString(); + auxPair.first = pointerId; + auxPair.second = pointerType; + _filePointers.insert(pointerId, pointerType); + } + + + if (_xmlReader->name() == "Method") { + attributes = _xmlReader->attributes(); + QString methodContext = attributes.value("context").toString(); + + do { + if (_xmlReader->readNextStartElement()) { + if (_xmlReader->name() == "Argument") { + attributes = _xmlReader->attributes(); + QString argumentType = attributes.value("type").toString(); + auxPair.first = methodContext; + auxPair.second = argumentType; + _fileArguments.append(auxPair); + } + } + } while (_xmlReader->name() == "Argument"); + } + } + } _xmlFileManager->closeXmlFile(); +} + +QMap XmlFileReader::fileClasses() +{ + return _fileClasses; +} + +QList > XmlFileReader::fileFields() +{ + return _fileFields; +} + +QMap XmlFileReader::filePointers() +{ + return _filePointers; +} + +QList > XmlFileReader::fileBases() +{ + return _fileBases; +} + +QList > XmlFileReader::fileArguments() +{ + return _fileArguments; +} + +} diff --git a/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilereader.h b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilereader.h new file mode 100644 index 00000000..6059c8f5 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/gccxmlarchitecturerecoverybackend/xmlfilereader.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef XMLFILEREADER_H +#define XMLFILEREADER_H + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QXmlStreamReader; +QT_END_NAMESPACE + +#include "xmlfilemanager.h" + +namespace DuSE +{ + +class XmlFileReader +{ +public: + XmlFileReader(QString rootDirectory, QString fileName); + ~XmlFileReader(); + + void fillTagContainers(); + QMap fileClasses(); + QList > fileFields(); + QMap filePointers(); + QList > fileBases(); + QList > fileArguments(); + +private: + QString _rootProjectDir; + QString _fileName; + QXmlStreamReader *_xmlReader; + XmlFileManager *_xmlFileManager; + QMap _fileClasses; + QList > _fileFields; + QMap _filePointers; + QList > _fileBases; + QList > _fileArguments; +}; + +} + +#endif // XMLFILEREADER_H diff --git a/examples/uml/duse-mt/src/plugins/plugins.pro b/examples/uml/duse-mt/src/plugins/plugins.pro index 9361759b..288a90aa 100644 --- a/examples/uml/duse-mt/src/plugins/plugins.pro +++ b/examples/uml/duse-mt/src/plugins/plugins.pro @@ -14,4 +14,7 @@ qtHaveModule(quick): SUBDIRS += welcomedashboard \ qtHaveModule(script):qtHaveModule(quick): SUBDIRS += designspaceexplorer SUBDIRS += architecturerecoverycore \ - gccxmlarchitecturerecoverybackend + gccxmlarchitecturerecoverybackend \ + acdcarchitecturerecoveryalgorithm \ + umlmodelingnotation \ + architecturerecoverypanel diff --git a/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation.json b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation.json new file mode 100644 index 00000000..1952997f --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation.json @@ -0,0 +1,8 @@ +{ + "Category": "Architecture Recovery", + "Vendor": "Qt Project", + "Version": "1.0", + "DependencyList": [ + "ArchitectureRecoveryCorePlugin" + ] +} diff --git a/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation.pro b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation.pro new file mode 100644 index 00000000..acd61e57 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation.pro @@ -0,0 +1,21 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2014-08-14T03:21:41 +# +#------------------------------------------------- + +include(../../duse-mt-plugin.pri) + +QT -= widgets gui +QT += modeling uml + +DEFINES += UMLMODELINGNOTATION_LIBRARY + +HEADERS += \ + umlmodelingnotation_export.h \ + umlmodelingnotationplugin.h + +SOURCES += \ + umlmodelingnotationplugin.cpp + +OTHER_FILES += umlmodelingnotation.json diff --git a/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation_dependencies.pri b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation_dependencies.pri new file mode 100644 index 00000000..7a6dd211 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation_dependencies.pri @@ -0,0 +1,4 @@ +DUSEMT_PLUGIN_NAME = UmlModelingNotation + +DUSEMT_PLUGIN_DEPENDS += \ + architecturerecoverycore diff --git a/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation_export.h b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation_export.h new file mode 100644 index 00000000..b5e46f50 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotation_export.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef UMLMODELINGNOTATION_EXPORT_H +#define UMLMODELINGNOTATION_EXPORT_H + +#include + +#if defined(UMLMODELINGNOTATION_LIBRARY) +# define UMLMODELINGNOTATION_EXPORT Q_DECL_EXPORT +#else +# define UMLMODELINGNOTATION_EXPORT Q_DECL_IMPORT +#endif + +#endif // UMLMODELINGNOTATION_EXPORT_H diff --git a/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotationplugin.cpp b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotationplugin.cpp new file mode 100644 index 00000000..c06b6474 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotationplugin.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "umlmodelingnotationplugin.h" + +#include + +namespace DuSE +{ + +UmlModelingNotationPlugin::UmlModelingNotationPlugin(QObject *parent) + : IPlugin(parent) +{ + _name = "UML Notation"; +} + +bool UmlModelingNotationPlugin::initialize() +{ + return true; +} + +void UmlModelingNotationPlugin::generateDiagram(const QString &name) +{ + QFile file(QString(name + "/output.xmi")); + + if (!file.open(QFile::WriteOnly | QFile::Text)) { + qDebug() << "Cannot write file !"; + } else { + QXmiWriter writer; + QList list; + foreach (QUmlPackage *subsystem, _subsystems) { + list<< subsystem->asQModelingObject(); + } + + if (writer.writeFile(list, &file)) { + qDebug() << "XMI file saved !"; + } else { + qDebug() << "Error when writing XMI file !"; + } + } + + file.close(); +} + +void UmlModelingNotationPlugin::loadSubsystems() +{ + foreach (QStringList clusterElements, _clusterList) { + QUmlPackage *subsystem = new QUmlPackage; + subsystem->setName(clusterElements.at(0)); + for (int i = 1; i < clusterElements.count(); ++i) { + QUmlPackage *subsystemElement = new QUmlPackage; + subsystemElement->setName(clusterElements.at(i)); + subsystem->addPackagedElement(subsystemElement); + } + _subsystems.append(subsystem); + } +} + +void UmlModelingNotationPlugin::setClusterList(QList m_clusterList) +{ + _clusterList = m_clusterList; +} + +} diff --git a/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotationplugin.h b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotationplugin.h new file mode 100644 index 00000000..fb1f76c3 --- /dev/null +++ b/examples/uml/duse-mt/src/plugins/umlmodelingnotation/umlmodelingnotationplugin.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef UMLMODELINGNOTATIONPLUGIN_H +#define UMLMODELINGNOTATIONPLUGIN_H + +#include +#include + +#include +#include +#include + +#include "umlmodelingnotation_export.h" + +namespace DuSE +{ + +class UMLMODELINGNOTATION_EXPORT UmlModelingNotationPlugin : public IPlugin, public IModelingNotation +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.liveblue.DuSE.IPlugin" FILE "umlmodelingnotation.json") + +public: + UmlModelingNotationPlugin(QObject *parent = 0); + + virtual bool initialize(); + virtual void generateDiagram(const QString &name); + void loadSubsystems(); + + void setClusterList(QList m_clusterList); + +private: + QList _clusterList; + QList _subsystems; +}; + +} + +#endif // UMLMODELINGNOTATIONPLUGIN_H -- cgit v1.2.3