Analyzer: Separate out run control factories

Separating out the run control factories is the initial
step towards separation of run control from QML profiler
engine. The goal is to to make the engine agnostic of
the run control.

Change-Id: Ic8279755f0188ab53253a62322fcccf1c17b6aaf
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
This commit is contained in:
Aurindam Jana
2013-07-19 16:08:54 +02:00
parent 2001fe982b
commit c57160eda6
13 changed files with 200 additions and 41 deletions

View File

@@ -16,8 +16,7 @@ SOURCES += \
analyzeroptionspage.cpp \ analyzeroptionspage.cpp \
analyzerrunconfigwidget.cpp \ analyzerrunconfigwidget.cpp \
analyzerutils.cpp \ analyzerutils.cpp \
startremotedialog.cpp \ startremotedialog.cpp
analyzerruncontrolfactory.cpp
HEADERS += \ HEADERS += \
ianalyzerengine.h \ ianalyzerengine.h \
@@ -32,8 +31,7 @@ HEADERS += \
analyzeroptionspage.h \ analyzeroptionspage.h \
analyzerrunconfigwidget.h \ analyzerrunconfigwidget.h \
analyzerutils.h \ analyzerutils.h \
startremotedialog.h \ startremotedialog.h
analyzerruncontrolfactory.h
RESOURCES += \ RESOURCES += \
analyzerbase.qrc analyzerbase.qrc

View File

@@ -26,8 +26,6 @@ QtcPlugin {
"analyzerrunconfigwidget.h", "analyzerrunconfigwidget.h",
"analyzerruncontrol.cpp", "analyzerruncontrol.cpp",
"analyzerruncontrol.h", "analyzerruncontrol.h",
"analyzerruncontrolfactory.cpp",
"analyzerruncontrolfactory.h",
"analyzersettings.cpp", "analyzersettings.cpp",
"analyzersettings.h", "analyzersettings.h",
"analyzerstartparameters.h", "analyzerstartparameters.h",

View File

@@ -30,7 +30,6 @@
#include "analyzerplugin.h" #include "analyzerplugin.h"
#include "analyzermanager.h" #include "analyzermanager.h"
#include "analyzerruncontrolfactory.h"
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/taskhub.h> #include <projectexplorer/taskhub.h>
@@ -65,8 +64,6 @@ bool AnalyzerPlugin::initialize(const QStringList &arguments, QString *errorStri
(void) new AnalyzerManager(this); (void) new AnalyzerManager(this);
addAutoReleasedObject(new AnalyzerRunControlFactory());
// Task integration. // Task integration.
//: Category under which Analyzer tasks are listed in Issues view //: Category under which Analyzer tasks are listed in Issues view
ProjectExplorer::ProjectExplorerPlugin::instance()->taskHub() ProjectExplorer::ProjectExplorerPlugin::instance()->taskHub()

View File

@@ -20,7 +20,8 @@ SOURCES += \
qmlprofilerdatamodel.cpp \ qmlprofilerdatamodel.cpp \
qmlprofilerclientmanager.cpp \ qmlprofilerclientmanager.cpp \
qmlprofilerviewmanager.cpp \ qmlprofilerviewmanager.cpp \
qmlprofilerstatewidget.cpp qmlprofilerstatewidget.cpp \
qmlprofilerruncontrolfactory.cpp
HEADERS += \ HEADERS += \
qmlprofilerconstants.h \ qmlprofilerconstants.h \
@@ -40,7 +41,8 @@ HEADERS += \
qmlprofilerdatamodel.h \ qmlprofilerdatamodel.h \
qmlprofilerclientmanager.h \ qmlprofilerclientmanager.h \
qmlprofilerviewmanager.h \ qmlprofilerviewmanager.h \
qmlprofilerstatewidget.h qmlprofilerstatewidget.h \
qmlprofilerruncontrolfactory.h
RESOURCES += \ RESOURCES += \
qml/qmlprofiler.qrc qml/qmlprofiler.qrc

View File

@@ -42,6 +42,8 @@ QtcPlugin {
"qmlprofilereventview.h", "qmlprofilereventview.h",
"qmlprofilerplugin.cpp", "qmlprofilerplugin.cpp",
"qmlprofilerplugin.h", "qmlprofilerplugin.h",
"qmlprofilerruncontrolfactory.cpp",
"qmlprofilerruncontrolfactory.h",
"qmlprofilerstatemanager.cpp", "qmlprofilerstatemanager.cpp",
"qmlprofilerstatemanager.h", "qmlprofilerstatemanager.h",
"qmlprofilerstatewidget.cpp", "qmlprofilerstatewidget.cpp",

View File

@@ -28,6 +28,7 @@
****************************************************************************/ ****************************************************************************/
#include "qmlprofilerplugin.h" #include "qmlprofilerplugin.h"
#include "qmlprofilerruncontrolfactory.h"
#include "qmlprofilertool.h" #include "qmlprofilertool.h"
@@ -50,6 +51,8 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
modes.append(StartMode(StartRemote)); modes.append(StartMode(StartRemote));
AnalyzerManager::addTool(new QmlProfilerTool(this), modes); AnalyzerManager::addTool(new QmlProfilerTool(this), modes);
addAutoReleasedObject(new QmlProfilerRunControlFactory());
return true; return true;
} }

View File

@@ -0,0 +1,91 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and 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.
**
****************************************************************************/
#include "qmlprofilerruncontrolfactory.h"
#include "localqmlprofilerrunner.h"
#include "qmlprofilerengine.h"
#include <analyzerbase/ianalyzertool.h>
#include <analyzerbase/analyzermanager.h>
#include <analyzerbase/analyzerstartparameters.h>
#include <analyzerbase/analyzerruncontrol.h>
#include <analyzerbase/analyzersettings.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <utils/qtcassert.h>
using namespace Analyzer;
using namespace ProjectExplorer;
namespace QmlProfiler {
namespace Internal {
QmlProfilerRunControlFactory::QmlProfilerRunControlFactory(QObject *parent) :
IRunControlFactory(parent)
{
}
bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const
{
if (mode != QmlProfilerRunMode)
return false;
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (tool)
return tool->canRun(runConfiguration, mode);
return false;
}
RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
{
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected"); // never happens
return 0;
}
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
AnalyzerStartParameters sp = tool->createStartParameters(runConfiguration, mode);
sp.toolId = tool->id();
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, runConfiguration);
return rc;
}
IRunConfigurationAspect *QmlProfilerRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
{
Q_UNUSED(rc);
return new AnalyzerRunConfigurationAspect;
}
} // namespace Internal
} // namespace QmlProfiler

