diff --git a/cpp/hal/gpiobus_factory.cpp b/cpp/hal/bus_factory.cpp similarity index 82% rename from cpp/hal/gpiobus_factory.cpp rename to cpp/hal/bus_factory.cpp index 3d941a1d..d7d8fc65 100644 --- a/cpp/hal/gpiobus_factory.cpp +++ b/cpp/hal/bus_factory.cpp @@ -8,17 +8,17 @@ // //--------------------------------------------------------------------------- -#include "hal/gpiobus_factory.h" +#include "bus_factory.h" #include "hal/gpiobus_raspberry.h" #include #include #include #include -const string GPIOBUS_Factory::type_raspberry_pi_1 = "Raspberry Pi 1"; -const string GPIOBUS_Factory::type_raspberry_pi_2_3 = "Raspberry Pi 2/3"; -const string GPIOBUS_Factory::type_raspberry_pi_4 = "Raspberry Pi 4"; -const string GPIOBUS_Factory::type_unknown = "Unknown platform"; +const string BusFactory::type_raspberry_pi_1 = "Raspberry Pi 1"; +const string BusFactory::type_raspberry_pi_2_3 = "Raspberry Pi 2/3"; +const string BusFactory::type_raspberry_pi_4 = "Raspberry Pi 4"; +const string BusFactory::type_unknown = "Unknown platform"; // The strings in this table should align with the 'model' embedded // in the device tree. This can be aquired by running: @@ -28,7 +28,7 @@ const string GPIOBUS_Factory::type_unknown = "Unknown platform"; // "Raspberry Pi 4 Model B" will match with both of the following: // - Raspberry Pi 4 Model B Rev 1.4 // - Raspberry Pi 4 Model B Rev 1.3 -const map> GPIOBUS_Factory::proc_device_tree_mapping = { +const map> BusFactory::proc_device_tree_mapping = { {"Raspberry Pi 1 Model ", pi_type::raspberry_pi_1}, {"Raspberry Pi 2 Model ", pi_type::raspberry_pi_2_3}, {"Raspberry Pi 3 Model ", pi_type::raspberry_pi_2_3}, @@ -39,7 +39,7 @@ const map> GPIOBUS_Factory::proc_device using namespace std; -unique_ptr GPIOBUS_Factory::Create(BUS::mode_e mode, bool in_process) +unique_ptr BusFactory::Create(BUS::mode_e mode, bool in_process) { unique_ptr bus; @@ -68,7 +68,7 @@ unique_ptr GPIOBUS_Factory::Create(BUS::mode_e mode, bool in_process) return bus; } -string GPIOBUS_Factory::GetAsString() +string BusFactory::GetAsString() { switch (pi_version) { case pi_type::raspberry_pi_1: @@ -85,7 +85,7 @@ string GPIOBUS_Factory::GetAsString() } } -void GPIOBUS_Factory::Init() +void BusFactory::Init() { ifstream in(DEVICE_TREE_MODEL_PATH); if (in.fail()) { @@ -112,7 +112,7 @@ void GPIOBUS_Factory::Init() spdlog::error("Unable to determine Raspberry Pi model. Defaulting to Raspberry Pi 4."); } -bool GPIOBUS_Factory::IsRaspberryPi() +bool BusFactory::IsRaspberryPi() { return pi_version != pi_type::unknown; } diff --git a/cpp/hal/gpiobus_factory.h b/cpp/hal/bus_factory.h similarity index 92% rename from cpp/hal/gpiobus_factory.h rename to cpp/hal/bus_factory.h index 2b4acbb5..ca3cbd52 100644 --- a/cpp/hal/gpiobus_factory.h +++ b/cpp/hal/bus_factory.h @@ -15,13 +15,13 @@ using namespace std; -class GPIOBUS_Factory +class BusFactory { public: - GPIOBUS_Factory() = default; - ~GPIOBUS_Factory() = default; + BusFactory() = default; + ~BusFactory() = default; enum class pi_type { unknown, diff --git a/cpp/piscsi/piscsi_core.cpp b/cpp/piscsi/piscsi_core.cpp index e86d7cd9..16bad3bb 100644 --- a/cpp/piscsi/piscsi_core.cpp +++ b/cpp/piscsi/piscsi_core.cpp @@ -17,7 +17,7 @@ #include "devices/device_logger.h" #include "devices/storage_device.h" #include "devices/host_services.h" -#include "hal/gpiobus_factory.h" +#include "../hal/bus_factory.h" #include "hal/gpiobus.h" #include "piscsi/piscsi_core.h" #include @@ -62,7 +62,7 @@ void Piscsi::Banner(span args) const bool Piscsi::InitBus(bool in_process) { - bus = GPIOBUS_Factory::Create(BUS::mode_e::TARGET, in_process); + bus = BusFactory::Create(BUS::mode_e::TARGET, in_process); if (!bus) { return false; } diff --git a/cpp/scsidump/scsidump_core.cpp b/cpp/scsidump/scsidump_core.cpp index 834504ef..12a615a5 100644 --- a/cpp/scsidump/scsidump_core.cpp +++ b/cpp/scsidump/scsidump_core.cpp @@ -9,7 +9,7 @@ //--------------------------------------------------------------------------- #include "scsidump/scsidump_core.h" -#include "hal/gpiobus_factory.h" +#include "../hal/bus_factory.h" #include "controllers/controller_manager.h" #include "shared/piscsi_exceptions.h" #include "shared/piscsi_util.h" @@ -86,7 +86,7 @@ bool ScsiDump::Init(bool in_process) sigaction(SIGTERM, &termination_handler, nullptr); signal(SIGPIPE, SIG_IGN); - bus = GPIOBUS_Factory::Create(BUS::mode_e::INITIATOR, in_process); + bus = BusFactory::Create(BUS::mode_e::INITIATOR, in_process); if (bus != nullptr) { scsi_executor = make_unique(*bus, initiator_id); @@ -214,7 +214,7 @@ int ScsiDump::run(span args, bool in_process) return EXIT_FAILURE; } - if (!in_process && !GPIOBUS_Factory::IsRaspberryPi()) { + if (!in_process && !BusFactory::IsRaspberryPi()) { cerr << "Error: No PiSCSI hardware support" << endl; return EXIT_FAILURE; } diff --git a/cpp/scsiexec/scsiexec_core.cpp b/cpp/scsiexec/scsiexec_core.cpp index c911a6a4..8aa3201e 100644 --- a/cpp/scsiexec/scsiexec_core.cpp +++ b/cpp/scsiexec/scsiexec_core.cpp @@ -8,7 +8,7 @@ //--------------------------------------------------------------------------- #include "scsiexec_core.h" -#include "hal/gpiobus_factory.h" +#include "../hal/bus_factory.h" #include "controllers/controller_manager.h" #include "shared/piscsi_util.h" #include @@ -83,7 +83,7 @@ bool ScsiExec::Init(bool) sigaction(SIGTERM, &termination_handler, nullptr); signal(SIGPIPE, SIG_IGN); - bus = GPIOBUS_Factory::Create(BUS::mode_e::INITIATOR); + bus = BusFactory::Create(BUS::mode_e::INITIATOR); if (bus) { scsi_executor = make_unique(*bus, initiator_id); @@ -192,7 +192,7 @@ int ScsiExec::run(span args, bool in_process) return EXIT_FAILURE; } - if (!in_process && !GPIOBUS_Factory::IsRaspberryPi()) { + if (!in_process && !BusFactory::IsRaspberryPi()) { cerr << "Error: No PiSCSI hardware support" << endl; return EXIT_FAILURE; }