RemoteLinux: Pimple and avoid unneeded use of global object pool

Following the now-canonical HelpPlugin pattern...

Change-Id: I2c02b3dee7238da9fb1e3a9b29afb4cd32424cb8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2018-02-02 18:23:41 +01:00
parent ba17b58ede
commit 6cfde4c2ed
2 changed files with 34 additions and 30 deletions

View File

@@ -42,16 +42,16 @@
#include "tarpackagecreationstep.h"
#include "uploadandinstalltarpackagestep.h"
#include <QtPlugin>
using namespace ProjectExplorer;
namespace RemoteLinux {
namespace Internal {
template <class Step>
class GenericLinuxDeployStepFactory : public ProjectExplorer::BuildStepFactory
class GenericDeployStepFactory : public ProjectExplorer::BuildStepFactory
{
public:
GenericLinuxDeployStepFactory()
GenericDeployStepFactory()
{
registerStep<Step>(Step::stepId());
setDisplayName(Step::displayName());
@@ -60,19 +60,43 @@ public:
}
};
class RemoteLinuxPluginPrivate
{
public:
GenericLinuxDeviceConfigurationFactory deviceConfigurationFactory;
RemoteLinuxRunConfigurationFactory runConfigurationFactory;
RemoteLinuxCustomRunConfigurationFactory customRunConfigurationFactory;
RemoteLinuxDeployConfigurationFactory deployConfigurationFactory;
GenericDeployStepFactory<TarPackageCreationStep> tarPackageCreationStepFactory;
GenericDeployStepFactory<UploadAndInstallTarPackageStep> uploadAndInstallTarPackageStepFactory;
GenericDeployStepFactory<GenericDirectUploadStep> genericDirectUploadStepFactory;
GenericDeployStepFactory<GenericRemoteLinuxCustomCommandDeploymentStep>
customCommandDeploymentStepFactory;
GenericDeployStepFactory<RemoteLinuxCheckForFreeDiskSpaceStep>
checkForFreeDiskSpaceStepFactory;
GenericDeployStepFactory<RemoteLinuxKillAppStep> remoteLinuxKillAppStepFactory;
EmbeddedLinuxQtVersionFactory embeddedLinuxQtVersionFactory;
};
static RemoteLinuxPluginPrivate *dd = nullptr;
RemoteLinuxPlugin::RemoteLinuxPlugin()
{
setObjectName(QLatin1String("RemoteLinuxPlugin"));
}
RemoteLinuxPlugin::~RemoteLinuxPlugin()
{
delete dd;
}
bool RemoteLinuxPlugin::initialize(const QStringList &arguments,
QString *errorMessage)
{
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
using namespace ProjectExplorer;
using namespace ProjectExplorer::Constants;
dd = new RemoteLinuxPluginPrivate;
auto constraint = [](RunConfiguration *runConfig) {
const Core::Id id = runConfig->id();
@@ -80,35 +104,14 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments,
|| id.name().startsWith(RemoteLinuxRunConfiguration::IdPrefix);
};
using namespace ProjectExplorer::Constants;
RunControl::registerWorker<SimpleTargetRunner>(NORMAL_RUN_MODE, constraint);
RunControl::registerWorker<LinuxDeviceDebugSupport>(DEBUG_RUN_MODE, constraint);
RunControl::registerWorker<RemoteLinuxQmlProfilerSupport>(QML_PROFILER_RUN_MODE, constraint);
RunControl::registerWorker<RemoteLinuxQmlPreviewSupport>(QML_PREVIEW_RUN_MODE, constraint);
addAutoReleasedObject(new GenericLinuxDeviceConfigurationFactory);
addAutoReleasedObject(new RemoteLinuxRunConfigurationFactory);
addAutoReleasedObject(new RemoteLinuxCustomRunConfigurationFactory);
addAutoReleasedObject(new RemoteLinuxDeployConfigurationFactory);
addAutoReleasedObject(new GenericLinuxDeployStepFactory<TarPackageCreationStep>);
addAutoReleasedObject(new GenericLinuxDeployStepFactory<UploadAndInstallTarPackageStep>);
addAutoReleasedObject(new GenericLinuxDeployStepFactory<GenericDirectUploadStep>);
addAutoReleasedObject(new GenericLinuxDeployStepFactory
<GenericRemoteLinuxCustomCommandDeploymentStep>);
addAutoReleasedObject(new GenericLinuxDeployStepFactory<RemoteLinuxCheckForFreeDiskSpaceStep>);
addAutoReleasedObject(new GenericLinuxDeployStepFactory<RemoteLinuxKillAppStep>);
addAutoReleasedObject(new EmbeddedLinuxQtVersionFactory);
return true;
}
RemoteLinuxPlugin::~RemoteLinuxPlugin()
{
}
void RemoteLinuxPlugin::extensionsInitialized()
{
}
} // namespace Internal
} // namespace RemoteLinux

View File

@@ -37,10 +37,11 @@ class RemoteLinuxPlugin : public ExtensionSystem::IPlugin
public:
RemoteLinuxPlugin();
~RemoteLinuxPlugin();
~RemoteLinuxPlugin() final;
bool initialize(const QStringList &arguments, QString *errorMessage);
void extensionsInitialized();
private:
bool initialize(const QStringList &arguments, QString *errorMessage) final;
void extensionsInitialized() final {}
};
} // namespace Internal