View File

@@ -0,0 +1,58 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and 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.
**
****************************************************************************/
#ifndef QMLPROFILERRUNCONTROLFACTORY_H
#define QMLPROFILERRUNCONTROLFACTORY_H
#include <projectexplorer/runconfiguration.h>
namespace QmlProfiler {
namespace Internal {
class QmlProfilerRunControlFactory : public ProjectExplorer::IRunControlFactory
{
Q_OBJECT
public:
typedef ProjectExplorer::RunConfiguration RunConfiguration;
explicit QmlProfilerRunControlFactory(QObject *parent = 0);
// IRunControlFactory implementation
bool canRun(RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const;
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode,
QString *errorMessage);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc);
};
} // namespace Internal
} // namespace QmlProfiler
#endif // QMLPROFILERRUNCONTROLFACTORY_H

View File

@@ -29,7 +29,8 @@ HEADERS += \
memcheckengine.h \ memcheckengine.h \
memcheckerrorview.h \ memcheckerrorview.h \
suppressiondialog.h \ suppressiondialog.h \
valgrindtool.h valgrindtool.h \
valgrindruncontrolfactory.h
SOURCES += \ SOURCES += \
valgrindplugin.cpp \ valgrindplugin.cpp \
@@ -52,7 +53,8 @@ SOURCES += \
memcheckengine.cpp \ memcheckengine.cpp \
memcheckerrorview.cpp \ memcheckerrorview.cpp \
suppressiondialog.cpp \ suppressiondialog.cpp \
valgrindtool.cpp valgrindtool.cpp \
valgrindruncontrolfactory.cpp
FORMS += \ FORMS += \
valgrindconfigwidget.ui valgrindconfigwidget.ui

View File

@@ -48,6 +48,8 @@ QtcPlugin {
"valgrindplugin.h", "valgrindplugin.h",
"valgrindprocess.cpp", "valgrindprocess.cpp",
"valgrindprocess.h", "valgrindprocess.h",
"valgrindruncontrolfactory.cpp",
"valgrindruncontrolfactory.h",
"valgrindrunner.cpp", "valgrindrunner.cpp",
"valgrindrunner.h", "valgrindrunner.h",
"valgrindsettings.cpp", "valgrindsettings.cpp",

View File

@@ -32,6 +32,7 @@
#include "callgrindtool.h" #include "callgrindtool.h"
#include "memchecktool.h" #include "memchecktool.h"
#include "valgrindruncontrolfactory.h"
#include <analyzerbase/analyzerconstants.h> #include <analyzerbase/analyzerconstants.h>
#include <analyzerbase/analyzermanager.h> #include <analyzerbase/analyzermanager.h>
@@ -99,6 +100,8 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
AnalyzerManager::addTool(new MemcheckTool(this), modes); AnalyzerManager::addTool(new MemcheckTool(this), modes);
AnalyzerManager::addTool(new CallgrindTool(this), modes); AnalyzerManager::addTool(new CallgrindTool(this), modes);
addAutoReleasedObject(new ValgrindRunControlFactory());
return true; return true;
} }

