aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/runcontrol.h
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2019-08-07 18:05:15 +0200
committerhjk <hjk@qt.io>2019-08-09 12:34:42 +0000
commitf9c221eb54ca3174c57f736b7afd5914147ab2a2 (patch)
tree1d58370c31fd3c342ddd133f659ee01adb017b22 /src/plugins/projectexplorer/runcontrol.h
parenta88970db34357adaaedd7514490d94702744a7ec (diff)
ProjectExplorer: Re-work setup runworker factories
This combines two of the previous three paths to create run workers, and refers to RunConfigurations by id, not by type where possible to decrease coupling between the classes. Only allow "type of run configuration" and "type of device" as the only possible kind of restriction and require a uniform RunWorker constructor signature. Adapt user code to fit that pattern. Change-Id: I5a6d49c9a144785fd0235d7586f244b56f67b366 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/runcontrol.h')
-rw-r--r--src/plugins/projectexplorer/runcontrol.h64
1 files changed, 16 insertions, 48 deletions
diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h
index ae6058580e..b794634742 100644
--- a/src/plugins/projectexplorer/runcontrol.h
+++ b/src/plugins/projectexplorer/runcontrol.h
@@ -50,11 +50,8 @@ class OutputFormatter;
namespace ProjectExplorer {
class GlobalOrProjectAspect;
class Node;
-class RunConfigurationFactory;
class RunConfiguration;
-class RunConfigurationCreationInfo;
class RunControl;
-class RunWorkerFactory;
class Target;
namespace Internal {
@@ -142,36 +139,32 @@ private:
const std::unique_ptr<Internal::RunWorkerPrivate> d;
};
-class PROJECTEXPLORER_EXPORT RunWorkerFactory
+class PROJECTEXPLORER_EXPORT RunWorkerFactory final
{
public:
using WorkerCreator = std::function<RunWorker *(RunControl *)>;
- using Constraint = std::function<bool(RunConfiguration *)>;
-
- RunWorkerFactory();
- virtual ~RunWorkerFactory();
-
- bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const;
- void setProducer(const WorkerCreator &producer);
- void addConstraint(const Constraint &constraint);
- void addSupportedRunMode(Core::Id runMode);
+ RunWorkerFactory(const WorkerCreator &producer,
+ const QList<Core::Id> &runModes,
+ const QList<Core::Id> &runConfigs = {},
+ const QList<Core::Id> &deviceTypes = {});
- void setSupportedRunConfigurations(const QList<Core::Id> &ids);
- void addSupportedRunConfiguration(Core::Id id);
+ ~RunWorkerFactory();
+ bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const;
WorkerCreator producer() const { return m_producer; }
-private:
- // FIXME: That's temporary until ownership has been transferred to
- // the individual plugins.
- friend class ProjectExplorerPlugin;
- static void destroyRemainingRunWorkerFactories();
+ template <typename Worker>
+ static WorkerCreator make()
+ {
+ return [](RunControl *runControl) { return new Worker(runControl); };
+ }
+private:
+ WorkerCreator m_producer;
QList<Core::Id> m_supportedRunModes;
QList<Core::Id> m_supportedRunConfigurations;
- QList<Constraint> m_constraints;
- WorkerCreator m_producer;
+ QList<Core::Id> m_supportedDeviceTypes;
};
/**
@@ -258,19 +251,10 @@ public:
RunWorker *createWorker(Core::Id id);
using WorkerCreator = RunWorkerFactory::WorkerCreator;
- using Constraint = RunWorkerFactory::Constraint;
+ using Constraint = std::function<bool(RunConfiguration *)>;
static void registerWorkerCreator(Core::Id id, const WorkerCreator &workerCreator);
- template <class Worker>
- static void registerWorker(Core::Id runMode, const Constraint &constraint)
- {
- auto factory = new RunWorkerFactory;
- factory->setProducer([](RunControl *rc) { return new Worker(rc); });
- factory->addSupportedRunMode(runMode);
- factory->addConstraint(constraint);
- }
-
bool createMainWorker();
static bool canRun(RunConfiguration *runConfig, Core::Id runMode);
@@ -325,20 +309,4 @@ private:
bool m_useTerminal = false;
};
-template <class RunWorker, class RunConfig>
-class SimpleRunWorkerFactory : public RunWorkerFactory
-{
-public:
- SimpleRunWorkerFactory(Core::Id runMode = ProjectExplorer::Constants::NORMAL_RUN_MODE)
- {
- addSupportedRunMode(runMode);
- addConstraint([](RunConfiguration *runConfig) {
- return qobject_cast<RunConfig *>(runConfig) != nullptr;
- });
- setProducer([](RunControl *runControl) {
- return new RunWorker(runControl);
- });
- }
-};
-
} // namespace ProjectExplorer