Convert IN_* props of jobs to ctor-initialised readonly fields
This commit is contained in:
parent
f284fda3a6
commit
333cae15cd
|
@ -40,7 +40,7 @@ namespace BizHawk.Client.DiscoHawk
|
|||
Cursor = Cursors.WaitCursor;
|
||||
foreach (var file in files)
|
||||
{
|
||||
var job = new DiscMountJob { IN_FromPath = file };
|
||||
var job = new DiscMountJob(fromPath: file);
|
||||
job.Run();
|
||||
var disc = job.OUT_Disc;
|
||||
if (job.OUT_ErrorLevel)
|
||||
|
|
|
@ -23,8 +23,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
/// </summary>
|
||||
public static Disc LoadAutomagic(string path)
|
||||
{
|
||||
var job = new DiscMountJob { IN_FromPath = path };
|
||||
//job.IN_DiscInterface = DiscInterface.MednaDisc; //TEST
|
||||
var job = new DiscMountJob(fromPath: path/*, discInterface: DiscInterface.MednaDisc <-- TEST*/);
|
||||
job.Run();
|
||||
return job.OUT_Disc;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
private static Disc CreateImpl(DiscType? type, string path, Action<string> errorCallback)
|
||||
{
|
||||
//--- load the disc in a context which will let us abort if it's going to take too long
|
||||
var discMountJob = new DiscMountJob { IN_FromPath = path, IN_SlowLoadAbortThreshold = 8 };
|
||||
var discMountJob = new DiscMountJob(fromPath: path, slowLoadAbortThreshold: 8);
|
||||
discMountJob.Run();
|
||||
var disc = discMountJob.OUT_Disc ?? throw new InvalidOperationException($"Can't find the file specified: {path}");
|
||||
|
||||
|
|
|
@ -570,7 +570,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
}
|
||||
|
||||
//analyze the RAWTocEntries to figure out what type of track track 1 is
|
||||
var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job() { Entries = disc.RawTOCEntries };
|
||||
var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job(disc.RawTOCEntries);
|
||||
tocSynth.Run();
|
||||
|
||||
//Add sectors for the mandatory track 1 pregap, which isn't stored in the CCD file
|
||||
|
|
|
@ -120,16 +120,17 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
|
||||
internal class CompileCueJob : DiscJob
|
||||
{
|
||||
/// <summary>
|
||||
/// input: the CueFile to analyze
|
||||
/// </summary>
|
||||
public CUE_File IN_CueFile { private get; set; }
|
||||
private readonly CUE_File IN_CueFile;
|
||||
|
||||
/// <summary>
|
||||
/// The context used for this compiling job
|
||||
/// TODO - rename something like context
|
||||
/// </summary>
|
||||
public CUE_Context IN_CueContext { internal get; set; }
|
||||
internal readonly CUE_Context IN_CueContext;
|
||||
|
||||
/// <param name="cueFile">the CueFile to analyze</param>
|
||||
/// <param name="cueContext">The context used for this compiling job</param>
|
||||
public CompileCueJob(CUE_File cueFile, CUE_Context cueContext)
|
||||
{
|
||||
IN_CueFile = cueFile;
|
||||
IN_CueContext = cueContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// output: high level disc info
|
||||
|
|
|
@ -32,10 +32,10 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
/// </summary>
|
||||
internal class LoadCueJob : DiscJob
|
||||
{
|
||||
/// <summary>
|
||||
/// The results of the compile job, a prerequisite for this
|
||||
/// </summary>
|
||||
public CompileCueJob IN_CompileJob { private get; set; }
|
||||
private readonly CompileCueJob IN_CompileJob;
|
||||
|
||||
/// <param name="compileJob">The results of the compile job, a prerequisite for this</param>
|
||||
public LoadCueJob(CompileCueJob compileJob) => IN_CompileJob = compileJob;
|
||||
|
||||
/// <summary>
|
||||
/// The resulting disc
|
||||
|
@ -379,12 +379,11 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
|
||||
|
||||
//add RawTOCEntries A0 A1 A2 to round out the TOC
|
||||
var TOCMiscInfo = new Synthesize_A0A1A2_Job {
|
||||
IN_FirstRecordedTrackNumber = IN_CompileJob.OUT_CompiledDiscInfo.FirstRecordedTrackNumber,
|
||||
IN_LastRecordedTrackNumber = IN_CompileJob.OUT_CompiledDiscInfo.LastRecordedTrackNumber,
|
||||
IN_Session1Format = IN_CompileJob.OUT_CompiledDiscInfo.SessionFormat,
|
||||
IN_LeadoutTimestamp = OUT_Disc._Sectors.Count
|
||||
};
|
||||
var TOCMiscInfo = new Synthesize_A0A1A2_Job(
|
||||
firstRecordedTrackNumber: IN_CompileJob.OUT_CompiledDiscInfo.FirstRecordedTrackNumber,
|
||||
lastRecordedTrackNumber: IN_CompileJob.OUT_CompiledDiscInfo.LastRecordedTrackNumber,
|
||||
session1Format: IN_CompileJob.OUT_CompiledDiscInfo.SessionFormat,
|
||||
leadoutTimestamp: OUT_Disc._Sectors.Count);
|
||||
TOCMiscInfo.Run(OUT_Disc.RawTOCEntries);
|
||||
|
||||
//TODO - generate leadout, or delegates at least
|
||||
|
|
|
@ -14,22 +14,23 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
|||
/// </summary>
|
||||
internal class ParseCueJob : DiscJob
|
||||
{
|
||||
/// <summary>
|
||||
/// input: the cue string to parse
|
||||
/// </summary>
|
||||
public string IN_CueString { private get; set; }
|
||||
private readonly string IN_CueString;
|
||||
|
||||
private readonly bool IN_Strict;
|
||||
|
||||
/// <param name="cueString">the cue string to parse</param>
|
||||
/// <param name="strict">Indicates whether parsing will be strict or lenient</param>
|
||||
public ParseCueJob(string cueString, bool strict = false)
|
||||
{
|
||||
IN_CueString = cueString;
|
||||
IN_Strict = strict;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// output: the resulting minimally-processed cue file
|
||||
/// </summary>
|
||||
public CUE_File OUT_CueFile { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether parsing will be strict or lenient
|
||||
/// </summary>
|
||||
public bool IN_Strict { private get; set; } = false;
|
||||
|
||||
|
||||
private class CueLineParser
|
||||
{
|
||||
private int index;
|
||||
|
|
|
@ -709,7 +709,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
}
|
||||
|
||||
//analyze the RAWTocEntries to figure out what type of track track 1 is
|
||||
var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job() { Entries = disc.RawTOCEntries };
|
||||
var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job(disc.RawTOCEntries);
|
||||
tocSynth.Run();
|
||||
|
||||
// now build the sectors
|
||||
|
|
|
@ -11,27 +11,43 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
/// </summary>
|
||||
public partial class DiscMountJob : DiscJob
|
||||
{
|
||||
/// <summary>
|
||||
/// The filename to be loaded
|
||||
/// </summary>
|
||||
public string IN_FromPath { private get; set; }
|
||||
private readonly string IN_FromPath;
|
||||
|
||||
/// <summary>
|
||||
/// Slow-loading cues won't finish loading if this threshold is exceeded.
|
||||
/// Set to 10 to always load a cue
|
||||
/// </summary>
|
||||
public int IN_SlowLoadAbortThreshold { private get; set; } = 10;
|
||||
private readonly DiscMountPolicy IN_DiscMountPolicy;
|
||||
|
||||
/// <summary>
|
||||
/// Cryptic policies to be used when mounting the disc.
|
||||
/// </summary>
|
||||
public DiscMountPolicy IN_DiscMountPolicy { private get; set; } = new DiscMountPolicy();
|
||||
private readonly DiscInterface IN_DiscInterface;
|
||||
|
||||
/// <summary>
|
||||
private readonly int IN_SlowLoadAbortThreshold;
|
||||
|
||||
/// <param name="fromPath">The filename to be loaded</param>
|
||||
/// <param name="discMountPolicy">Cryptic policies to be used when mounting the disc.</param>
|
||||
/// <param name="discInterface">
|
||||
/// The interface to be used for loading the disc.
|
||||
/// Usually you'll want DiscInterface.BizHawk, but others can be used for A/B testing
|
||||
/// </summary>
|
||||
public DiscInterface IN_DiscInterface { private get; set; } = DiscInterface.BizHawk;
|
||||
/// </param>
|
||||
/// <param name="slowLoadAbortThreshold">
|
||||
/// Slow-loading cues won't finish loading if this threshold is exceeded.
|
||||
/// Set to 10 to always load a cue
|
||||
/// </param>
|
||||
public DiscMountJob(string fromPath, DiscMountPolicy discMountPolicy, DiscInterface discInterface = DiscInterface.BizHawk, int slowLoadAbortThreshold = 10)
|
||||
{
|
||||
IN_FromPath = fromPath;
|
||||
IN_DiscMountPolicy = discMountPolicy;
|
||||
IN_DiscInterface = discInterface;
|
||||
IN_SlowLoadAbortThreshold = slowLoadAbortThreshold;
|
||||
}
|
||||
|
||||
/// <param name="fromPath">The filename to be loaded</param>
|
||||
/// <param name="discInterface">
|
||||
/// The interface to be used for loading the disc.
|
||||
/// Usually you'll want DiscInterface.BizHawk, but others can be used for A/B testing
|
||||
/// </param>
|
||||
/// <param name="slowLoadAbortThreshold">
|
||||
/// Slow-loading cues won't finish loading if this threshold is exceeded.
|
||||
/// Set to 10 to always load a cue
|
||||
/// </param>
|
||||
public DiscMountJob(string fromPath, DiscInterface discInterface = DiscInterface.BizHawk, int slowLoadAbortThreshold = 10)
|
||||
: this(fromPath, new(), discInterface, slowLoadAbortThreshold) {}
|
||||
|
||||
/// <summary>
|
||||
/// The resulting disc
|
||||
|
@ -64,11 +80,11 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
|
||||
//generate toc and structure:
|
||||
//1. TOCRaw from RawTOCEntries
|
||||
var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job { Entries = OUT_Disc.RawTOCEntries };
|
||||
var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job(OUT_Disc.RawTOCEntries);
|
||||
tocSynth.Run();
|
||||
OUT_Disc.TOC = tocSynth.Result;
|
||||
//2. Structure from TOCRaw
|
||||
var structureSynth = new Synthesize_DiscStructure_From_DiscTOC_Job { IN_Disc = OUT_Disc, TOCRaw = OUT_Disc.TOC };
|
||||
var structureSynth = new Synthesize_DiscStructure_From_DiscTOC_Job(OUT_Disc, OUT_Disc.TOC);
|
||||
structureSynth.Run();
|
||||
OUT_Disc.Structure = structureSynth.Result;
|
||||
|
||||
|
@ -89,7 +105,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
var sbiPath = Path.ChangeExtension(IN_FromPath, ".sbi");
|
||||
if (File.Exists(sbiPath) && SBI.SBIFormat.QuickCheckISSBI(sbiPath))
|
||||
{
|
||||
var loadSbiJob = new SBI.LoadSBIJob() { IN_Path = sbiPath };
|
||||
var loadSbiJob = new SBI.LoadSBIJob(sbiPath);
|
||||
loadSbiJob.Run();
|
||||
var applySbiJob = new ApplySBIJob();
|
||||
applySbiJob.Run(OUT_Disc, loadSbiJob.OUT_Data, IN_DiscMountPolicy.SBI_As_Mednafen);
|
||||
|
@ -113,8 +129,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
if (!cfr.IsHardcodedResolve) cfr.SetBaseDirectory(cueDirPath);
|
||||
|
||||
// parse the cue file
|
||||
var parseJob = new ParseCueJob();
|
||||
parseJob.IN_CueString = cueContent;
|
||||
var parseJob = new ParseCueJob(cueContent);
|
||||
var okParse = true;
|
||||
try
|
||||
{
|
||||
|
@ -131,11 +146,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
|
||||
// compile the cue file
|
||||
// includes resolving required bin files and finding out what would processing would need to happen in order to load the cue
|
||||
var compileJob = new CompileCueJob
|
||||
{
|
||||
IN_CueContext = cueContext,
|
||||
IN_CueFile = parseJob.OUT_CueFile
|
||||
};
|
||||
var compileJob = new CompileCueJob(parseJob.OUT_CueFile, cueContext);
|
||||
var okCompile = true;
|
||||
try
|
||||
{
|
||||
|
@ -159,7 +170,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
}
|
||||
|
||||
// actually load it all up
|
||||
var loadJob = new LoadCueJob { IN_CompileJob = compileJob };
|
||||
var loadJob = new LoadCueJob(compileJob);
|
||||
loadJob.Run();
|
||||
//TODO need better handling of log output
|
||||
if (!string.IsNullOrEmpty(loadJob.OUT_Log)) Console.WriteLine(loadJob.OUT_Log);
|
||||
|
|
|
@ -27,18 +27,14 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
sw.WriteLine("BEGIN COMPARE: {0}\nSRC {1} vs DST {2}", infile, loadDiscInterface, cmpif);
|
||||
|
||||
//reload the original disc, with new policies as needed
|
||||
var dmj = new DiscMountJob
|
||||
{
|
||||
IN_DiscInterface = loadDiscInterface,
|
||||
IN_DiscMountPolicy = new DiscMountPolicy { CUE_PregapContradictionModeA = cmpif != DiscInterface.MednaDisc },
|
||||
IN_FromPath = infile
|
||||
};
|
||||
|
||||
var dmj = new DiscMountJob(
|
||||
fromPath: infile,
|
||||
discMountPolicy: new DiscMountPolicy { CUE_PregapContradictionModeA = cmpif != DiscInterface.MednaDisc },
|
||||
discInterface: loadDiscInterface);
|
||||
dmj.Run();
|
||||
|
||||
srcDisc = dmj.OUT_Disc;
|
||||
|
||||
var dstDmj = new DiscMountJob { IN_DiscInterface = cmpif, IN_FromPath = infile };
|
||||
var dstDmj = new DiscMountJob(fromPath: infile, discInterface: cmpif);
|
||||
dstDmj.Run();
|
||||
dstDisc = dstDmj.OUT_Disc;
|
||||
|
||||
|
@ -283,7 +279,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
}
|
||||
|
||||
// TODO - write it out
|
||||
var dmj = new DiscMountJob { IN_DiscInterface = loadDiscInterface, IN_FromPath = infile };
|
||||
var dmj = new DiscMountJob(fromPath: infile, discInterface: loadDiscInterface);
|
||||
dmj.Run();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ namespace BizHawk.Emulation.DiscSystem.SBI
|
|||
/// </summary>
|
||||
internal class LoadSBIJob : DiscJob
|
||||
{
|
||||
/// <summary>
|
||||
/// The file to be loaded
|
||||
/// </summary>
|
||||
public string IN_Path { private get; set; }
|
||||
private readonly string IN_Path;
|
||||
|
||||
/// <param name="path">The file to be loaded</param>
|
||||
public LoadSBIJob(string path) => IN_Path = path;
|
||||
|
||||
/// <summary>
|
||||
/// The resulting interpreted data
|
||||
|
|
|
@ -11,25 +11,29 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
/// </summary>
|
||||
internal class Synthesize_A0A1A2_Job
|
||||
{
|
||||
/// <summary>
|
||||
/// "First Recorded Track Number" value for TOC (usually 1)
|
||||
/// </summary>
|
||||
public int IN_FirstRecordedTrackNumber { private get; set; }
|
||||
private readonly int IN_FirstRecordedTrackNumber;
|
||||
|
||||
/// <summary>
|
||||
/// "Last Recorded Track Number" value for TOC
|
||||
/// </summary>
|
||||
public int IN_LastRecordedTrackNumber { private get; set; }
|
||||
private readonly int IN_LastRecordedTrackNumber;
|
||||
|
||||
/// <summary>
|
||||
/// The absolute timestamp of the lead-out track
|
||||
/// </summary>
|
||||
public int IN_LeadoutTimestamp { private get; set; }
|
||||
private readonly SessionFormat IN_Session1Format;
|
||||
|
||||
/// <summary>
|
||||
/// The session format for this TOC
|
||||
/// </summary>
|
||||
public SessionFormat IN_Session1Format { private get; set; }
|
||||
private readonly int IN_LeadoutTimestamp;
|
||||
|
||||
/// <param name="firstRecordedTrackNumber">"First Recorded Track Number" value for TOC (usually 1)</param>
|
||||
/// <param name="lastRecordedTrackNumber">"Last Recorded Track Number" value for TOC</param>
|
||||
/// <param name="session1Format">The session format for this TOC</param>
|
||||
/// <param name="leadoutTimestamp">The absolute timestamp of the lead-out track</param>
|
||||
public Synthesize_A0A1A2_Job(
|
||||
int firstRecordedTrackNumber,
|
||||
int lastRecordedTrackNumber,
|
||||
SessionFormat session1Format,
|
||||
int leadoutTimestamp)
|
||||
{
|
||||
IN_FirstRecordedTrackNumber = firstRecordedTrackNumber;
|
||||
IN_LastRecordedTrackNumber = lastRecordedTrackNumber;
|
||||
IN_Session1Format = session1Format;
|
||||
IN_LeadoutTimestamp = leadoutTimestamp;
|
||||
}
|
||||
|
||||
/// <summary>appends the new entries to the provided list</summary>
|
||||
/// <exception cref="InvalidOperationException"><see cref="IN_Session1Format"/> is <see cref="SessionFormat.None"/> or a non-member</exception>
|
||||
|
|
|
@ -4,9 +4,17 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
{
|
||||
internal class Synthesize_DiscStructure_From_DiscTOC_Job
|
||||
{
|
||||
public Disc IN_Disc { private get; set; }
|
||||
public DiscTOC TOCRaw;
|
||||
public DiscStructure Result;
|
||||
private readonly Disc IN_Disc;
|
||||
|
||||
private readonly DiscTOC TOCRaw;
|
||||
|
||||
public Synthesize_DiscStructure_From_DiscTOC_Job(Disc disc, DiscTOC tocRaw)
|
||||
{
|
||||
IN_Disc = disc;
|
||||
TOCRaw = tocRaw;
|
||||
}
|
||||
|
||||
public DiscStructure Result { get; private set; }
|
||||
|
||||
/// <exception cref="InvalidOperationException">first track of <see cref="TOCRaw"/> is not <c>1</c></exception>
|
||||
public void Run()
|
||||
|
|
|
@ -10,9 +10,15 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
/// </summary>
|
||||
internal class Synthesize_DiscTOC_From_RawTOCEntries_Job
|
||||
{
|
||||
public IEnumerable<RawTOCEntry> Entries;
|
||||
public List<string> Log = new List<string>();
|
||||
public DiscTOC Result;
|
||||
private readonly IReadOnlyList<RawTOCEntry> Entries;
|
||||
|
||||
public Synthesize_DiscTOC_From_RawTOCEntries_Job(IReadOnlyList<RawTOCEntry> entries) => Entries = entries;
|
||||
|
||||
public DiscTOC Result { get; private set; }
|
||||
|
||||
private readonly List<string> Log = new();
|
||||
|
||||
public IReadOnlyList<string> GetLog() => Log;
|
||||
|
||||
public void Run()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue