From b138df21eb1fbf9c8a794c4c873ab039d6460f71 Mon Sep 17 00:00:00 2001 From: "Christopher A. Mosher" Date: Sun, 11 Dec 2022 20:13:39 -0500 Subject: [PATCH] rename Config class to E2Config; remove an unused function --- CMakeLists.txt | 2 +- src/E2wxApp.cpp | 8 ++------ src/card.cpp | 2 +- src/{configep2.cpp => e2config.cpp} | 30 ++++++++++++++--------------- src/{configep2.h => e2config.h} | 6 +++--- src/emulator.cpp | 6 +++--- src/emulator.h | 4 ++-- 7 files changed, 27 insertions(+), 31 deletions(-) rename src/{configep2.cpp => e2config.cpp} (93%) rename src/{configep2.h => e2config.h} (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37904eb..4fd1472 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,6 @@ Circuit.cpp clipboardhandler.cpp clockcard.cpp Common.cpp -configep2.cpp Cpu6502.cpp Cpu6502Helper.cpp cpu.cpp @@ -77,6 +76,7 @@ disk2steppermotorrotor.cpp diskcontroller.cpp drive.cpp drivemotor.cpp +e2config.cpp e2filesystem.cpp e2string.cpp E2wxApp.cpp diff --git a/src/E2wxApp.cpp b/src/E2wxApp.cpp index 8df27ae..a38314a 100644 --- a/src/E2wxApp.cpp +++ b/src/E2wxApp.cpp @@ -23,7 +23,7 @@ #include "E2wxFrame.h" #include "emulator.h" #include "gui.h" -#include "configep2.h" +#include "e2config.h" #include "e2filesystem.h" #include #include @@ -105,10 +105,6 @@ static std::filesystem::path dirDocuments() { return path_from_string(wxStandardPaths::Get().GetAppDocumentsDir()); } -static std::filesystem::path dirResources() { - return path_from_string(wxStandardPaths::Get().GetResourcesDir()); -} - @@ -313,7 +309,7 @@ void E2wxApp::InitBoostLog() { void E2wxApp::StartEmulator() { this->emu = new Emulator(); - Config cfg(this->arg_configfile, this->opt_config_from_prefs_only); + E2Config cfg(this->arg_configfile, this->opt_config_from_prefs_only); this->emu->config(cfg); this->emu->init(); this->emu_timer = new EmuTimer(this->emu); diff --git a/src/card.cpp b/src/card.cpp index 46463aa..7ad3119 100644 --- a/src/card.cpp +++ b/src/card.cpp @@ -16,7 +16,7 @@ along with this program. If not, see . */ #include "card.h" -#include "configep2.h" +#include "e2config.h" Card::Card(): rom(0x0100), diff --git a/src/configep2.cpp b/src/e2config.cpp similarity index 93% rename from src/configep2.cpp rename to src/e2config.cpp index f4948bb..39e1241 100644 --- a/src/configep2.cpp +++ b/src/e2config.cpp @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "configep2.h" +#include "e2config.h" #include "E2wxApp.h" #include "e2filesystem.h" @@ -68,10 +68,10 @@ static std::uint16_t memory_block_size(const std::string &block_size) { -Config::Config(const std::filesystem::path& f, bool p): file_path {f}, prefs_only {p} { +E2Config::E2Config(const std::filesystem::path& f, bool p): file_path {f}, prefs_only {p} { } -Config::~Config() { +E2Config::~E2Config() { } static void strip_comment(std::string& str) @@ -114,7 +114,7 @@ static void trim(std::string& str) * If successful, returns an open stream, caller is responsible for deleting it * Otherwise, returns null */ -std::ifstream *Config::openFilePref(const wxString& s_name) { +std::ifstream *E2Config::openFilePref(const wxString& s_name) { std::ifstream *ret = nullptr; @@ -163,7 +163,7 @@ std::ifstream *Config::openFilePref(const wxString& s_name) { return ret; } -std::ifstream *Config::openFileExternal(const std::filesystem::path& path) { +std::ifstream *E2Config::openFileExternal(const std::filesystem::path& path) { std::ifstream *ret = nullptr; const std::filesystem::path p = valid_input_file(path); @@ -187,7 +187,7 @@ static const std::array rs_path_legacy{ "./epple2.conf", }; -std::ifstream *Config::openFileLegacy() { +std::ifstream *E2Config::openFileLegacy() { std::ifstream *ret = nullptr; BOOST_LOG_TRIVIAL(warning) << "Searching for config file in legacy locations..."; @@ -206,7 +206,7 @@ std::ifstream *Config::openFileLegacy() { * the user, either on command line, or via preferences, allowing for * backward compatibility with legacy file locations. */ -std::ifstream *Config::openFile() { +std::ifstream *E2Config::openFile() { std::ifstream *ret = nullptr; if (this->file_path.empty()) { @@ -266,7 +266,7 @@ std::ifstream *Config::openFile() { -void Config::parse(MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revision, ScreenImage& gui, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Apple2* apple2) { +void E2Config::parse(MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revision, ScreenImage& gui, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Apple2* apple2) { std::ifstream *p_ifstream_config = openFile(); if (p_ifstream_config == nullptr) { @@ -316,7 +316,7 @@ void Config::parse(MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revis -void Config::parseLine(const std::string& line, MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revision, ScreenImage& gui, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Apple2* apple2) { +void E2Config::parseLine(const std::string& line, MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revision, ScreenImage& gui, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Apple2* apple2) { try { tryParseLine(line, ram, rom, slts, revision, gui, cassetteIn, cassetteOut, apple2); } catch (const ConfigException& err) { @@ -331,7 +331,7 @@ static std::string filter_row(const std::string &row) { return std::string(1, static_cast (std::toupper(row[0]))); } -void Config::tryParseLine(const std::string& line, MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revision, ScreenImage& gui, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Apple2* apple2) { +void E2Config::tryParseLine(const std::string& line, MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revision, ScreenImage& gui, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Apple2* apple2) { std::istringstream tok(line); std::string cmd; @@ -551,9 +551,9 @@ void Config::tryParseLine(const std::string& line, MemoryRandomAccess& ram, Memo -unsigned char Config::disk_mask(0); +unsigned char E2Config::disk_mask(0); -void Config::loadDisk(Slots& slts, int slot, int drive, const std::string& fnib) { +void E2Config::loadDisk(Slots& slts, int slot, int drive, const std::string& fnib) { if (drive < 1 || 2 < drive) { throw ConfigException("Invalid drive; must be 1 or 2"); } @@ -569,7 +569,7 @@ void Config::loadDisk(Slots& slts, int slot, int drive, const std::string& fnib) controller->loadDisk(drive - 1, fnib); } -void Config::unloadDisk(Slots& slts, int slot, int drive) { +void E2Config::unloadDisk(Slots& slts, int slot, int drive) { if (drive < 1 || 2 < drive) { throw ConfigException("Invalid drive; must be 1 or 2"); } @@ -584,14 +584,14 @@ void Config::unloadDisk(Slots& slts, int slot, int drive) { controller->unloadDisk(drive - 1); } -void Config::saveDisk(Slots& slts, int slot, int drive) { +void E2Config::saveDisk(Slots& slts, int slot, int drive) { if (drive < 1 || 2 < drive) { throw ConfigException("Invalid drive; must be 1 or 2"); } slts.get(slot)->save(drive - 1); } -void Config::insertCard(const std::string& cardType, int slot, Slots& slts, ScreenImage& gui, std::istringstream& tok) { +void E2Config::insertCard(const std::string& cardType, int slot, Slots& slts, ScreenImage& gui, std::istringstream& tok) { if (slot < 0 || 8 <= slot) { throw ConfigException("Invalid slot number"); } diff --git a/src/configep2.h b/src/e2config.h similarity index 96% rename from src/configep2.h rename to src/e2config.h index 03845e1..c819990 100644 --- a/src/configep2.h +++ b/src/e2config.h @@ -38,7 +38,7 @@ public: // TODO split out all static things into their own class (and don't make them static) // Remember that, besides config, also command line entry calls parseLine // This will also help with adding menu items in place of commands -class Config { +class E2Config { private: const std::filesystem::path file_path; const bool prefs_only; @@ -55,8 +55,8 @@ private: static void tryParseLine(const std::string& line, MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revision, ScreenImage& gui, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Apple2* apple2); public: - Config(const std::filesystem::path& f, bool p); - ~Config(); + E2Config(const std::filesystem::path& f, bool p); + ~E2Config(); void parse(MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revision, ScreenImage& gui, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Apple2* apple2); static void parseLine(const std::string& line, MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revision, ScreenImage& gui, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Apple2* apple2); diff --git a/src/emulator.cpp b/src/emulator.cpp index 3c10053..9500115 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -16,7 +16,7 @@ along with this program. If not, see . */ #include "emulator.h" -#include "configep2.h" +#include "e2config.h" #include "e2const.h" #include @@ -74,7 +74,7 @@ void Emulator::powerOffComputer() { this->timable = &this->videoStatic; } -void Emulator::config(Config& cfg) { +void Emulator::config(E2Config& cfg) { cfg.parse(this->apple2.ram, this->apple2.rom, this->apple2.slts, this->apple2.revision, this->screenImage, this->apple2.cassetteIn, this->apple2.cassetteOut, &this->apple2); this->apple2.ram.dump_config(); } @@ -479,7 +479,7 @@ void Emulator::processCommand() { return; } - Config::parseLine(cmdline, this->apple2.ram, this->apple2.rom, this->apple2.slts, this->apple2.revision, this->screenImage, this->apple2.cassetteIn, this->apple2.cassetteOut, NULL); + E2Config::parseLine(cmdline, this->apple2.ram, this->apple2.rom, this->apple2.slts, this->apple2.revision, this->screenImage, this->apple2.cassetteIn, this->apple2.cassetteOut, NULL); cmdline.erase(cmdline.begin(), cmdline.end()); } diff --git a/src/emulator.h b/src/emulator.h index 322e782..308358c 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -30,7 +30,7 @@ #include class Timable; -class Config; +class E2Config; class Emulator { @@ -73,7 +73,7 @@ public: Emulator(); virtual ~Emulator(); - void config(Config& cfg); + void config(E2Config& cfg); virtual void init();