39 enum class Type : uint8_t {
51 virtual std::string_view
GetName()
const = 0;
57 friend class MusicDriver;
58 friend class SoundDriver;
59 friend class VideoDriver;
66 typedef std::map<std::string, DriverFactoryBase *>
Drivers;
86 return s_driver[
type];
97 "music",
"sound",
"video"
99 return driver_type_name[
type];
129 if (driver !=
nullptr) driver->Stop();
134 static void GetDriversInfo(std::back_insert_iterator<std::string> &output_iterator);
142 return this->description;
static void MarkVideoDriverOperational()
Mark the current video driver as operational.
std::string_view name
The name of the drivers of this factory.
std::string_view GetDescription() const
Get a nice description of the driver-class.
std::map< std::string, DriverFactoryBase * > Drivers
Type for a map of drivers.
static Drivers & GetDrivers()
Get the map with drivers.
virtual bool UsesHardwareAcceleration() const
Does the driver use hardware acceleration (video-drivers only).
static void ShutdownDrivers()
Shuts down all active drivers.
static std::unique_ptr< Driver > & GetActiveDriver(Driver::Type type)
Get the active driver for the given type.
DriverFactoryBase(Driver::Type type, int priority, std::string_view name, std::string_view description)
Construct a new DriverFactory.
static void SelectDriver(const std::string &name, Driver::Type type)
Find the requested driver and return its class.
static std::string_view GetDriverTypeName(Driver::Type type)
Get the driver type name.
static bool SelectDriverImpl(const std::string &name, Driver::Type type)
Find the requested driver and return its class.
virtual std::unique_ptr< Driver > CreateInstance() const =0
Create an instance of this driver-class.
static void GetDriversInfo(std::back_insert_iterator< std::string > &output_iterator)
Build a human readable list of available drivers, grouped by type.
Driver::Type type
The type of driver.
virtual ~DriverFactoryBase()
Ensure the destructor of the sub classes are called as well.
int priority
The priority of this factory.
std::string_view description
The description of this driver.
A driver for communicating with the user.
virtual std::string_view GetName() const =0
Get the name of this driver.
virtual ~Driver()=default
Ensure the destructor of the sub classes are called as well.
virtual void Stop()=0
Stop this driver.
@ Begin
Helper for iteration.
@ Music
A music driver, needs to be before sound to properly shut down extmidi forked music players.
@ End
Helper for iteration.
virtual std::optional< std::string_view > Start(const StringList &parm)=0
Start this driver.
Iterate a range of enum values.
int GetDriverParamInt(const StringList &parm, std::string_view name, int def)
Get an integer parameter the list of parameters.
std::optional< std::string_view > GetDriverParam(const StringList &parm, std::string_view name)
Get a string parameter the list of parameters.
bool GetDriverParamBool(const StringList &parm, std::string_view name)
Get a boolean parameter the list of parameters.
Type (helpers) for enums.
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
std::vector< std::string > StringList
Type for a list of strings.