forked from qt-creator/qt-creator
ProjectExplorer: Introduce Runnable and Connection concepts.
A 'Runnable' contains (possibly target-specific) data to describe something that could be run (e.g. a remote executable with arguments, working directory and environment). A 'Connection' contains (possibly target-specific) data to describe a connection to target that will be used to run a Runnable. Runnable and Connection objects are used in the target RunControlFactories and are opaque to the project explorer. Change-Id: I2293dffa71148646cfb52c9b582ccd2675b145a8 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -541,6 +541,16 @@ Core::Id RunControl::runMode() const
|
|||||||
return m_runMode;
|
return m_runMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RunControl::setRunnable(const Runnable &runnable)
|
||||||
|
{
|
||||||
|
m_runnable = runnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RunControl::setConnection(const Connection &connection)
|
||||||
|
{
|
||||||
|
m_connection = connection;
|
||||||
|
}
|
||||||
|
|
||||||
QString RunControl::displayName() const
|
QString RunControl::displayName() const
|
||||||
{
|
{
|
||||||
return m_displayName;
|
return m_displayName;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "projectconfiguration.h"
|
#include "projectconfiguration.h"
|
||||||
#include "projectexplorer_export.h"
|
#include "projectexplorer_export.h"
|
||||||
#include "projectexplorerconstants.h"
|
#include "projectexplorerconstants.h"
|
||||||
|
#include "applicationlauncher.h"
|
||||||
|
|
||||||
#include <utils/outputformat.h>
|
#include <utils/outputformat.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -37,6 +38,8 @@
|
|||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QFormLayout;
|
class QFormLayout;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@@ -150,6 +153,67 @@ private:
|
|||||||
ISettingsAspect *m_globalSettings; // Not owned.
|
ISettingsAspect *m_globalSettings; // Not owned.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PROJECTEXPLORER_EXPORT ClonableConcept
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~ClonableConcept() = default;
|
||||||
|
virtual ClonableConcept *clone() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class ClonableModel : public ClonableConcept
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ClonableModel(const T &data) : m_data(data) {}
|
||||||
|
ClonableConcept *clone() const override { return new ClonableModel(*this); }
|
||||||
|
|
||||||
|
T m_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PROJECTEXPLORER_EXPORT Runnable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Runnable() {}
|
||||||
|
Runnable(const Runnable &other) : d(other.d->clone()) {}
|
||||||
|
Runnable(Runnable &&other) = default;
|
||||||
|
template <class T> Runnable(const T &data) : d(new ClonableModel<T>(data)) {}
|
||||||
|
|
||||||
|
void operator=(Runnable other) { d = std::move(other.d); }
|
||||||
|
|
||||||
|
template <class T> bool is() const {
|
||||||
|
return dynamic_cast<ClonableModel<T> *>(d.get()) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T> const T &as() const {
|
||||||
|
return static_cast<ClonableModel<T> *>(d.get())->m_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<ClonableConcept> d;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PROJECTEXPLORER_EXPORT Connection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Connection() {}
|
||||||
|
Connection(const Connection &other) : d(other.d->clone()) {}
|
||||||
|
Connection(Connection &&other) = default;
|
||||||
|
template <class T> Connection(const T &data) : d(new ClonableModel<T>(data)) {}
|
||||||
|
|
||||||
|
void operator=(Connection other) { d = std::move(other.d); }
|
||||||
|
|
||||||
|
template <class T> bool is() const {
|
||||||
|
return dynamic_cast<ClonableModel<T> *>(d.get()) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T> const T &as() const {
|
||||||
|
return static_cast<ClonableModel<T> *>(d.get())->m_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<ClonableConcept> d;
|
||||||
|
};
|
||||||
|
|
||||||
// Documentation inside.
|
// Documentation inside.
|
||||||
class PROJECTEXPLORER_EXPORT RunConfiguration : public ProjectConfiguration
|
class PROJECTEXPLORER_EXPORT RunConfiguration : public ProjectConfiguration
|
||||||
{
|
{
|
||||||
@@ -303,6 +367,12 @@ public:
|
|||||||
Utils::OutputFormatter *outputFormatter();
|
Utils::OutputFormatter *outputFormatter();
|
||||||
Core::Id runMode() const;
|
Core::Id runMode() const;
|
||||||
|
|
||||||
|
const Runnable &runnable() const { return m_runnable; }
|
||||||
|
void setRunnable(const Runnable &runnable);
|
||||||
|
|
||||||
|
const Connection &connection() const { return m_connection; }
|
||||||
|
void setConnection(const Connection &connection);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void bringApplicationToForeground(qint64 pid);
|
void bringApplicationToForeground(qint64 pid);
|
||||||
void appendMessage(const QString &msg, Utils::OutputFormat format);
|
void appendMessage(const QString &msg, Utils::OutputFormat format);
|
||||||
@@ -325,6 +395,8 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
|
Runnable m_runnable;
|
||||||
|
Connection m_connection;
|
||||||
Core::Id m_runMode;
|
Core::Id m_runMode;
|
||||||
Utils::Icon m_icon;
|
Utils::Icon m_icon;
|
||||||
const QPointer<RunConfiguration> m_runConfiguration;
|
const QPointer<RunConfiguration> m_runConfiguration;
|
||||||
|
|||||||
Reference in New Issue
Block a user