Changeset - r21027:e87e97e6befd
[Not reviewed]
master
0 27 0
rubidium - 11 years ago 2013-11-25 14:26:46
rubidium@openttd.org
(svn r26107) -Codechange/cleanup: remove some coding bloat and simplify the driver factory instatiations
27 files changed with 101 insertions and 208 deletions:
0 comments (0 inline, 0 general)
src/driver.cpp
Show inline comments
 
@@ -165,33 +165,6 @@ Driver *DriverFactoryBase::SelectDriver(
 
}
 

	
 
/**
 
 * Register a driver internally, based on its name.
 
 * @param name the name of the driver.
 
 * @param type the type of driver to register
 
 * @param priority the priority; how badly do we want this as default?
 
 * @note an assert() will be trigger if 2 driver with the same name try to register.
 
 */
 
void DriverFactoryBase::RegisterDriver(const char *name, Driver::Type type, int priority)
 
{
 
	/* Don't register nameless Drivers */
 
	if (name == NULL) return;
 

	
 
	this->name = strdup(name);
 
	this->type = type;
 
	this->priority = priority;
 

	
 
	/* Prefix the name with driver type to make it unique */
 
	char buf[32];
 
	strecpy(buf, GetDriverTypeName(type), lastof(buf));
 
	strecpy(buf + 5, name, lastof(buf));
 

	
 
	const char *longname = strdup(buf);
 

	
 
	std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(longname, this));
 
	assert(P.second);
 
}
 

	
 
/**
 
 * Build a human readable list of available drivers, grouped by type.
 
 * @param p The buffer to write to.
 
 * @param last The last element in the buffer.
 
@@ -219,12 +192,31 @@ char *DriverFactoryBase::GetDriversInfo(
 
}
 

	
 
/**
 
 * Construct a new DriverFactory.
 
 * @param type        The type of driver.
 
 * @param priority    The priority within the driver class.
 
 * @param name        The name of the driver.
 
 * @param description A long-ish description of the driver.
 
 */
 
DriverFactoryBase::DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description) :
 
	type(type), priority(priority), name(name), description(description)
 
{
 
	/* Prefix the name with driver type to make it unique */
 
	char buf[32];
 
	strecpy(buf, GetDriverTypeName(type), lastof(buf));
 
	strecpy(buf + 5, name, lastof(buf));
 

	
 
	const char *longname = strdup(buf);
 

	
 
	std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(longname, this));
 
	assert(P.second);
 
}
 

	
 
/**
 
 * Frees memory used for this->name
 
 */
 
DriverFactoryBase::~DriverFactoryBase()
 
{
 
	if (this->name == NULL) return;
 

	
 
	/* Prefix the name with driver type to make it unique */
 
	char buf[32];
 
	strecpy(buf, GetDriverTypeName(type), lastof(buf));
 
@@ -239,5 +231,4 @@ DriverFactoryBase::~DriverFactoryBase()
 
	free(longname);
 

	
 
	if (GetDrivers().empty()) delete &GetDrivers();
 
	free(this->name);
 
}
src/driver.h
Show inline comments
 
@@ -60,8 +60,9 @@ DECLARE_POSTFIX_INCREMENT(Driver::Type)
 
class DriverFactoryBase {
 
private:
 
	Driver::Type type; ///< The type of driver.
 
	int priority;            ///< The priority of this factory.
 
	const char *name;  ///< The name of the drivers of this factory.
 
	int priority;      ///< The priority of this factory.
 
	const char *description; ///< The description of this driver.
 

	
 
	typedef std::map<const char *, DriverFactoryBase *, StringCompare> Drivers; ///< Type for a map of drivers.
 

	
 
@@ -97,15 +98,11 @@ private:
 
	}
 

	
 
protected:
 
	void RegisterDriver(const char *name, Driver::Type type, int priority);
 

	
 
public:
 
	DriverFactoryBase() :
 
		name(NULL)
 
	{}
 
	DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description);
 

	
 
	virtual ~DriverFactoryBase();
 

	
 
public:
 
	/**
 
	 * Shuts down all active drivers
 
	 */
 
@@ -124,13 +121,16 @@ public:
 
	 * Get a nice description of the driver-class.
 
	 * @return The description.
 
	 */
 
	virtual const char *GetDescription() = 0;
 
	const char *GetDescription() const
 
	{
 
		return this->description;
 
	}
 

	
 
	/**
 
	 * Create an instance of this driver-class.
 
	 * @return The instance.
 
	 */
 
	virtual Driver *CreateInstance() = 0;
 
	virtual Driver *CreateInstance() const = 0;
 
};
 

	
 
