summaryrefslogtreecommitdiff
path: root/src/music
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/music
parenta399fc667ce506abcdcfd853d1ad58f0bb8dbb4f (diff)
downloadopenttd-6996b441d9d104bc6d7041b64362f4426425f600.tar.xz
(svn r26107) -Codechange/cleanup: remove some coding bloat and simplify the driver factory instatiations
Diffstat (limited to 'src/music')
-rw-r--r--src/music/allegro_m.h12
-rw-r--r--src/music/bemidi.h8
-rw-r--r--src/music/cocoa_m.h8
-rw-r--r--src/music/dmusic.h8
-rw-r--r--src/music/extmidi.h8
-rw-r--r--src/music/libtimidity.h8
-rw-r--r--src/music/music_driver.hpp19
-rw-r--r--src/music/null_m.h8
-rw-r--r--src/music/os2_m.h8
-rw-r--r--src/music/qtmidi.h8
-rw-r--r--src/music/win32_m.h8
11 files changed, 32 insertions, 71 deletions
diff --git a/src/music/allegro_m.h b/src/music/allegro_m.h
index 2160c396e..e7cade350 100644
--- a/src/music/allegro_m.h
+++ b/src/music/allegro_m.h
@@ -32,20 +32,18 @@ public:
};
/** Factory for allegro's music player. */
-class FMusicDriver_Allegro: public MusicDriverFactory<FMusicDriver_Allegro> {
+class FMusicDriver_Allegro : public DriverFactoryBase {
public:
#if !defined(WITH_SDL) && defined(WITH_ALLEGRO)
/* If SDL is not compiled in but Allegro is, chances are quite big
* that Allegro is going to be used. Then favour this sound driver
* over extmidi because with extmidi we get crashes. */
- static const int priority = 9;
+ static const int PRIORITY = 9;
#else
- static const int priority = 2;
+ static const int PRIORITY = 2;
#endif
-
- /* virtual */ const char *GetName() { return "allegro"; }
- /* virtual */ const char *GetDescription() { return "Allegro MIDI Driver"; }
- /* virtual */ Driver *CreateInstance() { return new MusicDriver_Allegro(); }
+ FMusicDriver_Allegro() : DriverFactoryBase(Driver::DT_MUSIC, PRIORITY, "allegro", "Allegro MIDI Driver") {}
+ /* virtual */ Driver *CreateInstance() const { return new MusicDriver_Allegro(); }
};
#endif /* MUSIC_ALLEGRO_H */
diff --git a/src/music/bemidi.h b/src/music/bemidi.h
index 1b280e667..b261ec59f 100644
--- a/src/music/bemidi.h
+++ b/src/music/bemidi.h
@@ -32,12 +32,10 @@ public:
};
/** Factory for the BeOS midi player. */
-class FMusicDriver_BeMidi: public MusicDriverFactory<FMusicDriver_BeMidi> {
+class FMusicDriver_BeMidi : public DriverFactoryBase {
public:
- static const int priority = 10;
- /* virtual */ const char *GetName() { return "bemidi"; }
- /* virtual */ const char *GetDescription() { return "BeOS MIDI Driver"; }
- /* virtual */ Driver *CreateInstance() { return new MusicDriver_BeMidi(); }
+ FMusicDriver_BeMidi() : DriverFactoryBase(Driver::DT_MUSIC, 10, "bemidi", "BeOS MIDI Driver") {}
+ /* virtual */ Driver *CreateInstance() const { return new MusicDriver_BeMidi(); }
};
#endif /* MUSIC_BEMIDI_H */
diff --git a/src/music/cocoa_m.h b/src/music/cocoa_m.h
index f3cff9db8..00bdc6b62 100644
--- a/src/music/cocoa_m.h
+++ b/src/music/cocoa_m.h
@@ -30,12 +30,10 @@ public:
/* virtual */ const char *GetName() const { return "cocoa"; }
};
-class FMusicDriver_Cocoa: public MusicDriverFactory<FMusicDriver_Cocoa> {
+class FMusicDriver_Cocoa : public DriverFactoryBase {
public:
- static const int priority = 10;
- /* virtual */ const char *GetName() { return "cocoa"; }
- /* virtual */ const char *GetDescription() { return "Cocoa MIDI Driver"; }
- /* virtual */ Driver *CreateInstance() { return new MusicDriver_Cocoa(); }
+ FMusicDriver_Cocoa() : DriverFactoryBase(Driver::DT_MUSIC, 10, "cocoa", "Cocoa MIDI Driver") {}
+ /* virtual */ Driver *CreateInstance() const { return new MusicDriver_Cocoa(); }
};
#endif /* MUSIC_MACOSX_COCOA_H */
diff --git a/src/music/dmusic.h b/src/music/dmusic.h
index 29eee8ed0..22a758daf 100644
--- a/src/music/dmusic.h
+++ b/src/music/dmusic.h
@@ -34,12 +34,10 @@ public:
};
/** Factory for the DirectX music player. */
-class FMusicDriver_DMusic: public MusicDriverFactory<FMusicDriver_DMusic> {
+class FMusicDriver_DMusic : public DriverFactoryBase {
public:
- static const int priority = 10;
- /* virtual */ const char *GetName() { return "dmusic"; }
- /* virtual */ const char *GetDescription() { return "DirectMusic MIDI Driver"; }
- /* virtual */ Driver *CreateInstance() { return new MusicDriver_DMusic(); }
+ FMusicDriver_DMusic() : DriverFactoryBase(Driver::DT_MUSIC, 10, "dmusic", "DirectMusic MIDI Driver") {}
+ /* virtual */ Driver *CreateInstance() const { return new MusicDriver_DMusic(); }
};
#endif /* MUSIC_DMUSIC_H */
diff --git a/src/music/extmidi.h b/src/music/extmidi.h
index 1638c78f5..8f5dd31c7 100644
--- a/src/music/extmidi.h
+++ b/src/music/extmidi.h
@@ -38,12 +38,10 @@ public:
/* virtual */ const char *GetName() const { return "extmidi"; }
};
-class FMusicDriver_ExtMidi: public MusicDriverFactory<FMusicDriver_ExtMidi> {
+class FMusicDriver_ExtMidi : public DriverFactoryBase {
public:
- static const int priority = 3;
- /* virtual */ const char *GetName() { return "extmidi"; }
- /* virtual */ const char *GetDescription() { return "External MIDI Driver"; }
- /* virtual */ Driver *CreateInstance() { return new MusicDriver_ExtMidi(); }
+ FMusicDriver_ExtMidi() : DriverFactoryBase(Driver::DT_MUSIC, 3, "extmidi", "External MIDI Driver") {}
+ /* virtual */ Driver *CreateInstance() const { return new MusicDriver_ExtMidi(); }
};
#endif /* MUSIC_EXTERNAL_H */
diff --git a/src/music/libtimidity.h b/src/music/libtimidity.h
index 4f9343619..7fc667e3a 100644
--- a/src/music/libtimidity.h
+++ b/src/music/libtimidity.h
@@ -32,12 +32,10 @@ public:
};
/** Factory for the libtimidity driver. */
-class FMusicDriver_LibTimidity: public MusicDriverFactory<FMusicDriver_LibTimidity> {
+class FMusicDriver_LibTimidity : public DriverFactoryBase {
public:
- static const int priority = 5;
- /* virtual */ const char *GetName() { return "libtimidity"; }
- /* virtual */ const char *GetDescription() { return "LibTimidity MIDI Driver"; }
- /* virtual */ Driver *CreateInstance() { return new MusicDriver_LibTimidity(); }
+ FMusicDriver_LibTimidity() : DriverFactoryBase(Driver::DT_MUSIC, 5, "libtimidity", "LibTimidity MIDI Driver") {}
+ /* virtual */ Driver *CreateInstance() const { return new MusicDriver_LibTimidity(); }
};
#endif /* MUSIC_LIBTIMIDITY_H */
diff --git a/src/music/music_driver.hpp b/src/music/music_driver.hpp
index 70a1e37a5..453d05102 100644
--- a/src/music/music_driver.hpp
+++ b/src/music/music_driver.hpp
@@ -41,25 +41,6 @@ public:
virtual void SetVolume(byte vol) = 0;
};
-/** Base of the factory for the music drivers. */
-class MusicDriverFactoryBase: public DriverFactoryBase {
-};
-
-/**
- * Factory for the music drivers.
- * @tparam T The type of the music factory to register.
- */
-template <class T>
-class MusicDriverFactory: public MusicDriverFactoryBase {
-public:
- MusicDriverFactory() { this->RegisterDriver(((T *)this)->GetName(), Driver::DT_MUSIC, ((T *)this)->priority); }
-
- /**
- * Get the long, human readable, name for the Driver-class.
- */
- const char *GetName();
-};
-
extern MusicDriver *_music_driver;
extern char *_ini_musicdriver;
diff --git a/src/music/null_m.h b/src/music/null_m.h
index babfd3775..d7b41d53e 100644
--- a/src/music/null_m.h
+++ b/src/music/null_m.h
@@ -32,12 +32,10 @@ public:
};
/** Factory for the null music player. */
-class FMusicDriver_Null: public MusicDriverFactory<FMusicDriver_Null> {
+class FMusicDriver_Null : public DriverFactoryBase {
public:
- static const int priority = 1;
- /* virtual */ const char *GetName() { return "null"; }
- /* virtual */ const char *GetDescription() { return "Null Music Driver"; }
- /* virtual */ Driver *CreateInstance() { return new MusicDriver_Null(); }
+ FMusicDriver_Null() : DriverFactoryBase(Driver::DT_MUSIC, 1, "null", "Null Music Driver") {}
+ /* virtual */ Driver *CreateInstance() const { return new MusicDriver_Null(); }
};
#endif /* MUSIC_NULL_H */
diff --git a/src/music/os2_m.h b/src/music/os2_m.h
index 054526e59..91ccf5a00 100644
--- a/src/music/os2_m.h
+++ b/src/music/os2_m.h
@@ -32,12 +32,10 @@ public:
};
/** Factory for OS/2's music player. */
-class FMusicDriver_OS2: public MusicDriverFactory<FMusicDriver_OS2> {
+class FMusicDriver_OS2 : public DriverFactoryBase {
public:
- static const int priority = 10;
- /* virtual */ const char *GetName() { return "os2"; }
- /* virtual */ const char *GetDescription() { return "OS/2 Music Driver"; }
- /* virtual */ Driver *CreateInstance() { return new MusicDriver_OS2(); }
+ FMusicDriver_OS2() : DriverFactoryBase(Driver::DT_MUSIC, 10, "os2", "OS/2 Music Driver") {}
+ /* virtual */ Driver *CreateInstance() const { return new MusicDriver_OS2(); }
};
#endif /* MUSIC_OS2_H */
diff --git a/src/music/qtmidi.h b/src/music/qtmidi.h
index 806a3c196..d8ecaf1fe 100644
--- a/src/music/qtmidi.h
+++ b/src/music/qtmidi.h
@@ -30,12 +30,10 @@ public:
/* virtual */ const char *GetName() const { return "qt"; }
};
-class FMusicDriver_QtMidi: public MusicDriverFactory<FMusicDriver_QtMidi> {
+class FMusicDriver_QtMidi : public DriverFactoryBase {
public:
- static const int priority = 5;
- /* virtual */ const char *GetName() { return "qt"; }
- /* virtual */ const char *GetDescription() { return "QuickTime MIDI Driver"; }
- /* virtual */ Driver *CreateInstance() { return new MusicDriver_QtMidi(); }
+ FMusicDriver_QtMidi() : DriverFactoryBase(Driver::DT_MUSIC, 5, "qt", "QuickTime MIDI Driver") {}
+ /* virtual */ Driver *CreateInstance() const { return new MusicDriver_QtMidi(); }
};
#endif /* MUSIC_MACOSX_QUICKTIME_H */
diff --git a/src/music/win32_m.h b/src/music/win32_m.h
index cf46fbc15..b59298d01 100644
--- a/src/music/win32_m.h
+++ b/src/music/win32_m.h
@@ -32,12 +32,10 @@ public:
};
/** Factory for Windows' music player. */
-class FMusicDriver_Win32: public MusicDriverFactory<FMusicDriver_Win32> {
+class FMusicDriver_Win32 : public DriverFactoryBase {
public:
- static const int priority = 5;
- /* virtual */ const char *GetName() { return "win32"; }
- /* virtual */ const char *GetDescription() { return "Win32 Music Driver"; }
- /* virtual */ Driver *CreateInstance() { return new MusicDriver_Win32(); }
+ FMusicDriver_Win32() : DriverFactoryBase(Driver::DT_MUSIC, 5, "win32", "Win32 Music Driver") {}
+ /* virtual */ Driver *CreateInstance() const { return new MusicDriver_Win32(); }
};
#endif /* MUSIC_WIN32_H */