summaryrefslogtreecommitdiff
path: root/src/plugins/qmlprofiler
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@digia.com>2013-07-19 16:08:54 +0200
committerAurindam Jana <aurindam.jana@digia.com>2013-07-23 16:17:21 +0200
commitc57160eda676b7cefd9375191054a0df0c8d4408 (patch)
treeb5e1ceee7035ebcdca948b6764a3020f9ebf61db /src/plugins/qmlprofiler
parent2001fe982b38a59c7f03c3b7bb36a83ce5aaf246 (diff)
downloadqt-creator-c57160eda676b7cefd9375191054a0df0c8d4408.tar.gz
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>
Diffstat (limited to 'src/plugins/qmlprofiler')
-rw-r--r--src/plugins/qmlprofiler/qmlprofiler.pro6
-rw-r--r--src/plugins/qmlprofiler/qmlprofiler.qbs2
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerplugin.cpp3
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp91
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h58
5 files changed, 158 insertions, 2 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro
index c2f6f05818..d644e47527 100644
--- a/src/plugins/qmlprofiler/qmlprofiler.pro
+++ b/src/plugins/qmlprofiler/qmlprofiler.pro
@@ -20,7 +20,8 @@ SOURCES += \
qmlprofilerdatamodel.cpp \
qmlprofilerclientmanager.cpp \
qmlprofilerviewmanager.cpp \
- qmlprofilerstatewidget.cpp
+ qmlprofilerstatewidget.cpp \
+ qmlprofilerruncontrolfactory.cpp
HEADERS += \
qmlprofilerconstants.h \
@@ -40,7 +41,8 @@ HEADERS += \
qmlprofilerdatamodel.h \
qmlprofilerclientmanager.h \
qmlprofilerviewmanager.h \
- qmlprofilerstatewidget.h
+ qmlprofilerstatewidget.h \
+ qmlprofilerruncontrolfactory.h
RESOURCES += \
qml/qmlprofiler.qrc
diff --git a/src/plugins/qmlprofiler/qmlprofiler.qbs b/src/plugins/qmlprofiler/qmlprofiler.qbs
index cb136bf4d8..4550ec894f 100644
--- a/src/plugins/qmlprofiler/qmlprofiler.qbs
+++ b/src/plugins/qmlprofiler/qmlprofiler.qbs
@@ -42,6 +42,8 @@ QtcPlugin {
"qmlprofilereventview.h",
"qmlprofilerplugin.cpp",
"qmlprofilerplugin.h",
+ "qmlprofilerruncontrolfactory.cpp",
+ "qmlprofilerruncontrolfactory.h",
"qmlprofilerstatemanager.cpp",
"qmlprofilerstatemanager.h",
"qmlprofilerstatewidget.cpp",
diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp
index 4d49ff1d8a..70e016cf09 100644
--- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp
@@ -28,6 +28,7 @@
****************************************************************************/
#include "qmlprofilerplugin.h"
+#include "qmlprofilerruncontrolfactory.h"
#include "qmlprofilertool.h"
@@ -50,6 +51,8 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
modes.append(StartMode(StartRemote));
AnalyzerManager::addTool(new QmlProfilerTool(this), modes);
+ addAutoReleasedObject(new QmlProfilerRunControlFactory());
+
return true;
}
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp
new file mode 100644
index 0000000000..453a37f559
--- /dev/null
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp
@@ -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
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h
new file mode 100644
index 0000000000..a7f6d9ffe3
--- /dev/null
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h
@@ -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