summaryrefslogtreecommitdiff
path: root/src/sound
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-11-25 14:26:46 +0000
committerrubidium <rubidium@openttd.org>2013-11-25 14:26:46 +0000
commit6996b441d9d104bc6d7041b64362f4426425f600 (patch)
tree074989fd03a7f672e137423688c40d1efc466a95 /src/sound
parenta399fc667ce506abcdcfd853d1ad58f0bb8dbb4f (diff)
downloadopenttd-6996b441d9d104bc6d7041b64362f4426425f600.tar.xz
(svn r26107) -Codechange/cleanup: remove some coding bloat and simplify the driver factory instatiations
Diffstat (limited to 'src/sound')
-rw-r--r--src/sound/allegro_s.h8
-rw-r--r--src/sound/cocoa_s.h8
-rw-r--r--src/sound/null_s.h8
-rw-r--r--src/sound/sdl_s.h8
-rw-r--r--src/sound/sound_driver.hpp19
-rw-r--r--src/sound/win32_s.h8
6 files changed, 15 insertions, 44 deletions
diff --git a/src/sound/allegro_s.h b/src/sound/allegro_s.h
index 315bad2a8..269a1a030 100644
--- a/src/sound/allegro_s.h
+++ b/src/sound/allegro_s.h
@@ -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 */
diff --git a/src/sound/cocoa_s.h b/src/sound/cocoa_s.h
index 7492164c5..a85748bc2 100644
--- a/src/sound/cocoa_s.h
+++ b/src/sound/cocoa_s.h
@@ -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 */
diff --git a/src/sound/null_s.h b/src/sound/null_s.h
index 5951842cb..a2714d86d 100644
--- a/src/sound/null_s.h
+++ b/src/sound/null_s.h
@@ -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 */
diff --git a/src/sound/sdl_s.h b/src/sound/sdl_s.h
index 6733ee6a7..60cf11838 100644
--- a/src/sound/sdl_s.h
+++ b/src/sound/sdl_s.h
@@ -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 */
diff --git a/src/sound/sound_driver.hpp b/src/sound/sound_driver.hpp
index 56664e6ad..badfabd93 100644
--- a/src/sound/sound_driver.hpp
+++ b/src/sound/sound_driver.hpp
@@ -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;
diff --git a/src/sound/win32_s.h b/src/sound/win32_s.h
index 03af04a53..f76849b15 100644
--- a/src/sound/win32_s.h
+++ b/src/sound/win32_s.h
@@ -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 */