ProjectExplorer: Provide a way to extend RunWorkerFactory

In the light of docker support it would be nice to have a way
to tell existing RunWorkerFactories that they also work for
docker, or generally to increase the scope to which they apply
after construction time.

Small con: Some more boiler plate,
Small pros: Setup using the new method looks similar to what we use
in the other factories, and the Factories types are recognizable
when debugging.

Change-Id: Idb1757f519e7151b835326aa8b98aeaa4a372cc4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2021-06-17 12:46:21 +02:00
parent c533e5c43c
commit de6c7696d2
5 changed files with 55 additions and 11 deletions

View File

@@ -80,6 +80,11 @@ static QList<RunWorkerFactory *> g_runWorkerFactories;
static QSet<Utils::Id> g_runModes;
static QSet<Utils::Id> g_runConfigs;
RunWorkerFactory::RunWorkerFactory()
{
g_runWorkerFactories.append(this);
}
RunWorkerFactory::RunWorkerFactory(const WorkerCreator &producer,
const QList<Utils::Id> &runModes,
const QList<Utils::Id> &runConfigs,
@@ -103,6 +108,26 @@ RunWorkerFactory::~RunWorkerFactory()
g_runWorkerFactories.removeOne(this);
}
void RunWorkerFactory::setProducer(const WorkerCreator &producer)
{
m_producer = producer;
}
void RunWorkerFactory::addSupportedRunMode(Utils::Id runMode)
{
m_supportedRunModes.append(runMode);
}
void RunWorkerFactory::addSupportedRunConfig(Utils::Id runConfig)
{
m_supportedRunConfigurations.append(runConfig);
}
void RunWorkerFactory::addSupportedDeviceType(Utils::Id deviceType)
{
m_supportedDeviceTypes.append(deviceType);
}
bool RunWorkerFactory::canRun(Utils::Id runMode,
Utils::Id deviceType,
const QString &runConfigId) const