diff options
author | rubidium <rubidium@openttd.org> | 2013-11-25 14:26:46 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2013-11-25 14:26:46 +0000 |
commit | 6996b441d9d104bc6d7041b64362f4426425f600 (patch) | |
tree | 074989fd03a7f672e137423688c40d1efc466a95 /src/video | |
parent | a399fc667ce506abcdcfd853d1ad58f0bb8dbb4f (diff) | |
download | openttd-6996b441d9d104bc6d7041b64362f4426425f600.tar.xz |
(svn r26107) -Codechange/cleanup: remove some coding bloat and simplify the driver factory instatiations
Diffstat (limited to 'src/video')
-rw-r--r-- | src/video/allegro_v.h | 8 | ||||
-rw-r--r-- | src/video/cocoa/cocoa_v.h | 8 | ||||
-rw-r--r-- | src/video/dedicated_v.h | 11 | ||||
-rw-r--r-- | src/video/null_v.h | 8 | ||||
-rw-r--r-- | src/video/sdl_v.h | 8 | ||||
-rw-r--r-- | src/video/video_driver.hpp | 19 | ||||
-rw-r--r-- | src/video/win32_v.h | 8 |
7 files changed, 20 insertions, 50 deletions
diff --git a/src/video/allegro_v.h b/src/video/allegro_v.h index da95269ce..d455bb515 100644 --- a/src/video/allegro_v.h +++ b/src/video/allegro_v.h @@ -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 */ diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h index e70a33b15..491efa94b 100644 --- a/src/video/cocoa/cocoa_v.h +++ b/src/video/cocoa/cocoa_v.h @@ -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(); } }; diff --git a/src/video/dedicated_v.h b/src/video/dedicated_v.h index 7d449d159..24d647fef 100644 --- a/src/video/dedicated_v.h +++ b/src/video/dedicated_v.h @@ -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 */ diff --git a/src/video/null_v.h b/src/video/null_v.h index 9bc26c4ef..69563f5c4 100644 --- a/src/video/null_v.h +++ b/src/video/null_v.h @@ -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 */ diff --git a/src/video/sdl_v.h b/src/video/sdl_v.h index 66f8bf856..523129309 100644 --- a/src/video/sdl_v.h +++ b/src/video/sdl_v.h @@ -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 */ diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp index d8249b1f7..3a3b4c79e 100644 --- a/src/video/video_driver.hpp +++ b/src/video/video_driver.hpp @@ -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; diff --git a/src/video/win32_v.h b/src/video/win32_v.h index 6be60c230..f7c289009 100644 --- a/src/video/win32_v.h +++ b/src/video/win32_v.h @@ -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 */ |