OpenTTD Source 20241224-master-gf74b0cf984
BlitterFactory Class Referenceabstract

The base factory, keeping track of all blitters. More...

#include <factory.hpp>

Inheritance diagram for BlitterFactory:
FBlitter_32bppAnim FBlitter_32bppOptimized FBlitter_32bppSimple FBlitter_40bppAnim FBlitter_8bppOptimized FBlitter_8bppSimple FBlitter_Null

Public Member Functions

std::string_view GetName () const
 Get the long, human readable, name for the Blitter-class.
 
std::string_view GetDescription () const
 Get a nice description of the blitter-class.
 
virtual BlitterCreateInstance ()=0
 Create an instance of this Blitter-class.
 

Static Public Member Functions

static BlitterSelectBlitter (const std::string_view name)
 Find the requested blitter and return its class.
 
static BlitterFactoryGetBlitterFactory (const std::string_view name)
 Get the blitter factory with the given name.
 
static BlitterGetCurrentBlitter ()
 Get the current active blitter (always set by calling SelectBlitter).
 
static void GetBlittersInfo (std::back_insert_iterator< std::string > &output_iterator)
 Fill a buffer with information about the blitters.
 

Protected Member Functions

 BlitterFactory (const char *name, const char *description, bool usable=true)
 Construct the blitter, and register it.
 
virtual bool IsUsable () const
 Is the blitter usable with the current drivers and hardware config?
 

Private Types

typedef std::map< std::string, BlitterFactory * > Blitters
 Map of blitter factories.
 

Static Private Member Functions

static BlittersGetBlitters ()
 Get the map with currently known blitters.
 
static Blitter ** GetActiveBlitter ()
 Get the currently active blitter.
 

Private Attributes

const std::string name
 The name of the blitter factory.
 
const std::string description
 The description of the blitter.
 

Detailed Description

The base factory, keeping track of all blitters.

Definition at line 21 of file factory.hpp.

Member Typedef Documentation

◆ Blitters

typedef std::map<std::string, BlitterFactory *> BlitterFactory::Blitters
private

Map of blitter factories.

Definition at line 26 of file factory.hpp.

Constructor & Destructor Documentation

◆ BlitterFactory()

BlitterFactory::BlitterFactory ( const char *  name,
const char *  description,
bool  usable = true 
)
inlineprotected

Construct the blitter, and register it.

Parameters
nameThe name of the blitter.
descriptionA longer description for the blitter.
usableWhether the blitter is usable (on the current computer). For example for disabling SSE blitters when the CPU can't handle them.
Precondition
name != nullptr.
description != nullptr.
There is no blitter registered with this name.

Definition at line 58 of file factory.hpp.

References Debug, GetBlitters(), and name.

◆ ~BlitterFactory()

virtual BlitterFactory::~BlitterFactory ( )
inlinevirtual

Definition at line 85 of file factory.hpp.

Member Function Documentation

◆ CreateInstance()

virtual Blitter * BlitterFactory::CreateInstance ( )
pure virtual

◆ GetActiveBlitter()

static Blitter ** BlitterFactory::GetActiveBlitter ( )
inlinestaticprivate

Get the currently active blitter.

Returns
The currently active blitter.

Definition at line 42 of file factory.hpp.

Referenced by GetCurrentBlitter(), and SelectBlitter().

◆ GetBlitterFactory()

static BlitterFactory * BlitterFactory::GetBlitterFactory ( const std::string_view  name)
inlinestatic

Get the blitter factory with the given name.

Parameters
namethe blitter factory to select.
Returns
The blitter factory, or nullptr when there isn't one with the wanted name.

Definition at line 114 of file factory.hpp.

References GetBlitters(), IsUsable(), name, and StrEqualsIgnoreCase().

Referenced by SelectBlitter(), and SwitchNewGRFBlitter().

◆ GetBlitters()

static Blitters & BlitterFactory::GetBlitters ( )
inlinestaticprivate

Get the map with currently known blitters.

Returns
The known blitters.

Definition at line 32 of file factory.hpp.

Referenced by BlitterFactory(), GetBlitterFactory(), and GetBlittersInfo().

◆ GetBlittersInfo()

static void BlitterFactory::GetBlittersInfo ( std::back_insert_iterator< std::string > &  output_iterator)
inlinestatic

Fill a buffer with information about the blitters.

Parameters
pThe buffer to fill.
lastThe last element of the buffer.
Returns
p The location till where we filled the buffer.

Definition at line 149 of file factory.hpp.

References GetBlitters(), GetDescription(), and name.

Referenced by ShowHelp().

◆ GetCurrentBlitter()

◆ GetDescription()

std::string_view BlitterFactory::GetDescription ( ) const
inline

Get a nice description of the blitter-class.

Definition at line 170 of file factory.hpp.

References description.

Referenced by GetBlittersInfo().

◆ GetName()

std::string_view BlitterFactory::GetName ( ) const
inline

Get the long, human readable, name for the Blitter-class.

Definition at line 162 of file factory.hpp.

References name.

◆ IsUsable()

virtual bool BlitterFactory::IsUsable ( ) const
inlineprotectedvirtual

Is the blitter usable with the current drivers and hardware config?

Returns
True if the blitter can be instantiated.

Reimplemented in FBlitter_40bppAnim.

Definition at line 79 of file factory.hpp.

Referenced by GetBlitterFactory().

◆ SelectBlitter()

static Blitter * BlitterFactory::SelectBlitter ( const std::string_view  name)
inlinestatic

Find the requested blitter and return its class.

Parameters
namethe blitter to select.
Postcondition
Sets the blitter so GetCurrentBlitter() returns it too.

Definition at line 96 of file factory.hpp.

References CreateInstance(), Debug, GetActiveBlitter(), GetBlitterFactory(), Blitter::GetName(), and name.

Referenced by openttd_main(), and VideoDriver_Null::Start().

Field Documentation

◆ description

const std::string BlitterFactory::description
private

The description of the blitter.

Definition at line 24 of file factory.hpp.

Referenced by GetDescription().

◆ name

const std::string BlitterFactory::name
private

The name of the blitter factory.

Definition at line 23 of file factory.hpp.

Referenced by BlitterFactory(), GetBlitterFactory(), GetBlittersInfo(), GetName(), and SelectBlitter().


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