OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Static Private Member Functions | Private Attributes | Friends
DriverFactoryBase Class Reference

Base for all driver factories. More...

`#include <driver.h>`

Inheritance diagram for DriverFactoryBase:

## Public Member Functions
const char * | GetDescription () const
| Get a nice description of the driver-class.
virtual Driver * | CreateInstance () const =0
| Create an instance of this driver-class.

## Static Public Member Functions
static void | ShutdownDrivers ()
| Shuts down all active drivers.
static void | SelectDriver (const char *name, Driver::Type type)
| Find the requested driver and return its class.
static char * | GetDriversInfo (char *p, const char *last)
| Build a human readable list of available drivers, grouped by type.

## Protected Member Functions
| DriverFactoryBase (Driver::Type type, int priority, const char *name, const char *description)
| Construct a new DriverFactory.
virtual | ~DriverFactoryBase ()
| Frees memory used for this->name.

## Private Types
typedef std::map< const char *, DriverFactoryBase *, StringCompare > | 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.
static const char * | GetDriverTypeName (Driver::Type type)
| Get the driver type name.
static bool | SelectDriverImpl (const char *name, Driver::Type type)
| Find the requested driver and return its class.

## Private Attributes
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.
const char * | description
| The description of this driver.

## Friends
class | MusicDriver
class | SoundDriver
class | VideoDriver

## Detailed Description

Base for all driver factories.

Definition at line 60 of file driver.h.

## Constructor & Destructor Documentation

DriverFactoryBase::DriverFactoryBase | ( | Driver::Type | type,
|  | int | priority,
|  | const char * | name,
|  | const char * | description
| ) |  |
| protected

Construct a new DriverFactory.

Parameters

  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 219 of file driver.cpp.

References GetDrivers(), GetDriverTypeName(), lastof, strecpy(), and stredup().

## Member Function Documentation

virtual Driver* DriverFactoryBase::CreateInstance | ( |  | ) | const
| pure virtual

Create an instance of this driver-class.

Returns
  The instance.

Implemented in FVideoDriver_Cocoa, FVideoDriver_SDL, FVideoDriver_Win32, FMusicDriver_Allegro, FVideoDriver_Dedicated, FMusicDriver_ExtMidi, FVideoDriver_Allegro, FVideoDriver_Null, FMusicDriver_DMusic, FMusicDriver_BeMidi, FMusicDriver_LibTimidity, FMusicDriver_Null, FMusicDriver_OS2, FMusicDriver_Win32, FMusicDriver_Cocoa, FMusicDriver_QtMidi, FSoundDriver_Allegro, FSoundDriver_Null, FSoundDriver_SDL, FSoundDriver_Win32, and FSoundDriver_Cocoa.

Referenced by SelectDriverImpl().

static Driver** DriverFactoryBase::GetActiveDriver | ( | Driver::Type | type | ) |
| inline static private

Get the active driver for the given type.

Parameters

  type | The type to get the driver for.

Returns
  The active driver.

Definition at line 87 of file driver.h.

Referenced by SoundDriver::GetInstance(), MusicDriver::GetInstance(), VideoDriver::GetInstance(), and SelectDriverImpl().

const char* DriverFactoryBase::GetDescription | ( |  | ) | const
| inline

Get a nice description of the driver-class.

Returns
  The description.

Definition at line 130 of file driver.h.

Referenced by GetDriversInfo().

char * DriverFactoryBase::GetDriversInfo | ( | char * | p,
|  | const char * | last
| ) |  |
| static

Build a human readable list of available drivers, grouped by type.

Parameters

  p | The buffer to write to.
  last | The last element in the buffer.

Returns
  The end of the written buffer.

Definition at line 191 of file driver.cpp.

References Driver::DT_BEGIN, Driver::DT_END, GetDescription(), GetDrivers(), GetDriverTypeName(), name, priority, seprintf(), and type.

Referenced by ShowHelp().

static const char* DriverFactoryBase::GetDriverTypeName | ( | Driver::Type | type | ) |
| inline static private

Get the driver type name.

Parameters

  type | The type of driver to get the name of.

Returns
  The name of the type.

Definition at line 98 of file driver.h.

Referenced by DriverFactoryBase(), GetDriversInfo(), SelectDriver(), SelectDriverImpl(), and ~DriverFactoryBase().

void DriverFactoryBase::SelectDriver | ( | const char * | name,
|  | Driver::Type | type
| ) |  |
| static

Find the requested driver and return its class.

Parameters

  name | the driver to select.
  type | the type of driver to select

Postcondition
  Sets the driver so GetCurrentDriver() returns it too.

Definition at line 88 of file driver.cpp.

References GetDriverTypeName(), SelectDriverImpl(), StrEmpty(), and usererror().

Referenced by openttd_main().

bool DriverFactoryBase::SelectDriverImpl | ( | const char * | name,
|  | Driver::Type | type
| ) |  |
| static private

Find the requested driver and return its class.

Parameters

  name | the driver to select.
  type | the type of driver to select

Postcondition
  Sets the driver so GetCurrentDriver() returns it too.

Returns
  True upon success, otherwise false.

Definition at line 104 of file driver.cpp.

References CreateInstance(), DEBUG, GetActiveDriver(), GetDrivers(), GetDriverTypeName(), lastof, lengthof, name, priority, Driver::Start(), strecpy(), StrEmpty(), type, and usererror().

Referenced by SelectDriver().

The documentation for this class was generated from the following files:

- src/driver.h
- src/driver.cpp