1 |
#ifndef WIZARDFACTORY_H |
2 |
#define WIZARDFACTORY_H |
3 |
|
4 |
#include "soundwizard.h" |
5 |
|
6 |
// This template class allows us to create wizards in the heap which auto-delete themselves once finished |
7 |
template<typename T> |
8 |
class WizardFactory : public T |
9 |
{ |
10 |
public: |
11 |
static void startInstance(const QString &appDir, const QString &workspaceWizardLocation, QSettings *vagoSettings){ |
12 |
(new WizardFactory<T>(appDir, workspaceWizardLocation, vagoSettings))->exec(); |
13 |
} |
14 |
private: |
15 |
// We need to have a constructor to be able to acess "exec" protected function |
16 |
WizardFactory |
17 |
( |
18 |
const QString &appDir, |
19 |
const QString &workspaceWizardLocation, |
20 |
QSettings *vagoSettings |
21 |
):T(appDir, workspaceWizardLocation, vagoSettings){} |
22 |
}; |
23 |
|
24 |
// Specialization for SoundWizard (it receives extra variables) |
25 |
template<> |
26 |
class WizardFactory<SoundWizard> : public SoundWizard |
27 |
{ |
28 |
public: |
29 |
static void startInstance(const QString &appDir, const QString &workspaceWizardLocation, QSettings *vagoSettings, QHash<QString, QString> *commandMap){ |
30 |
(new WizardFactory(appDir, workspaceWizardLocation, vagoSettings, commandMap))->exec(); |
31 |
} |
32 |
private: |
33 |
WizardFactory |
34 |
( |
35 |
const QString &appDir, |
36 |
const QString &workspaceWizardLocation, |
37 |
QSettings *vagoSettings, |
38 |
QHash<QString, QString> *commandMap |
39 |
):SoundWizard(appDir, workspaceWizardLocation, vagoSettings, commandMap){} |
40 |
}; |
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
#endif // WIZARDFACTORY_H |