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, Logger *myLogger){ |
12 |
(new WizardFactory<T>(appDir, workspaceWizardLocation, vagoSettings, myLogger))->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 |
Logger *myLogger |
22 |
):T(appDir, workspaceWizardLocation, vagoSettings, myLogger){} |
23 |
}; |
24 |
|
25 |
// Specialization for SoundWizard (it receives extra variables) |
26 |
template<> |
27 |
class WizardFactory<SoundWizard> : public SoundWizard |
28 |
{ |
29 |
public: |
30 |
static void startInstance(const QString &appDir, const QString &workspaceWizardLocation, QSettings *vagoSettings, Logger *myLogger, QHash<QString, QString> *commandMap){ |
31 |
(new WizardFactory(appDir, workspaceWizardLocation, vagoSettings, myLogger, commandMap))->exec(); |
32 |
} |
33 |
private: |
34 |
WizardFactory |
35 |
( |
36 |
const QString &appDir, |
37 |
const QString &workspaceWizardLocation, |
38 |
QSettings *vagoSettings, |
39 |
Logger *myLogger, |
40 |
QHash<QString, QString> *commandMap |
41 |
):SoundWizard(appDir, workspaceWizardLocation, vagoSettings, myLogger, commandMap){} |
42 |
}; |
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
#endif // WIZARDFACTORY_H |