(svn r26107) -Codechange/cleanup: remove some coding bloat and simplify the driver factory instatiations

This commit is contained in:
rubidium
2013-11-25 14:26:46 +00:00
parent e12e78b95b
commit f843a0b5d9
27 changed files with 101 additions and 208 deletions

View File

@@ -26,12 +26,10 @@ public:
};
/** Factory for the allegro sound driver. */
class FSoundDriver_Allegro: public SoundDriverFactory<FSoundDriver_Allegro> {
class FSoundDriver_Allegro : public DriverFactoryBase {
public:
static const int priority = 4;
/* virtual */ const char *GetName() { return "allegro"; }
/* virtual */ const char *GetDescription() { return "Allegro Sound Driver"; }
/* virtual */ Driver *CreateInstance() { return new SoundDriver_Allegro(); }
FSoundDriver_Allegro() : DriverFactoryBase(Driver::DT_SOUND, 4, "allegro", "Allegro Sound Driver") {}
/* virtual */ Driver *CreateInstance() const { return new SoundDriver_Allegro(); }
};
#endif /* SOUND_ALLEGRO_H */

View File

@@ -22,12 +22,10 @@ public:
/* virtual */ const char *GetName() const { return "cocoa"; }
};
class FSoundDriver_Cocoa: public SoundDriverFactory<FSoundDriver_Cocoa> {
class FSoundDriver_Cocoa : public DriverFactoryBase {
public:
static const int priority = 10;
/* virtual */ const char *GetName() { return "cocoa"; }
/* virtual */ const char *GetDescription() { return "Cocoa Sound Driver"; }
/* virtual */ Driver *CreateInstance() { return new SoundDriver_Cocoa(); }
FSoundDriver_Cocoa() : DriverFactoryBase(Driver::DT_SOUND, 10, "cocoa", "Cocoa Sound Driver") {}
/* virtual */ Driver *CreateInstance() const { return new SoundDriver_Cocoa(); }
};
#endif /* SOUND_COCOA_H */

View File

@@ -24,12 +24,10 @@ public:
};
/** Factory for the null sound driver. */
class FSoundDriver_Null: public SoundDriverFactory<FSoundDriver_Null> {
class FSoundDriver_Null : public DriverFactoryBase {
public:
static const int priority = 1;
/* virtual */ const char *GetName() { return "null"; }
/* virtual */ const char *GetDescription() { return "Null Sound Driver"; }
/* virtual */ Driver *CreateInstance() { return new SoundDriver_Null(); }
FSoundDriver_Null() : DriverFactoryBase(Driver::DT_SOUND, 1, "null", "Null Sound Driver") {}
/* virtual */ Driver *CreateInstance() const { return new SoundDriver_Null(); }
};
#endif /* SOUND_NULL_H */

View File

@@ -24,12 +24,10 @@ public:
};
/** Factory for the SDL sound driver. */
class FSoundDriver_SDL: public SoundDriverFactory<FSoundDriver_SDL> {
class FSoundDriver_SDL : public DriverFactoryBase {
public:
static const int priority = 5;
/* virtual */ const char *GetName() { return "sdl"; }
/* virtual */ const char *GetDescription() { return "SDL Sound Driver"; }
/* virtual */ Driver *CreateInstance() { return new SoundDriver_SDL(); }
FSoundDriver_SDL() : DriverFactoryBase(Driver::DT_SOUND, 5, "sdl", "SDL Sound Driver") {}
/* virtual */ Driver *CreateInstance() const { return new SoundDriver_SDL(); }
};
#endif /* SOUND_SDL_H */

View File

@@ -21,25 +21,6 @@ public:
virtual void MainLoop() {}
};
/** Base of the factory for the sound drivers. */
class SoundDriverFactoryBase: public DriverFactoryBase {
};
/**
* Factory for the sound drivers.
* @tparam T The type of the sound factory to register.
*/
template <class T>
class SoundDriverFactory: public SoundDriverFactoryBase {
public:
SoundDriverFactory() { this->RegisterDriver(((T *)this)->GetName(), Driver::DT_SOUND, ((T *)this)->priority); }
/**
* Get the long, human readable, name for the Driver-class.
*/
const char *GetName();
};
extern SoundDriver *_sound_driver;
extern char *_ini_sounddriver;

View File

@@ -24,12 +24,10 @@ public:
};
/** Factory for the sound driver for Windows. */
class FSoundDriver_Win32: public SoundDriverFactory<FSoundDriver_Win32> {
class FSoundDriver_Win32 : public DriverFactoryBase {
public:
static const int priority = 10;
/* virtual */ const char *GetName() { return "win32"; }
/* virtual */ const char *GetDescription() { return "Win32 WaveOut Driver"; }
/* virtual */ Driver *CreateInstance() { return new SoundDriver_Win32(); }
FSoundDriver_Win32() : DriverFactoryBase(Driver::DT_SOUND, 10, "win32", "Win32 WaveOut Sound Driver") {}
/* virtual */ Driver *CreateInstance() const { return new SoundDriver_Win32(); }
};
#endif /* SOUND_WIN32_H */