qmlprofilerruncontrolfactory.cpp 3.19 KB
Newer Older
1
/****************************************************************************
2
**
3 4
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** 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.
15
**
hjk's avatar
hjk committed
16 17 18 19 20 21 22 23 24 25
** 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
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29

30 31 32
#include "qmlprofilerruncontrolfactory.h"
#include "localqmlprofilerrunner.h"
#include "qmlprofilerengine.h"
33

34 35 36 37 38 39 40 41
#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>
42

43
#include <utils/qtcassert.h>
44

45
using namespace Analyzer;
46 47
using namespace ProjectExplorer;

48
namespace QmlProfiler {
49 50
namespace Internal {

51
QmlProfilerRunControlFactory::QmlProfilerRunControlFactory(QObject *parent) :
52 53 54 55
    IRunControlFactory(parent)
{
}

56
bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const
57
{
58 59
    if (mode != QmlProfilerRunMode)
        return false;
60
    IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
61 62 63 64 65
    if (tool)
        return tool->canRun(runConfiguration, mode);
    return false;
}

66
RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
67
{
68
    IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
69 70 71
    if (!tool) {
        if (errorMessage)
            *errorMessage = tr("No analyzer tool selected"); // never happens
72
        return 0;
73
    }
74 75 76 77 78 79 80 81 82 83

    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;
}

84
IRunConfigurationAspect *QmlProfilerRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
85
{
86
    Q_UNUSED(rc);
87
    return new AnalyzerRunConfigurationAspect;
88 89 90
}

} // namespace Internal
91
} // namespace QmlProfiler