OpenTTD Source
20241121-master-g67a0fccfad
|
Base for all driver factories. More...
#include <driver.h>
Public Member Functions | |
std::string_view | GetDescription () const |
Get a nice description of the driver-class. More... | |
virtual Driver * | CreateInstance () const =0 |
Create an instance of this driver-class. More... | |
Static Public Member Functions | |
static void | ShutdownDrivers () |
Shuts down all active drivers. | |
static void | SelectDriver (const std::string &name, Driver::Type type) |
Find the requested driver and return its class. More... | |
static void | GetDriversInfo (std::back_insert_iterator< std::string > &output_iterator) |
Build a human readable list of available drivers, grouped by type. More... | |
Protected Member Functions | |
DriverFactoryBase (Driver::Type type, int priority, const char *name, const char *description) | |
Construct a new DriverFactory. More... | |
virtual | ~DriverFactoryBase () |
Frees memory used for this->name. | |
virtual bool | UsesHardwareAcceleration () const |
Does the driver use hardware acceleration (video-drivers only). More... | |
Private Types | |
typedef std::map< std::string, DriverFactoryBase * > | Drivers |
Type for a map of drivers. | |
Static Private Member Functions | |
static Drivers & | GetDrivers () |
Get the map with drivers. | |
static Driver ** | GetActiveDriver (Driver::Type type) |
Get the active driver for the given type. More... | |
static std::string_view | GetDriverTypeName (Driver::Type type) |
Get the driver type name. More... | |
static bool | SelectDriverImpl (const std::string &name, Driver::Type type) |
Find the requested driver and return its class. More... | |
static void | MarkVideoDriverOperational () |
Mark the current video driver as operational. | |
Private Attributes | |
Driver::Type | type |
The type of driver. | |
int | priority |
The priority of this factory. | |
std::string_view | name |
The name of the drivers of this factory. | |
std::string_view | description |
The description of this driver. | |
Friends | |
class | MusicDriver |
class | SoundDriver |
class | VideoDriver |
|
protected |
Construct a new DriverFactory.
type | The type of driver. |
priority | The priority within the driver class. |
name | The name of the driver. |
description | A long-ish description of the driver. |
Definition at line 244 of file driver.cpp.
References GetDrivers(), GetDriverTypeName(), name, and type.
|
pure virtual |
Create an instance of this driver-class.
Implemented in FVideoDriver_Win32GDI, FVideoDriver_SDL, FVideoDriver_SDL_OpenGL, FVideoDriver_SDL_Default, FVideoDriver_Null, FVideoDriver_Dedicated, FVideoDriver_CocoaQuartz, FVideoDriver_CocoaOpenGL, FVideoDriver_Allegro, FSoundDriver_XAudio2, FSoundDriver_Win32, FSoundDriver_SDL, FSoundDriver_Null, FSoundDriver_Cocoa, FSoundDriver_Allegro, FMusicDriver_Win32, FMusicDriver_Null, FMusicDriver_FluidSynth, FMusicDriver_ExtMidi, FMusicDriver_DMusic, FMusicDriver_Cocoa, FMusicDriver_BeMidi, and FMusicDriver_Allegro.
Referenced by SelectDriverImpl().
|
inlinestaticprivate |
Get the active driver for the given type.
type | The type to get the driver for. |
Definition at line 84 of file driver.h.
Referenced by MusicDriver::GetInstance(), SoundDriver::GetInstance(), VideoDriver::GetInstance(), and SelectDriverImpl().
|
inline |
Get a nice description of the driver-class.
Definition at line 138 of file driver.h.
Referenced by GetDriversInfo().
|
static |
Build a human readable list of available drivers, grouped by type.
output_iterator | The iterator to write the string to. |
Definition at line 219 of file driver.cpp.
References Driver::DT_BEGIN, Driver::DT_END, GetDescription(), GetDrivers(), GetDriverTypeName(), name, priority, and type.
|
inlinestaticprivate |
Get the driver type name.
type | The type of driver to get the name of. |
Definition at line 95 of file driver.h.
Referenced by DriverFactoryBase(), GetDriversInfo(), SelectDriverImpl(), and ~DriverFactoryBase().
|
static |
Find the requested driver and return its class.
name | the driver to select. |
type | the type of driver to select |
Definition at line 88 of file driver.cpp.
References name, SelectDriverImpl(), and type.
|
staticprivate |
Find the requested driver and return its class.
name | the driver to select. |
type | the type of driver to select |
Definition at line 104 of file driver.cpp.
References _video_hw_accel, BASE_DIR, CreateInstance(), Debug, Driver::DT_VIDEO, FioFindFullPath(), FioFOpenFile(), FioRemove(), GetActiveDriver(), GetDrivers(), GetDriverTypeName(), HWACCELERATION_TEST_FILE, name, priority, ScheduleErrorMessage(), Driver::Start(), type, and UsesHardwareAcceleration().
Referenced by SelectDriver().
|
inlineprotectedvirtual |
Does the driver use hardware acceleration (video-drivers only).
Reimplemented in FVideoDriver_SDL_OpenGL, and FVideoDriver_CocoaOpenGL.
Definition at line 114 of file driver.h.
Referenced by SelectDriverImpl().