Some more renaming.

This commit is contained in:
David Given
2025-10-14 23:16:56 +02:00
parent f63c8dadf1
commit 157ec569b2
10 changed files with 63 additions and 65 deletions

View File

@@ -680,7 +680,7 @@ TracksAndSectors readAndDecodeTrack(const DiskLayout& diskLayout,
void readDiskCommand(const DiskLayout& diskLayout, void readDiskCommand(const DiskLayout& diskLayout,
FluxSource& fluxSource, FluxSource& fluxSource,
Decoder& decoder, Decoder& decoder,
Disk& decodedDisk) Disk& disk)
{ {
std::unique_ptr<FluxSinkFactory> outputFluxSinkFactory; std::unique_ptr<FluxSinkFactory> outputFluxSinkFactory;
if (globalConfig()->decoder().has_copy_flux_to()) if (globalConfig()->decoder().has_copy_flux_to())
@@ -705,12 +705,12 @@ void readDiskCommand(const DiskLayout& diskLayout,
auto [trackFluxes, trackSectors] = auto [trackFluxes, trackSectors] =
readAndDecodeTrack(diskLayout, fluxSource, decoder, ltl); readAndDecodeTrack(diskLayout, fluxSource, decoder, ltl);
for (const auto& flux : trackFluxes) for (const auto& flux : trackFluxes)
decodedDisk.tracksByPhysicalLocation.emplace( disk.tracksByPhysicalLocation.emplace(
CylinderHead{ CylinderHead{
flux->ptl->physicalCylinder, flux->ptl->physicalHead}, flux->ptl->physicalCylinder, flux->ptl->physicalHead},
flux); flux);
for (const auto& sector : trackSectors) for (const auto& sector : trackSectors)
decodedDisk.sectorsByPhysicalLocation.emplace( disk.sectorsByPhysicalLocation.emplace(
sector->physicalLocation.value(), sector); sector->physicalLocation.value(), sector);
if (outputFluxSink) if (outputFluxSink)
@@ -778,34 +778,33 @@ void readDiskCommand(const DiskLayout& diskLayout,
log(TrackReadLogMessage{trackFluxes, trackSectors}); log(TrackReadLogMessage{trackFluxes, trackSectors});
std::vector<std::shared_ptr<const Sector>> all_sectors; std::vector<std::shared_ptr<const Sector>> all_sectors;
for (auto& [ch, sector] : decodedDisk.sectorsByPhysicalLocation) for (auto& [ch, sector] : disk.sectorsByPhysicalLocation)
all_sectors.push_back(sector); all_sectors.push_back(sector);
all_sectors = collectSectors(all_sectors); all_sectors = collectSectors(all_sectors);
decodedDisk.image = std::make_shared<Image>(all_sectors); disk.image = std::make_shared<Image>(all_sectors);
/* Log a _copy_ of the decodedDisk structure so that the logger /* Log a _copy_ of the disk structure so that the logger
* doesn't see the decodedDisk get mutated in subsequent reads. */ * doesn't see the disk get mutated in subsequent reads. */
log(DiskReadLogMessage{std::make_shared<Disk>(decodedDisk)}); log(DiskReadLogMessage{std::make_shared<Disk>(disk)});
} }
} }
if (!decodedDisk.image) if (!disk.image)
decodedDisk.image = std::make_shared<Image>(); disk.image = std::make_shared<Image>();
log(EndOperationLogMessage{"Read complete"}); log(EndOperationLogMessage{"Read complete"});
} }
void readDiskCommand(const DiskLayout& diskLayout, void readDiskCommand(const DiskLayout& diskLayout,
FluxSource& fluxsource, FluxSource& fluxSource,
Decoder& decoder, Decoder& decoder,
ImageWriter& writer) ImageWriter& writer)
{ {
Disk decodedDisk; Disk disk;
readDiskCommand(diskLayout, fluxsource, decoder, decodedDisk); readDiskCommand(diskLayout, fluxSource, decoder, disk);
writer.printMap(*decodedDisk.image); writer.printMap(*disk.image);
if (globalConfig()->decoder().has_write_csv_to()) if (globalConfig()->decoder().has_write_csv_to())
writer.writeCsv( writer.writeCsv(*disk.image, globalConfig()->decoder().write_csv_to());
*decodedDisk.image, globalConfig()->decoder().write_csv_to()); writer.writeImage(*disk.image);
writer.writeImage(*decodedDisk.image);
} }

View File