#endif /* DRIVER_H */
src/music/allegro_m.h
Show inline comments
 
@@ -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 */
src/music/bemidi.h
Show inline comments
 
@@ -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 */
src/music/cocoa_m.h
Show inline comments
 
@@ -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 */
src/music/dmusic.h
Show inline comments
 
@@ -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 */
src/music/extmidi.h
Show inline comments
 
@@ -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 */
src/music/libtimidity.h
Show inline comments
 
@@ -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 */
src/music/music_driver.hpp
Show inline comments
 
@@ -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;
 

	
src/music/null_m.h
Show inline comments
 
@@ -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 */
src/music/os2_m.h
Show inline comments
 
@@ -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 */
src/music/qtmidi.h
Show inline comments
 
@@ -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 */
src/music/win32_m.h
Show inline comments
 
@@ -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 */
src/openttd.cpp
Show inline comments
 
@@ -190,7 +190,7 @@ static void ShowHelp()
 
	p = BaseMusic::GetSetsList(p, lastof(buf));
 

	
 
	/* List the drivers */
 
	p = VideoDriverFactoryBase::GetDriversInfo(p, lastof(buf));
 
	p = DriverFactoryBase::GetDriversInfo(p, lastof(buf));
 

	
 
	/* List the blitters */
 
	p = BlitterFactoryBase::GetBlittersInfo(p, lastof(buf));
 
