MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / createDriver

Method createDriver

app/src/IO/ConnectionManager.cpp:1479–1546  ·  view source on GitHub ↗

* @brief Creates a fresh driver instance for the given bus @p type. */

Source from the content-addressed store, hash-verified

1477 * @brief Creates a fresh driver instance for the given bus @p type.
1478 */
1479std::unique_ptr<IO::HAL_Driver> IO::ConnectionManager::createDriver(
1480 SerialStudio::BusType type) const
1481{
1482 Q_ASSERT(static_cast<int>(type) >= 0);
1483 Q_ASSERT(static_cast<int>(type) >= static_cast<int>(SerialStudio::BusType::UART));
1484
1485 switch (type) {
1486 case SerialStudio::BusType::UART:
1487 return std::make_unique<IO::Drivers::UART>();
1488 case SerialStudio::BusType::Network:
1489 return std::make_unique<IO::Drivers::Network>();
1490 case SerialStudio::BusType::BluetoothLE:
1491 return std::make_unique<IO::Drivers::BluetoothLE>();
1492#ifdef BUILD_COMMERCIAL
1493 case SerialStudio::BusType::Audio: {
1494 const auto& tk = Licensing::CommercialToken::current();
1495 if (!tk.isValid() || !SS_LICENSE_GUARD() || tk.featureTier() < Licensing::FeatureTier::Trial)
1496 return nullptr;
1497
1498 return std::make_unique<IO::Drivers::Audio>();
1499 }
1500 case SerialStudio::BusType::ModBus: {
1501 const auto& tk = Licensing::CommercialToken::current();
1502 if (!tk.isValid() || !SS_LICENSE_GUARD() || tk.featureTier() < Licensing::FeatureTier::Trial)
1503 return nullptr;
1504
1505 return std::make_unique<IO::Drivers::Modbus>();
1506 }
1507 case SerialStudio::BusType::CanBus: {
1508 const auto& tk = Licensing::CommercialToken::current();
1509 if (!tk.isValid() || !SS_LICENSE_GUARD() || tk.featureTier() < Licensing::FeatureTier::Trial)
1510 return nullptr;
1511
1512 return std::make_unique<IO::Drivers::CANBus>();
1513 }
1514 case SerialStudio::BusType::RawUsb: {
1515 const auto& tk = Licensing::CommercialToken::current();
1516 if (!tk.isValid() || !SS_LICENSE_GUARD() || tk.featureTier() < Licensing::FeatureTier::Trial)
1517 return nullptr;
1518
1519 return std::make_unique<IO::Drivers::USB>();
1520 }
1521 case SerialStudio::BusType::HidDevice: {
1522 const auto& tk = Licensing::CommercialToken::current();
1523 if (!tk.isValid() || !SS_LICENSE_GUARD() || tk.featureTier() < Licensing::FeatureTier::Trial)
1524 return nullptr;
1525
1526 return std::make_unique<IO::Drivers::HID>();
1527 }
1528 case SerialStudio::BusType::Process: {
1529 const auto& tk = Licensing::CommercialToken::current();
1530 if (!tk.isValid() || !SS_LICENSE_GUARD() || tk.featureTier() < Licensing::FeatureTier::Trial)
1531 return nullptr;
1532
1533 return std::make_unique<IO::Drivers::Process>();
1534 }
1535 case SerialStudio::BusType::Mqtt: {
1536 const auto& tk = Licensing::CommercialToken::current();

Callers

nothing calls this directly

Calls 2

featureTierMethod · 0.80
isValidMethod · 0.45

Tested by

no test coverage detected