DriverFactoryBase Class Reference

Base for all driver factories. More...

#include <driver.h>

Inheritance diagram for DriverFactoryBase:
MusicDriverFactoryBase SoundDriverFactoryBase VideoDriverFactoryBase MusicDriverFactory< T > MusicDriverFactory< FMusicDriver_Allegro > MusicDriverFactory< FMusicDriver_BeMidi > MusicDriverFactory< FMusicDriver_Cocoa > MusicDriverFactory< FMusicDriver_DMusic > MusicDriverFactory< FMusicDriver_ExtMidi > MusicDriverFactory< FMusicDriver_LibTimidity > MusicDriverFactory< FMusicDriver_Null > MusicDriverFactory< FMusicDriver_OS2 > MusicDriverFactory< FMusicDriver_QtMidi > MusicDriverFactory< FMusicDriver_Win32 > SoundDriverFactory< T > SoundDriverFactory< FSoundDriver_Allegro > SoundDriverFactory< FSoundDriver_Cocoa > SoundDriverFactory< FSoundDriver_Null > SoundDriverFactory< FSoundDriver_SDL > SoundDriverFactory< FSoundDriver_Win32 > VideoDriverFactory< T > VideoDriverFactory< FVideoDriver_Allegro > VideoDriverFactory< FVideoDriver_Cocoa > VideoDriverFactory< FVideoDriver_Dedicated > VideoDriverFactory< FVideoDriver_Null > VideoDriverFactory< FVideoDriver_SDL > VideoDriverFactory< FVideoDriver_Win32 >

Public Member Functions

virtual ~DriverFactoryBase ()
 Frees memory used for this->name.
virtual const char * GetDescription ()=0
 Get a nice description of the driver-class.
virtual DriverCreateInstance ()=0
 Create an instance of this driver-class.

Static Public Member Functions

static void ShutdownDrivers ()
 Shuts down all active drivers.
static DriverSelectDriver (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

void RegisterDriver (const char *name, Driver::Type type, int priority)
 Register a driver internally, based on its name.

Private Types

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

Static Private Member Functions

static DriversGetDrivers ()
 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.

Private Attributes

Driver::Type type
 The type of driver.
const char * name
 The name of the drivers of this factory.
int priority
 The priority of this factory.

Detailed Description

Base for all driver factories.

Definition at line 60 of file driver.h.


Member Function Documentation

virtual Driver* DriverFactoryBase::CreateInstance (  )  [pure virtual]
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 82 of file driver.h.

Referenced by SelectDriver().

virtual const char* DriverFactoryBase::GetDescription (  )  [pure virtual]
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 199 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 93 of file driver.h.

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

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

Register a driver internally, based on its name.

Parameters:
name the name of the driver.
type the type of driver to register
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.

Definition at line 173 of file driver.cpp.

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

Driver * 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 CreateInstance(), DEBUG, GetActiveDriver(), GetDrivers(), GetDriverTypeName(), lastof, lengthof, name, priority, Driver::Start(), strecpy(), StrEmpty(), type, and usererror().


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

Generated on Mon May 9 05:19:51 2011 for OpenTTD by  doxygen 1.6.1