@@ -767,7 +767,7 @@ int openttd_main(int argc, char *argv[])
 
	free(blitter);
 

	
 
	if (videodriver == NULL && _ini_videodriver != NULL) videodriver = strdup(_ini_videodriver);
 
	_video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
 
	_video_driver = (VideoDriver*)DriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
 
	if (_video_driver == NULL) {
 
		StrEmpty(videodriver) ?
 
			usererror("Failed to autoprobe video driver") :
 
@@ -833,7 +833,7 @@ int openttd_main(int argc, char *argv[])
 
	free(music_set);
 

	
 
	if (sounddriver == NULL && _ini_sounddriver != NULL) sounddriver = strdup(_ini_sounddriver);
 
	_sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND);
 
	_sound_driver = (SoundDriver*)DriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND);
 
	if (_sound_driver == NULL) {
 
		StrEmpty(sounddriver) ?
 
			usererror("Failed to autoprobe sound driver") :
 
@@ -842,7 +842,7 @@ int openttd_main(int argc, char *argv[])
 
	free(sounddriver);
 

	
 
	if (musicdriver == NULL && _ini_musicdriver != NULL) musicdriver = strdup(_ini_musicdriver);
 
	_music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
 
	_music_driver = (MusicDriver*)DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
 
	if (_music_driver == NULL) {
 
		StrEmpty(musicdriver) ?
 
			usererror("Failed to autoprobe music driver") :
src/sound/allegro_s.h
Show inline comments
 
@@ -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 */
src/sound/cocoa_s.h
Show inline comments
 
@@ -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 */
src/sound/null_s.h
Show inline comments
 
@@ -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 */
src/sound/sdl_s.h
Show inline comments
 
@@ -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 */
src/sound/sound_driver.hpp
Show inline comments
 
@@ -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;
 

	
src/sound/win32_s.h
Show inline comments
 
@@ -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 */
src/video/allegro_v.h
Show inline comments
 
@@ -37,12 +37,10 @@ public:
 
};
 

	
 
/** Factory for the allegro video driver. */
 
class FVideoDriver_Allegro: public VideoDriverFactory<FVideoDriver_Allegro> {
 
class FVideoDriver_Allegro : public DriverFactoryBase {
 
public:
 
	static const int priority = 4;
 
	/* virtual */ const char *GetName() { return "allegro"; }
 
	/* virtual */ const char *GetDescription() { return "Allegro Video Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new VideoDriver_Allegro(); }
 
	FVideoDriver_Allegro() : DriverFactoryBase(Driver::DT_VIDEO, 4, "allegro", "Allegro Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_Allegro(); }
 
};
 

	
 
#endif /* VIDEO_ALLEGRO_H */
src/video/cocoa/cocoa_v.h
Show inline comments
 
@@ -61,12 +61,10 @@ public:
 
	/* virtual */ const char *GetName() const { return "cocoa"; }
 
};
 

	
 
class FVideoDriver_Cocoa: public VideoDriverFactory<FVideoDriver_Cocoa> {
 
class FVideoDriver_Cocoa : public DriverFactoryBase {
 
public:
 
	static const int priority = 10;
 
	/* virtual */ const char *GetName() { return "cocoa"; }
 
	/* virtual */ const char *GetDescription() { return "Cocoa Video Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new VideoDriver_Cocoa(); }
 
	FVideoDriver_Cocoa() : DriverFactoryBase(Driver::DT_VIDEO, 10, "cocoa", "Cocoa Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_Cocoa(); }
 
};
 

	
 

	
src/video/dedicated_v.h
Show inline comments
 
@@ -33,18 +33,17 @@ public:
 
};
 

	
 
/** Factory for the dedicated server video driver. */
 
class FVideoDriver_Dedicated: public VideoDriverFactory<FVideoDriver_Dedicated> {
 
class FVideoDriver_Dedicated : public DriverFactoryBase {
 
public:
 
#ifdef DEDICATED
 
	/* Automatically select this dedicated driver when making a dedicated
 
	 * server build. */
 
	static const int priority = 10;
 
	static const int PRIORITY = 10;
 
#else
 
	static const int priority = 0;
 
	static const int PRIORITY = 0;
 
#endif
 
	/* virtual */ const char *GetName() { return "dedicated"; }
 
	/* virtual */ const char *GetDescription() { return "Dedicated Video Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new VideoDriver_Dedicated(); }
 
	FVideoDriver_Dedicated() : DriverFactoryBase(Driver::DT_VIDEO, PRIORITY, "dedicated", "Dedicated Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_Dedicated(); }
 
};
 

	
 
#endif /* VIDEO_DEDICATED_H */
src/video/null_v.h
Show inline comments
 
@@ -36,12 +36,10 @@ public:
 
};
 

	
 
/** Factory the null video driver. */
 
class FVideoDriver_Null: public VideoDriverFactory<FVideoDriver_Null> {
 
class FVideoDriver_Null : public DriverFactoryBase {
 
public:
 
	static const int priority = 0;
 
	/* virtual */ const char *GetName() { return "null"; }
 
	/* virtual */ const char *GetDescription() { return "Null Video Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new VideoDriver_Null(); }
 
	FVideoDriver_Null() : DriverFactoryBase(Driver::DT_VIDEO, 0, "null", "Null Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_Null(); }
 
};
 

	
 
#endif /* VIDEO_NULL_H */
src/video/sdl_v.h
Show inline comments
 
@@ -41,12 +41,10 @@ private:
 
};
 

	
 
/** Factory for the SDL video driver. */
 
class FVideoDriver_SDL: public VideoDriverFactory<FVideoDriver_SDL> {
 
class FVideoDriver_SDL : public DriverFactoryBase {
 
public:
 
	static const int priority = 5;
 
	/* virtual */ const char *GetName() { return "sdl"; }
 
	/* virtual */ const char *GetDescription() { return "SDL Video Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new VideoDriver_SDL(); }
 
	FVideoDriver_SDL() : DriverFactoryBase(Driver::DT_VIDEO, 5, "sdl", "SDL Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_SDL(); }
 
};
 

	
 
#endif /* VIDEO_SDL_H */
src/video/video_driver.hpp
Show inline comments
 
@@ -80,25 +80,6 @@ public:
 
	virtual void EditBoxLostFocus() {}
 
};
 

	
 
/** Base of the factory for the video drivers. */
 
class VideoDriverFactoryBase: public DriverFactoryBase {
 
};
 

	
 
/**
 
 * Factory for the video drivers.
 
 * @tparam T The type of the video factory to register.
 
 */
 
template <class T>
 
class VideoDriverFactory: public VideoDriverFactoryBase {
 
public:
 
	VideoDriverFactory() { this->RegisterDriver(((T *)this)->GetName(), Driver::DT_VIDEO, ((T *)this)->priority); }
 

	
 
	/**
 
	 * Get the long, human readable, name for the Driver-class.
 
	 */
 
	const char *GetName();
 
};
 

	
 
extern VideoDriver *_video_driver;
 
extern char *_ini_videodriver;
 
extern int _num_resolutions;
src/video/win32_v.h
Show inline comments
 
@@ -41,12 +41,10 @@ public:
 
};
 

	
 
/** The factory for Windows' video driver. */
 
class FVideoDriver_Win32: public VideoDriverFactory<FVideoDriver_Win32> {
 
class FVideoDriver_Win32 : public DriverFactoryBase {
 
public:
 
	static const int priority = 10;
 
	/* virtual */ const char *GetName() { return "win32"; }
 
	/* virtual */ const char *GetDescription() { return "Win32 GDI Video Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new VideoDriver_Win32(); }
 
	FVideoDriver_Win32() : DriverFactoryBase(Driver::DT_VIDEO, 10, "win32", "Win32 GDI Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_Win32(); }
 
};
 

	
 
#endif /* VIDEO_WIN32_H */
0 comments (0 inline, 0 general)