@@ -122,9 +122,9 @@ extern TracksAndSectors readAndDecodeTrack(const DiskLayout& diskLayout,
const std::shared_ptr<const LogicalTrackLayout>& ltl); const std::shared_ptr<const LogicalTrackLayout>& ltl);
extern void readDiskCommand(const DiskLayout& diskLayout, extern void readDiskCommand(const DiskLayout& diskLayout,
FluxSource& fluxsource, FluxSource& fluxSource,
Decoder& decoder, Decoder& decoder,
Disk& diskflux); Disk& disk);
extern void readDiskCommand(const DiskLayout& diskLayout, extern void readDiskCommand(const DiskLayout& diskLayout,
FluxSource& source, FluxSource& source,
Decoder& decoder, Decoder& decoder,

View File

@@ -96,12 +96,12 @@ public:
{ {
auto* fluxSource = GetContext().GetFluxSource(); auto* fluxSource = GetContext().GetFluxSource();
auto* decoder = GetContext().GetDecoder(); auto* decoder = GetContext().GetDecoder();
auto diskflux = readDiskCommand(*fluxSource, *decoder); auto disk = readDiskCommand(*fluxSource, *decoder);
runOnUiThread( runOnUiThread(
[&]() [&]()
{ {
visualiser->SetDiskData(diskflux); visualiser->SetDiskData(disk);
}); });
}); });
} }

View File

