mirror of
https://github.com/akuker/RASCSI.git
synced 2026-04-20 11:17:58 +00:00
SCSI Dump Usability Enhancements & Cleanup (#1026)
Co-authored-by: Tony Kuker <akuker@gmail.com>
This commit is contained in:
+24
-17
@@ -21,24 +21,31 @@ using namespace std;
|
||||
|
||||
unique_ptr<BUS> GPIOBUS_Factory::Create(BUS::mode_e mode)
|
||||
{
|
||||
// TODO Make the factory a friend of GPIOBUS and make the GPIOBUS constructor private
|
||||
// so that clients cannot use it anymore but have to use the factory.
|
||||
// Also make Init() private.
|
||||
unique_ptr<BUS> return_ptr;
|
||||
SBC_Version::Init();
|
||||
if (SBC_Version::IsBananaPi()) {
|
||||
LOGTRACE("Creating GPIOBUS_BananaM2p")
|
||||
return_ptr = make_unique<GPIOBUS_BananaM2p>();
|
||||
} else if (SBC_Version::IsRaspberryPi()) {
|
||||
LOGTRACE("Creating GPIOBUS_Raspberry")
|
||||
return_ptr = make_unique<GPIOBUS_Raspberry>();
|
||||
} else {
|
||||
LOGINFO("Creating Virtual GPIOBUS")
|
||||
return_ptr = make_unique<GPIOBUS_Virtual>();
|
||||
|
||||
try {
|
||||
// TODO Make the factory a friend of GPIOBUS and make the GPIOBUS constructor private
|
||||
// so that clients cannot use it anymore but have to use the factory.
|
||||
// Also make Init() private.
|
||||
SBC_Version::Init();
|
||||
if (SBC_Version::IsBananaPi()) {
|
||||
LOGTRACE("Creating GPIOBUS_BananaM2p")
|
||||
return_ptr = make_unique<GPIOBUS_BananaM2p>();
|
||||
} else if (SBC_Version::IsRaspberryPi()) {
|
||||
LOGTRACE("Creating GPIOBUS_Raspberry")
|
||||
return_ptr = make_unique<GPIOBUS_Raspberry>();
|
||||
} else {
|
||||
LOGINFO("Creating Virtual GPIOBUS")
|
||||
return_ptr = make_unique<GPIOBUS_Virtual>();
|
||||
}
|
||||
if (!return_ptr->Init(mode)) {
|
||||
return nullptr;
|
||||
}
|
||||
return_ptr->Reset();
|
||||
} catch (const invalid_argument&) {
|
||||
LOGERROR("Exception while trying to initialize GPIO bus. Are you running as root?")
|
||||
return_ptr = nullptr;
|
||||
}
|
||||
if (!return_ptr->Init(mode)) {
|
||||
return nullptr;
|
||||
}
|
||||
return_ptr->Reset();
|
||||
|
||||
return return_ptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user