Skip to content

Commit

Permalink
Renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Nov 25, 2023
1 parent 0800e16 commit a8052be
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
20 changes: 10 additions & 10 deletions cpp/hal/gpiobus_factory.cpp → cpp/hal/bus_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
//
//---------------------------------------------------------------------------

#include "hal/gpiobus_factory.h"
#include "bus_factory.h"
#include "hal/gpiobus_raspberry.h"
#include <spdlog/spdlog.h>
#include <sstream>
#include <fstream>
#include <memory>

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:
Expand All @@ -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<string, GPIOBUS_Factory::pi_type, less<>> GPIOBUS_Factory::proc_device_tree_mapping = {
const map<string, BusFactory::pi_type, less<>> 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},
Expand All @@ -39,7 +39,7 @@ const map<string, GPIOBUS_Factory::pi_type, less<>> GPIOBUS_Factory::proc_device

using namespace std;

unique_ptr<BUS> GPIOBUS_Factory::Create(BUS::mode_e mode, bool in_process)
unique_ptr<BUS> BusFactory::Create(BUS::mode_e mode, bool in_process)
{
unique_ptr<BUS> bus;

Expand Down Expand Up @@ -68,7 +68,7 @@ unique_ptr<BUS> 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:
Expand All @@ -85,7 +85,7 @@ string GPIOBUS_Factory::GetAsString()
}
}

void GPIOBUS_Factory::Init()
void BusFactory::Init()
{
ifstream in(DEVICE_TREE_MODEL_PATH);
if (in.fail()) {
Expand All @@ -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;
}
6 changes: 3 additions & 3 deletions cpp/hal/gpiobus_factory.h → cpp/hal/bus_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions cpp/piscsi/piscsi_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <spdlog/spdlog.h>
Expand Down Expand Up @@ -62,7 +62,7 @@ void Piscsi::Banner(span<char *> 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;
}
Expand Down
6 changes: 3 additions & 3 deletions cpp/scsidump/scsidump_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<ScsiExecutor>(*bus, initiator_id);
Expand Down Expand Up @@ -214,7 +214,7 @@ int ScsiDump::run(span<char*> 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;
}
Expand Down
6 changes: 3 additions & 3 deletions cpp/scsiexec/scsiexec_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <google/protobuf/util/json_util.h>
Expand Down Expand Up @@ -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<ScsiExecutor>(*bus, initiator_id);
Expand Down Expand Up @@ -192,7 +192,7 @@ int ScsiExec::run(span<char*> 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;
}
Expand Down

0 comments on commit a8052be

Please sign in to comment.