1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-13 00:29:14 +00:00

Mark overrides, improve constiness.

This commit is contained in:
Thomas Harte 2024-12-03 17:33:09 -05:00
parent 3ffd986a1c
commit 6ef63790a9
22 changed files with 58 additions and 64 deletions

View File

@ -46,7 +46,6 @@ struct HitRate {
continue;
}
NSLog(@"%@", diskItem);
const auto list = Analyser::Static::GetTargets([path stringByAppendingPathComponent:diskItem].UTF8String);
if(list.empty()) {
continue;

View File

@ -133,7 +133,7 @@ void FileHolder::seek(long offset, int whence) {
std::fseek(file_, offset, whence);
}
long FileHolder::tell() {
long FileHolder::tell() const {
return std::ftell(file_);
}
@ -141,7 +141,7 @@ void FileHolder::flush() {
std::fflush(file_);
}
bool FileHolder::eof() {
bool FileHolder::eof() const {
return std::feof(file_);
}
@ -159,7 +159,7 @@ bool FileHolder::check_signature(const char *signature, std::size_t length) {
return true;
}
std::string FileHolder::extension() {
std::string FileHolder::extension() const {
std::size_t pointer = name_.size() - 1;
while(pointer > 0 && name_[pointer] != '.') pointer--;
if(name_[pointer] == '.') pointer++;
@ -178,11 +178,11 @@ void FileHolder::ensure_is_at_least_length(long length) {
}
}
bool FileHolder::get_is_known_read_only() {
bool FileHolder::get_is_known_read_only() const {
return is_read_only_;
}
struct stat &FileHolder::stats() {
const struct stat &FileHolder::stats() const {
return file_stats_;
}

View File

@ -144,13 +144,13 @@ public:
void seek(long offset, int whence);
/*! @returns The current cursor position within this file. */
long tell();
long tell() const;
/*! Flushes any queued content that has not yet been written to disk. */
void flush();
/*! @returns @c true if the end-of-file indicator is set, @c false otherwise. */
bool eof();
bool eof() const;
class BitStream {
public:
@ -214,7 +214,7 @@ public:
Determines and returns the file extension: everything from the final character
back to the first dot. The string is converted to lowercase before being returned.
*/
std::string extension();
std::string extension() const;
/*!
Ensures the file is at least @c length bytes long, appending 0s until it is
@ -225,12 +225,12 @@ public:
/*!
@returns @c true if an attempt was made to read this file in ReadWrite mode but it could be opened only for reading; @c false otherwise.
*/
bool get_is_known_read_only();
bool get_is_known_read_only() const;
/*!
@returns the stat struct describing this file.
*/
struct stat &stats();
const struct stat &stats() const;
/*!
@returns a mutex owned by the file that can be used to serialise file access.

View File

@ -168,7 +168,7 @@ CAS::CAS(const std::string &file_name) {
}
}
bool CAS::is_at_end() {
bool CAS::is_at_end() const {
return phase_ == Phase::EndOfFile;
}

View File

@ -34,11 +34,11 @@ public:
};
// implemented to satisfy @c Tape
bool is_at_end();
bool is_at_end() const override;
private:
void virtual_reset();
Pulse virtual_get_next_pulse();
void virtual_reset() override;
Pulse virtual_get_next_pulse() override;
// Storage for the array of data blobs to transcribe into audio;
// each chunk is preceded by a header which may be long, and is optionally

View File

@ -114,7 +114,7 @@ void CSW::invert_pulse() {
pulse_.type = (pulse_.type == Pulse::High) ? Pulse::Low : Pulse::High;
}
bool CSW::is_at_end() {
bool CSW::is_at_end() const {
return source_data_pointer_ == source_data_.size();
}

View File

@ -43,11 +43,11 @@ public:
};
// implemented to satisfy @c Tape
bool is_at_end();
bool is_at_end() const override;
private:
void virtual_reset();
Pulse virtual_get_next_pulse();
void virtual_reset() override;
Pulse virtual_get_next_pulse() override;
Pulse pulse_;
CompressionType compression_type_;

View File

@ -45,7 +45,7 @@ void CommodoreTAP::virtual_reset() {
is_at_end_ = false;
}
bool CommodoreTAP::is_at_end() {
bool CommodoreTAP::is_at_end() const {
return is_at_end_;
}

View File

@ -33,12 +33,12 @@ public:
};
// implemented to satisfy @c Tape
bool is_at_end();
bool is_at_end() const override;
private:
Storage::FileHolder file_;
void virtual_reset();
Pulse virtual_get_next_pulse();
void virtual_reset() override;
Pulse virtual_get_next_pulse() override;
bool updated_layout_;
uint32_t file_size_;

View File

@ -158,6 +158,6 @@ Tape::Pulse OricTAP::virtual_get_next_pulse() {
return pulse;
}
bool OricTAP::is_at_end() {
bool OricTAP::is_at_end() const {
return phase_ == End;
}

View File

@ -33,12 +33,12 @@ public:
};
// implemented to satisfy @c Tape
bool is_at_end();
bool is_at_end() const override;
private:
Storage::FileHolder file_;
void virtual_reset();
Pulse virtual_get_next_pulse();
void virtual_reset() override;
Pulse virtual_get_next_pulse() override;
// byte serialisation and output
uint16_t current_value_;

View File

@ -115,7 +115,7 @@ void TZX::get_csw_recording_block() {
while(!csw.is_at_end()) {
Tape::Pulse next_pulse = csw.get_next_pulse();
current_level_ = (next_pulse.type == Tape::Pulse::High);
emplace_back(std::move(next_pulse));
push_back(next_pulse);
}
(void)number_of_compressed_pulses;

View File

@ -95,7 +95,7 @@ void PRG::virtual_reset() {
copy_mask_ = 0x80;
}
bool PRG::is_at_end() {
bool PRG::is_at_end() const {
return file_phase_ == FilePhaseAtEnd;
}

View File

@ -34,12 +34,12 @@ public:
};
// implemented to satisfy @c Tape
bool is_at_end();
bool is_at_end() const override;
private:
FileHolder file_;
Pulse virtual_get_next_pulse();
void virtual_reset();
Pulse virtual_get_next_pulse() override;
void virtual_reset() override;
uint16_t load_address_;
uint16_t length_;

View File

@ -42,11 +42,11 @@ void ZX80O81P::virtual_reset() {
bit_pointer_ = wave_pointer_ = 0;
}
bool ZX80O81P::has_finished_data() {
bool ZX80O81P::has_finished_data() const {
return (data_pointer_ == data_.size()) && !wave_pointer_ && !bit_pointer_;
}
bool ZX80O81P::is_at_end() {
bool ZX80O81P::is_at_end() const {
return has_finished_data() && has_ended_final_byte_;
}

View File

@ -37,15 +37,15 @@ public:
private:
// implemented to satisfy @c Tape
bool is_at_end();
bool is_at_end() const override;
// implemented to satisfy TargetPlatform::TypeDistinguisher
TargetPlatform::Type target_platform_type();
TargetPlatform::Type target_platform_type() override;
TargetPlatform::Type platform_type_;
void virtual_reset();
Pulse virtual_get_next_pulse();
bool has_finished_data();
void virtual_reset() override;
Pulse virtual_get_next_pulse() override;
bool has_finished_data() const;
uint8_t byte_;
int bit_pointer_;

View File

@ -38,7 +38,7 @@ ZXSpectrumTAP::ZXSpectrumTAP(const std::string &file_name) :
virtual_reset();
}
bool ZXSpectrumTAP::is_at_end() {
bool ZXSpectrumTAP::is_at_end() const {
return file_.tell() == file_.stats().st_size && phase_ == Phase::Gap;
}

View File

@ -48,7 +48,7 @@ private:
void read_next_block();
// Implemented to satisfy @c Tape.
bool is_at_end() override;
bool is_at_end() const override;
void virtual_reset() override;
Pulse virtual_get_next_pulse() override;
};

View File

@ -12,11 +12,11 @@ using namespace Storage::Tape;
PulseQueuedTape::PulseQueuedTape() : pulse_pointer_(0), is_at_end_(false) {}
bool PulseQueuedTape::is_at_end() {
bool PulseQueuedTape::is_at_end() const {
return is_at_end_;
}
void PulseQueuedTape::set_is_at_end(bool is_at_end) {
void PulseQueuedTape::set_is_at_end(const bool is_at_end) {
is_at_end_ = is_at_end;
}
@ -25,27 +25,23 @@ void PulseQueuedTape::clear() {
pulse_pointer_ = 0;
}
bool PulseQueuedTape::empty() {
bool PulseQueuedTape::empty() const {
return queued_pulses_.empty();
}
void PulseQueuedTape::emplace_back(Tape::Pulse::Type type, Time length) {
void PulseQueuedTape::emplace_back(const Tape::Pulse::Type type, const Time length) {
queued_pulses_.emplace_back(type, length);
}
void PulseQueuedTape::emplace_back(const Tape::Pulse &&pulse) {
queued_pulses_.emplace_back(pulse);
}
Tape::Pulse PulseQueuedTape::silence() {
Pulse silence;
silence.type = Pulse::Zero;
silence.length.length = 1;
silence.length.clock_rate = 1;
return silence;
void PulseQueuedTape::push_back(const Tape::Pulse pulse) {
queued_pulses_.push_back(pulse);
}
Tape::Pulse PulseQueuedTape::virtual_get_next_pulse() {
const auto silence = [] {
return Tape::Pulse(Tape::Pulse::Type::Zero, Storage::Time(1, 1));
};
if(is_at_end_) {
return silence();
}
@ -59,7 +55,7 @@ Tape::Pulse PulseQueuedTape::virtual_get_next_pulse() {
}
}
std::size_t read_pointer = pulse_pointer_;
const std::size_t read_pointer = pulse_pointer_;
pulse_pointer_++;
return queued_pulses_[read_pointer];
}

View File

@ -26,20 +26,19 @@ namespace Storage::Tape {
class PulseQueuedTape: public Tape {
public:
PulseQueuedTape();
bool is_at_end();
bool is_at_end() const override;
protected:
void emplace_back(Tape::Pulse::Type type, Time length);
void emplace_back(const Tape::Pulse &&pulse);
void push_back(Tape::Pulse);
void clear();
bool empty();
bool empty() const;
void set_is_at_end(bool);
virtual void get_next_pulses() = 0;
private:
Pulse virtual_get_next_pulse();
Pulse silence();
Pulse virtual_get_next_pulse() override;
std::vector<Pulse> queued_pulses_;
std::size_t pulse_pointer_;

View File

@ -49,7 +49,7 @@ Tape::Pulse Tape::get_next_pulse() {
return pulse_;
}
uint64_t Tape::get_offset() {
uint64_t Tape::get_offset() const {
return offset_;
}

View File

@ -54,14 +54,14 @@ public:
void reset();
/// @returns @c true if the tape has progressed beyond all recorded content; @c false otherwise.
virtual bool is_at_end() = 0;
virtual bool is_at_end() const = 0;
/*!
Returns a numerical representation of progression into the tape. Precision is arbitrary but
required to be at least to the whole pulse. Greater numbers are later than earlier numbers,
but not necessarily continuous.
*/
virtual uint64_t get_offset();
virtual uint64_t get_offset() const;
/*!
Moves the tape to the first time at which the specified offset would be returned by get_offset.