MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / ForkFrom

Method ForkFrom

src/GCodes/GCodeBuffer/GCodeBuffer.cpp:381–405  ·  view source on GitHub ↗

Copy the entire file state from the other GCode buffer to ourselves. Called to copy the state of the File stream to File2.

Source from the content-addressed store, hash-verified

379
380// Copy the entire file state from the other GCode buffer to ourselves. Called to copy the state of the File stream to File2.
381void GCodeBuffer::ForkFrom(const GCodeBuffer& other) noexcept
382{
383 GCodeMachineState *ms = other.machineState->ForkChain();
384 std::swap(ms, machineState);
385
386 // We should have a single old MachineState object, but to avoid memory leaks allow for the possibility of having a chain
387 while (ms != nullptr)
388 {
389 GCodeMachineState *const msToDelete = ms;
390 ms = ms->GetPrevious();
391 delete msToDelete;
392 }
393
394 printFilePositionAtMacroStart = other.printFilePositionAtMacroStart;
395 GetVariables().AssignFrom(other.GetVariables());
396
397# if HAS_SBC_INTERFACE
398 if (!isBinaryBuffer && !reprap.UsingSbcInterface())
399# endif
400 {
401 machineState->fileState.Seek(other.GetJobFilePosition());
402 GetFileInput()->Reset(machineState->fileState);
403 stringParser.StartNewFile();
404 }
405}
406
407// Determine whether this input channel is at a strictly later point than the other one
408bool GCodeBuffer::IsLaterThan(const GCodeBuffer& other) const noexcept

Callers 1

THROWSFunction · 0.80

Calls 8

ForkChainMethod · 0.80
UsingSbcInterfaceMethod · 0.80
SeekMethod · 0.80
GetJobFilePositionMethod · 0.80
GetPreviousMethod · 0.45
AssignFromMethod · 0.45
ResetMethod · 0.45
StartNewFileMethod · 0.45

Tested by

no test coverage detected