|
@@ -207,31 +207,27 @@ void DriverFactoryBase::GetDriversInfo(s
|
|
|
* @param description A long-ish description of the driver.
|
|
|
*/
|
|
|
DriverFactoryBase::DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description) :
|
|
|
type(type), priority(priority), name(name), description(description)
|
|
|
{
|
|
|
/* Prefix the name with driver type to make it unique */
|
|
|
char buf[32];
|
|
|
strecpy(buf, GetDriverTypeName(type), lastof(buf));
|
|
|
strecpy(buf + 5, name, lastof(buf));
|
|
|
std::string typed_name = fmt::format("{}{}", GetDriverTypeName(type), name);
|
|
|
|
|
|
Drivers &drivers = GetDrivers();
|
|
|
assert(drivers.find(buf) == drivers.end());
|
|
|
drivers.insert(Drivers::value_type(buf, this));
|
|
|
assert(drivers.find(typed_name) == drivers.end());
|
|
|
drivers.insert(Drivers::value_type(typed_name, this));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Frees memory used for this->name
|
|
|
*/
|
|
|
DriverFactoryBase::~DriverFactoryBase()
|
|
|
{
|
|
|
/* Prefix the name with driver type to make it unique */
|
|
|
char buf[32];
|
|
|
strecpy(buf, GetDriverTypeName(type), lastof(buf));
|
|
|
strecpy(buf + 5, this->name, lastof(buf));
|
|
|
std::string typed_name = fmt::format("{}{}", GetDriverTypeName(type), name);
|
|
|
|
|
|
Drivers::iterator it = GetDrivers().find(buf);
|
|
|
Drivers::iterator it = GetDrivers().find(typed_name);
|
|
|
assert(it != GetDrivers().end());
|
|
|
|
|
|
GetDrivers().erase(it);
|
|
|
if (GetDrivers().empty()) delete &GetDrivers();
|
|
|
}
|