View File

@@ -1,7 +1,7 @@
/************************************************************************** /****************************************************************************
** **
** Copyright (C) 2013 Kläralvdalens Datakonsult AB, a KDAB Group company. ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: Kläralvdalens Datakonsult AB (info@kdab.com) ** Contact: http://www.qt-project.org/legal
** **
** This file is part of Qt Creator. ** This file is part of Qt Creator.
** **
@@ -27,36 +27,38 @@
** **
****************************************************************************/ ****************************************************************************/
#include "analyzerruncontrolfactory.h" #include "valgrindruncontrolfactory.h"
#include "analyzersettings.h"
#include "analyzerruncontrol.h" #include <analyzerbase/ianalyzertool.h>
#include "analyzermanager.h" #include <analyzerbase/analyzermanager.h>
#include "ianalyzertool.h" #include <analyzerbase/analyzerstartparameters.h>
#include "analyzerstartparameters.h" #include <analyzerbase/analyzerruncontrol.h>
#include <analyzerbase/analyzersettings.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QAction> using namespace Analyzer;
using namespace ProjectExplorer; using namespace ProjectExplorer;
namespace Analyzer { namespace Valgrind {
namespace Internal { namespace Internal {
AnalyzerRunControlFactory::AnalyzerRunControlFactory(QObject *parent) : ValgrindRunControlFactory::ValgrindRunControlFactory(QObject *parent) :
IRunControlFactory(parent) IRunControlFactory(parent)
{ {
} }
bool AnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const bool ValgrindRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const
{ {
if (mode != CallgrindRunMode && mode != MemcheckRunMode)
return false;
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode); IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (tool) if (tool)
return tool->canRun(runConfiguration, mode); return tool->canRun(runConfiguration, mode);
return false; return false;
} }
RunControl *AnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
{ {
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode); IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool) { if (!tool) {
@@ -74,11 +76,11 @@ RunControl *AnalyzerRunControlFactory::create(RunConfiguration *runConfiguration
return rc; return rc;
} }
IRunConfigurationAspect *AnalyzerRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc) IRunConfigurationAspect *ValgrindRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
{ {
Q_UNUSED(rc); Q_UNUSED(rc);
return new AnalyzerRunConfigurationAspect; return new AnalyzerRunConfigurationAspect;
} }
} // namespace Internal } // namespace Internal
} // namespace Analyzer } // namespace Valgrind

View File

@@ -1,7 +1,7 @@
/************************************************************************** /****************************************************************************
** **
** Copyright (C) 2013 Kläralvdalens Datakonsult AB, a KDAB Group company. ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: Kläralvdalens Datakonsult AB (info@kdab.com) ** Contact: http://www.qt-project.org/legal
** **
** This file is part of Qt Creator. ** This file is part of Qt Creator.
** **
@@ -27,24 +27,25 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef ANALYZERRUNCONTROLFACTORY_H #ifndef VALGRINDRUNCONTROLFACTORY_H
#define ANALYZERRUNCONTROLFACTORY_H #define VALGRINDRUNCONTROLFACTORY_H
#include <analyzerbase/analyzerruncontrol.h> #include <projectexplorer/runconfiguration.h>
namespace Analyzer { namespace Valgrind {
namespace Internal { namespace Internal {
class AnalyzerRunControlFactory : public ProjectExplorer::IRunControlFactory class ValgrindRunControlFactory : public ProjectExplorer::IRunControlFactory
{ {
Q_OBJECT Q_OBJECT
public: public:
typedef ProjectExplorer::RunConfiguration RunConfiguration; typedef ProjectExplorer::RunConfiguration RunConfiguration;
explicit AnalyzerRunControlFactory(QObject *parent = 0); explicit ValgrindRunControlFactory(QObject *parent = 0);
// IRunControlFactory implementation // IRunControlFactory implementation
bool canRun(RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const; bool canRun(RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const;
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode, ProjectExplorer::RunMode mode,
QString *errorMessage); QString *errorMessage);
@@ -52,6 +53,6 @@ public:
}; };
} // namespace Internal } // namespace Internal
} // namespace Analyzer } // namespace Valgrind
#endif // ANALYZERRUNCONTROLFACTORY_H #endif // VALGRINDRUNCONTROLFACTORY_H