@@ -17,11 +17,11 @@ AbstractSectorView::AbstractSectorView(const std::string& name):
void AbstractSectorView::drawContent() void AbstractSectorView::drawContent()
{ {
auto diskFlux = Datastore::getDisk(); auto disk = Datastore::getDisk();
auto diskLayout = Datastore::getDiskLayout(); auto diskLayout = Datastore::getDiskLayout();
if (!diskFlux || !diskLayout) if (!disk || !diskLayout)
return; return;
auto& image = diskFlux->image; auto& image = disk->image;
if (!image) if (!image)
return; return;

View File

@@ -43,9 +43,9 @@ static void saveSectorImage()
void ControlPanelView::drawContent() void ControlPanelView::drawContent()
{ {
auto diskFlux = Datastore::getDisk(); auto disk = Datastore::getDisk();
bool busy = Datastore::isBusy(); bool busy = Datastore::isBusy();
bool hasImage = diskFlux && diskFlux->image; bool hasImage = disk && disk->image;
if (ImGui::BeginTable("controlPanelOuter", if (ImGui::BeginTable("controlPanelOuter",
3, 3,
@@ -99,12 +99,12 @@ void ControlPanelView::drawContent()
button(ICON_TA_REPEAT, button(ICON_TA_REPEAT,
"fluxengine.view.controlpanel.rereadBad"_lang, "fluxengine.view.controlpanel.rereadBad"_lang,
nullptr, nullptr,
busy || !diskFlux); busy || !disk);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
button(ICON_TA_DOWNLOAD, button(ICON_TA_DOWNLOAD,
"fluxengine.view.controlpanel.writeFlux"_lang, "fluxengine.view.controlpanel.writeFlux"_lang,
saveFluxFile, saveFluxFile,
busy || !diskFlux); busy || !disk);
ImGui::TableNextRow(); ImGui::TableNextRow();
button(ICON_VS_FOLDER_OPENED, button(ICON_VS_FOLDER_OPENED,

View File

@@ -34,7 +34,7 @@
using hex::operator""_lang; using hex::operator""_lang;
static std::shared_ptr<const Disk> diskFlux; static std::shared_ptr<const Disk> disk;
static std::shared_ptr<Image> wtImage; static std::shared_ptr<Image> wtImage;
static std::deque<std::function<void()>> pendingTasks; static std::deque<std::function<void()>> pendingTasks;
@@ -246,7 +246,7 @@ void Datastore::init()
Events::SeekToTrackViaPhysicalLocation::subscribe( Events::SeekToTrackViaPhysicalLocation::subscribe(
[](CylinderHead physicalLocation) [](CylinderHead physicalLocation)
{ {
if (!diskFlux || !diskLayout) if (!disk || !diskLayout)
return; return;
auto ptlo = findOptionally(diskLayout->layoutByPhysicalLocation, auto ptlo = findOptionally(diskLayout->layoutByPhysicalLocation,
{physicalLocation.cylinder, physicalLocation.head}); {physicalLocation.cylinder, physicalLocation.head});
@@ -294,7 +294,7 @@ std::shared_ptr<const DiskLayout> Datastore::getDiskLayout()
std::shared_ptr<const Disk> Datastore::getDisk() std::shared_ptr<const Disk> Datastore::getDisk()
{ {
return diskFlux; return disk;
} }
static void badConfiguration() static void badConfiguration()
@@ -332,7 +332,7 @@ static void wtClearDiskData()
[] []
{ {
::wtImage = nullptr; ::wtImage = nullptr;
::diskFlux = nullptr; ::disk = nullptr;
}); });
} }
@@ -496,10 +496,10 @@ void Datastore::onLogMessage(const AnyLogMessage& message)
[&](std::shared_ptr<const DiskReadLogMessage> m) [&](std::shared_ptr<const DiskReadLogMessage> m)
{ {
/* This is where data gets from the worker thread to the GUI. /* This is where data gets from the worker thread to the GUI.
* The diskFlux here is a copy of the one being worked on, and * The disk here is a copy of the one being worked on, and
* is guaranteed not to change. */ * is guaranteed not to change. */
diskFlux = m->disk; disk = m->disk;
}, },
/* Large-scale operation start. */ /* Large-scale operation start. */
@@ -544,8 +544,8 @@ void Datastore::beginRead()
auto fluxSource = FluxSource::create(globalConfig()); auto fluxSource = FluxSource::create(globalConfig());
auto decoder = Arch::createDecoder(globalConfig()); auto decoder = Arch::createDecoder(globalConfig());
auto diskflux = std::make_shared<Disk>(); auto disk = std::make_shared<Disk>();
readDiskCommand(*diskLayout, *fluxSource, *decoder, *diskflux); readDiskCommand(*diskLayout, *fluxSource, *decoder, *disk);
} }
catch (...) catch (...)
{ {
@@ -605,7 +605,7 @@ void Datastore::beginWrite()
} }
} }
auto image = diskFlux->image; auto image = disk->image;
writeDiskCommand(*diskLayout, writeDiskCommand(*diskLayout,
*image, *image,
*encoder, *encoder,
@@ -705,11 +705,11 @@ void Datastore::readImage(const std::fs::path& path)
std::shared_ptr<Image> image = std::shared_ptr<Image> image =
ImageReader::create(globalConfig())->readImage(); ImageReader::create(globalConfig())->readImage();
auto diskFlux = wtMakeDiskDataFromImage(image); auto disk = wtMakeDiskDataFromImage(image);
hex::TaskManager::doLater( hex::TaskManager::doLater(
[=] [=]
{ {
::diskFlux = diskFlux; ::disk = disk;
}); });
} }
catch (...) catch (...)
@@ -735,16 +735,16 @@ void Datastore::writeFluxFile(const std::fs::path& path)
wtRebuildConfiguration(); wtRebuildConfiguration();
wtWaitForUiThreadToCatchUp(); wtWaitForUiThreadToCatchUp();
if (!diskFlux || !diskFlux->image) if (!disk || !disk->image)
error("no loaded image"); error("no loaded image");
if (diskFlux->image->getGeometry().totalBytes != if (disk->image->getGeometry().totalBytes !=
diskLayout->totalBytes) diskLayout->totalBytes)
error( error(
"loaded image is not the right size for this " "loaded image is not the right size for this "
"format"); "format");
globalConfig().setFluxSink(path.string()); globalConfig().setFluxSink(path.string());
auto fluxSource = FluxSource::createMemoryFluxSource(*diskFlux); auto fluxSource = FluxSource::createMemoryFluxSource(*disk);
auto fluxSinkFactory = FluxSinkFactory::create(globalConfig()); auto fluxSinkFactory = FluxSinkFactory::create(globalConfig());
writeRawDiskCommand(*diskLayout, *fluxSource, *fluxSinkFactory); writeRawDiskCommand(*diskLayout, *fluxSource, *fluxSinkFactory);
} }
@@ -781,11 +781,11 @@ void Datastore::createBlankImage()
filesystem->create(false, "FLUXENGINE"); filesystem->create(false, "FLUXENGINE");
filesystem->flushChanges(); filesystem->flushChanges();
auto diskFlux = wtMakeDiskDataFromImage(image); auto disk = wtMakeDiskDataFromImage(image);
hex::TaskManager::doLater( hex::TaskManager::doLater(
[=] [=]
{ {
::diskFlux = diskFlux; ::disk = disk;
}); });
} }
catch (...) catch (...)

View File

@@ -60,9 +60,9 @@ void DiskProvider::close() {}
void DiskProvider::readRaw(u64 offset, void* buffer, size_t size) void DiskProvider::readRaw(u64 offset, void* buffer, size_t size)
{ {
const auto& diskFlux = Datastore::getDisk(); const auto& disk = Datastore::getDisk();
const auto& diskLayout = Datastore::getDiskLayout(); const auto& diskLayout = Datastore::getDiskLayout();
if (diskFlux && diskFlux->image && diskLayout) if (disk && disk->image && diskLayout)
{ {
while (size != 0) while (size != 0)
{ {
@@ -74,7 +74,7 @@ void DiskProvider::readRaw(u64 offset, void* buffer, size_t size)
unsigned realOffset = it->first; unsigned realOffset = it->first;
auto logicalLocation = it->second; auto logicalLocation = it->second;
auto sector = diskFlux->image->get(logicalLocation); auto sector = disk->image->get(logicalLocation);
auto& ltl = diskLayout->layoutByLogicalLocation.at( auto& ltl = diskLayout->layoutByLogicalLocation.at(
logicalLocation.trackLocation()); logicalLocation.trackLocation());
unsigned blockOffset = realOffset - offset; unsigned blockOffset = realOffset - offset;

View File

@@ -20,6 +20,6 @@ DiskLayout::LayoutBounds ImageView::getBounds()
std::shared_ptr<const Sector> ImageView::getSector( std::shared_ptr<const Sector> ImageView::getSector(
unsigned logicalCylinder, unsigned logicalHead, unsigned sectorId) unsigned logicalCylinder, unsigned logicalHead, unsigned sectorId)
{ {
auto diskFlux = Datastore::getDisk(); auto disk = Datastore::getDisk();
return diskFlux->image->get({logicalCylinder, logicalHead, sectorId}); return disk->image->get({logicalCylinder, logicalHead, sectorId});
} }

View File

@@ -25,13 +25,12 @@ DiskLayout::LayoutBounds PhysicalView::getBounds()
std::shared_ptr<const Sector> PhysicalView::getSector( std::shared_ptr<const Sector> PhysicalView::getSector(
unsigned physicalCylinder, unsigned physicalHead, unsigned sectorId) unsigned physicalCylinder, unsigned physicalHead, unsigned sectorId)
{ {
const auto& diskFlux = Datastore::getDisk(); const auto& disk = Datastore::getDisk();
const auto& diskLayout = Datastore::getDiskLayout(); const auto& diskLayout = Datastore::getDiskLayout();
const auto& ptl = findOrDefault( const auto& ptl = findOrDefault(
diskLayout->layoutByPhysicalLocation, {physicalCylinder, physicalHead}); diskLayout->layoutByPhysicalLocation, {physicalCylinder, physicalHead});
if (!ptl) if (!ptl)
return nullptr; return nullptr;
const auto& ltl = ptl->logicalTrackLayout; const auto& ltl = ptl->logicalTrackLayout;
return diskFlux->image->get( return disk->image->get({ltl->logicalCylinder, ltl->logicalHead, sectorId});
{ltl->logicalCylinder, ltl->logicalHead, sectorId});
} }

View File

@@ -65,11 +65,11 @@ SummaryView::SummaryView():
} }
static std::set<std::shared_ptr<const Sector>> findSectors( static std::set<std::shared_ptr<const Sector>> findSectors(
const Disk& diskFlux, unsigned physicalCylinder, unsigned physicalHead) const Disk& disk, unsigned physicalCylinder, unsigned physicalHead)
{ {
std::set<std::shared_ptr<const Sector>> sectors; std::set<std::shared_ptr<const Sector>> sectors;
auto [startIt, endIt] = diskFlux.sectorsByPhysicalLocation.equal_range( auto [startIt, endIt] = disk.sectorsByPhysicalLocation.equal_range(
{physicalCylinder, physicalHead}); {physicalCylinder, physicalHead});
for (auto it = startIt; it != endIt; it++) for (auto it = startIt; it != endIt; it++)
sectors.insert(it->second); sectors.insert(it->second);
@@ -84,10 +84,10 @@ struct TrackAnalysis
}; };
static TrackAnalysis analyseTrack( static TrackAnalysis analyseTrack(
const Disk& diskFlux, unsigned physicalCylinder, unsigned physicalHead) const Disk& disk, unsigned physicalCylinder, unsigned physicalHead)
{ {
TrackAnalysis result = {}; TrackAnalysis result = {};
auto sectors = findSectors(diskFlux, physicalCylinder, physicalHead); auto sectors = findSectors(disk, physicalCylinder, physicalHead);
result.colour = ImGui::GetColorU32(ImGuiCol_TextDisabled); result.colour = ImGui::GetColorU32(ImGuiCol_TextDisabled);
result.tooltip = "No data"; result.tooltip = "No data";
if (!sectors.empty()) if (!sectors.empty())
@@ -137,7 +137,7 @@ static void drawPhysicalMap(unsigned minPhysicalCylinder,
unsigned maxPhysicalCylinder, unsigned maxPhysicalCylinder,
unsigned minPhysicalHead, unsigned minPhysicalHead,
unsigned maxPhysicalHead, unsigned maxPhysicalHead,
const Disk& diskFlux) const Disk& disk)
{ {
int numPhysicalCylinders = maxPhysicalCylinder - minPhysicalCylinder + 1; int numPhysicalCylinders = maxPhysicalCylinder - minPhysicalCylinder + 1;
int numPhysicalHeads = maxPhysicalHead - minPhysicalHead + 1; int numPhysicalHeads = maxPhysicalHead - minPhysicalHead + 1;
@@ -185,7 +185,7 @@ static void drawPhysicalMap(unsigned minPhysicalCylinder,
cylinder <= maxPhysicalCylinder; cylinder <= maxPhysicalCylinder;
cylinder++) cylinder++)
{ {
auto [tooltip, colour] = analyseTrack(diskFlux, cylinder, head); auto [tooltip, colour] = analyseTrack(disk, cylinder, head);
ImGui::PushStyleColor(ImGuiCol_Header, colour); ImGui::PushStyleColor(ImGuiCol_Header, colour);
DEFER(ImGui::PopStyleColor()); DEFER(ImGui::PopStyleColor());
ImGui::PushFont(NULL, originalFontSize); ImGui::PushFont(NULL, originalFontSize);
@@ -219,7 +219,7 @@ static void drawLogicalMap(unsigned minPhysicalCylinder,
unsigned maxPhysicalCylinder, unsigned maxPhysicalCylinder,
unsigned minPhysicalHead, unsigned minPhysicalHead,
unsigned maxPhysicalHead, unsigned maxPhysicalHead,
const Disk& diskFlux, const Disk& disk,
const DiskLayout& diskLayout) const DiskLayout& diskLayout)
{ {
auto originalFontSize = ImGui::GetFontSize(); auto originalFontSize = ImGui::GetFontSize();
@@ -278,7 +278,7 @@ static void drawLogicalMap(unsigned minPhysicalCylinder,
if (ptl->groupOffset == 0) if (ptl->groupOffset == 0)
{ {
auto [tooltip, colour] = auto [tooltip, colour] =
analyseTrack(diskFlux, physicalCylinder, physicalHead); analyseTrack(disk, physicalCylinder, physicalHead);
ImGui::PushStyleColor(ImGuiCol_Header, colour); ImGui::PushStyleColor(ImGuiCol_Header, colour);
DEFER(ImGui::PopStyleColor()); DEFER(ImGui::PopStyleColor());
@@ -325,9 +325,9 @@ static void drawLogicalMap(unsigned minPhysicalCylinder,
void SummaryView::drawContent() void SummaryView::drawContent()
{ {
auto diskFlux = Datastore::getDisk(); auto disk = Datastore::getDisk();
auto diskLayout = Datastore::getDiskLayout(); auto diskLayout = Datastore::getDiskLayout();
if (!diskFlux || !diskLayout) if (!disk || !diskLayout)
return; return;
auto [minPhysicalCylinder, auto [minPhysicalCylinder,
@@ -337,7 +337,7 @@ void SummaryView::drawContent()
int numPhysicalCylinders = maxPhysicalCylinder - minPhysicalCylinder + 1; int numPhysicalCylinders = maxPhysicalCylinder - minPhysicalCylinder + 1;
int numPhysicalHeads = maxPhysicalHead - minPhysicalHead + 1; int numPhysicalHeads = maxPhysicalHead - minPhysicalHead + 1;
if (diskFlux) if (disk)
{ {
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, {1, 1}); ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, {1, 1});
DEFER(ImGui::PopStyleVar()); DEFER(ImGui::PopStyleVar());
@@ -354,7 +354,7 @@ void SummaryView::drawContent()
maxPhysicalCylinder, maxPhysicalCylinder,
minPhysicalHead, minPhysicalHead,
maxPhysicalHead, maxPhysicalHead,
*diskFlux); *disk);
ImGuiExt::TextFormattedCenteredHorizontal( ImGuiExt::TextFormattedCenteredHorizontal(
"fluxengine.view.summary.logical"_lang); "fluxengine.view.summary.logical"_lang);
@@ -363,7 +363,7 @@ void SummaryView::drawContent()
maxPhysicalCylinder, maxPhysicalCylinder,
minPhysicalHead, minPhysicalHead,
maxPhysicalHead, maxPhysicalHead,
*diskFlux, *disk,
*diskLayout); *diskLayout);
ImGui::Dummy(ImVec2(0, ImGui::GetFontSize())); ImGui::Dummy(ImVec2(0, ImGui::GetFontSize()));