From 31c6faf3c81fbbb5e2c0844871a6066fb6770207 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 9 May 2020 21:22:51 -0400 Subject: [PATCH] Adds a bunch of `const`s. --- ClockReceiver/ClockingHintSource.hpp | 2 +- Components/1770/1770.cpp | 4 ++-- Components/1770/1770.hpp | 16 ++++++------- Components/6522/6522.hpp | 2 +- .../Implementation/6522Implementation.hpp | 4 ++-- Components/6532/6532.hpp | 2 +- Components/6560/6560.hpp | 14 +++++------ Components/6850/6850.cpp | 2 +- Components/6850/6850.hpp | 2 +- Components/68901/MFP68901.cpp | 2 +- Components/68901/MFP68901.hpp | 2 +- Components/8272/i8272.cpp | 2 +- Components/8272/i8272.hpp | 2 +- Components/8530/z8530.cpp | 4 ++-- Components/8530/z8530.hpp | 4 ++-- Components/AudioToggle/AudioToggle.cpp | 2 +- Components/AudioToggle/AudioToggle.hpp | 3 +-- Components/DiskII/DiskII.cpp | 2 +- Components/DiskII/DiskII.hpp | 2 +- Machines/Atari/ST/DMAController.cpp | 2 +- Machines/Atari/ST/DMAController.hpp | 2 +- Machines/Atari/ST/IntelligentKeyboard.cpp | 2 +- Machines/Atari/ST/IntelligentKeyboard.hpp | 2 +- Machines/ScanProducer.hpp | 2 +- Outputs/CRT/CRT.cpp | 2 +- Outputs/CRT/CRT.hpp | 2 +- Outputs/CRT/Internals/Flywheel.hpp | 24 +++++++++---------- Storage/Disk/Controller/DiskController.cpp | 2 +- Storage/Disk/Controller/DiskController.hpp | 2 +- Storage/Disk/Drive.cpp | 2 +- Storage/Disk/Drive.hpp | 2 +- Storage/MassStorage/SCSI/SCSI.cpp | 2 +- Storage/MassStorage/SCSI/SCSI.hpp | 2 +- Storage/Tape/Tape.cpp | 4 ++-- Storage/Tape/Tape.hpp | 4 ++-- 35 files changed, 65 insertions(+), 66 deletions(-) diff --git a/ClockReceiver/ClockingHintSource.hpp b/ClockReceiver/ClockingHintSource.hpp index c0d7b24a2..e5f775e0d 100644 --- a/ClockReceiver/ClockingHintSource.hpp +++ b/ClockReceiver/ClockingHintSource.hpp @@ -67,7 +67,7 @@ class Source { } /// @returns the current preferred clocking strategy. - virtual Preference preferred_clocking() = 0; + virtual Preference preferred_clocking() const = 0; private: Observer *observer_ = nullptr; diff --git a/Components/1770/1770.cpp b/Components/1770/1770.cpp index 1a0b393ea..3f8cf9a85 100644 --- a/Components/1770/1770.cpp +++ b/Components/1770/1770.cpp @@ -824,11 +824,11 @@ void WD1770::set_head_loaded(bool head_loaded) { if(head_loaded) posit_event(int(Event1770::HeadLoad)); } -bool WD1770::get_head_loaded() { +bool WD1770::get_head_loaded() const { return head_is_loaded_; } -ClockingHint::Preference WD1770::preferred_clocking() { +ClockingHint::Preference WD1770::preferred_clocking() const { if(status_.busy) return ClockingHint::Preference::RealTime; return Storage::Disk::MFMController::preferred_clocking(); } diff --git a/Components/1770/1770.hpp b/Components/1770/1770.hpp index 5793e2185..877d33050 100644 --- a/Components/1770/1770.hpp +++ b/Components/1770/1770.hpp @@ -62,18 +62,18 @@ class WD1770: public Storage::Disk::MFMController { }; /// @returns The current value of the IRQ line output. - inline bool get_interrupt_request_line() { return status_.interrupt_request; } + inline bool get_interrupt_request_line() const { return status_.interrupt_request; } /// @returns The current value of the DRQ line output. - inline bool get_data_request_line() { return status_.data_request; } + inline bool get_data_request_line() const { return status_.data_request; } class Delegate { public: virtual void wd1770_did_change_output(WD1770 *wd1770) = 0; }; - inline void set_delegate(Delegate *delegate) { delegate_ = delegate; } + inline void set_delegate(Delegate *delegate) { delegate_ = delegate; } - ClockingHint::Preference preferred_clocking() final; + ClockingHint::Preference preferred_clocking() const final; protected: virtual void set_head_load_request(bool head_load); @@ -81,12 +81,12 @@ class WD1770: public Storage::Disk::MFMController { void set_head_loaded(bool head_loaded); /// @returns The last value posted to @c set_head_loaded. - bool get_head_loaded(); + bool get_head_loaded() const; private: - Personality personality_; - inline bool has_motor_on_line() { return (personality_ != P1793 ) && (personality_ != P1773); } - inline bool has_head_load_line() { return (personality_ == P1793 ); } + const Personality personality_; + bool has_motor_on_line() const { return (personality_ != P1793 ) && (personality_ != P1773); } + bool has_head_load_line() const { return (personality_ == P1793 ); } struct Status { bool write_protect = false; diff --git a/Components/6522/6522.hpp b/Components/6522/6522.hpp index 00f1e291b..4ab35e558 100644 --- a/Components/6522/6522.hpp +++ b/Components/6522/6522.hpp @@ -112,7 +112,7 @@ template class MOS6522: public MOS6522Storage { void run_for(const Cycles cycles); /// @returns @c true if the IRQ line is currently active; @c false otherwise. - bool get_interrupt_line(); + bool get_interrupt_line() const; /// Updates the port handler to the current time and then requests that it flush. void flush(); diff --git a/Components/6522/Implementation/6522Implementation.hpp b/Components/6522/Implementation/6522Implementation.hpp index ccc9b2fb8..0568167d5 100644 --- a/Components/6522/Implementation/6522Implementation.hpp +++ b/Components/6522/Implementation/6522Implementation.hpp @@ -383,9 +383,9 @@ template void MOS6522::run_for(const Cycles cycles) { } /*! @returns @c true if the IRQ line is currently active; @c false otherwise. */ -template bool MOS6522::get_interrupt_line() { +template bool MOS6522::get_interrupt_line() const { uint8_t interrupt_status = registers_.interrupt_flags & registers_.interrupt_enable & 0x7f; - return !!interrupt_status; + return interrupt_status; } template void MOS6522::evaluate_cb2_output() { diff --git a/Components/6532/6532.hpp b/Components/6532/6532.hpp index b411e620e..dcbd660f0 100644 --- a/Components/6532/6532.hpp +++ b/Components/6532/6532.hpp @@ -142,7 +142,7 @@ template class MOS6532 { } } - inline bool get_inerrupt_line() { + inline bool get_inerrupt_line() const { return interrupt_line_; } diff --git a/Components/6560/6560.hpp b/Components/6560/6560.hpp index 0f7013dc9..8a26345a3 100644 --- a/Components/6560/6560.hpp +++ b/Components/6560/6560.hpp @@ -87,8 +87,8 @@ template class MOS6560 { void set_scan_target(Outputs::Display::ScanTarget *scan_target) { crt_.set_scan_target(scan_target); } Outputs::Display::ScanStatus get_scaled_scan_status() const { return crt_.get_scaled_scan_status() / 4.0f; } void set_display_type(Outputs::Display::DisplayType display_type) { crt_.set_display_type(display_type); } - Outputs::Display::DisplayType get_display_type() { return crt_.get_display_type(); } - Outputs::Speaker::Speaker *get_speaker() { return &speaker_; } + Outputs::Display::DisplayType get_display_type() const { return crt_.get_display_type(); } + Outputs::Speaker::Speaker *get_speaker() { return &speaker_; } void set_high_frequency_cutoff(float cutoff) { speaker_.set_high_frequency_cutoff(cutoff); @@ -420,11 +420,11 @@ template class MOS6560 { /* Reads from a 6560 register. */ - uint8_t read(int address) { + uint8_t read(int address) const { address &= 0xf; switch(address) { default: return registers_.direct_values[address]; - case 0x03: return static_cast(raster_value() << 7) | (registers_.direct_values[3] & 0x7f); + case 0x03: return uint8_t(raster_value() << 7) | (registers_.direct_values[3] & 0x7f); case 0x04: return (raster_value() >> 1) & 0xff; } } @@ -462,11 +462,11 @@ template class MOS6560 { // counters that cover an entire field int horizontal_counter_ = 0, vertical_counter_ = 0; - const int lines_this_field() { + int lines_this_field() const { // Necessary knowledge here: only the NTSC 6560 supports interlaced video. return registers_.interlaced ? (is_odd_frame_ ? 262 : 263) : timing_.lines_per_progressive_field; } - const int raster_value() { + int raster_value() const { const int bonus_line = (horizontal_counter_ + timing_.line_counter_increment_offset) / timing_.cycles_per_line; const int line = vertical_counter_ + bonus_line; const int final_line = lines_this_field(); @@ -481,7 +481,7 @@ template class MOS6560 { } // Cf. http://www.sleepingelephant.com/ipw-web/bulletin/bb/viewtopic.php?f=14&t=7237&start=15#p80737 } - bool is_odd_frame() { + bool is_odd_frame() const { return is_odd_frame_ || !registers_.interlaced; } diff --git a/Components/6850/6850.cpp b/Components/6850/6850.cpp index 0c486a169..882850df7 100644 --- a/Components/6850/6850.cpp +++ b/Components/6850/6850.cpp @@ -120,7 +120,7 @@ void ACIA::consider_transmission() { } } -ClockingHint::Preference ACIA::preferred_clocking() { +ClockingHint::Preference ACIA::preferred_clocking() const { // Real-time clocking is required if a transmission is ongoing; this is a courtesy for whomever // is on the receiving end. if(transmit.transmission_data_time_remaining() > 0) return ClockingHint::Preference::RealTime; diff --git a/Components/6850/6850.hpp b/Components/6850/6850.hpp index 0e9c91152..8e2dbf19d 100644 --- a/Components/6850/6850.hpp +++ b/Components/6850/6850.hpp @@ -86,7 +86,7 @@ class ACIA: public ClockingHint::Source, private Serial::Line::ReadDelegate { Serial::Line request_to_send; // ClockingHint::Source. - ClockingHint::Preference preferred_clocking() final; + ClockingHint::Preference preferred_clocking() const final; struct InterruptDelegate { virtual void acia6850_did_change_interrupt_status(ACIA *acia) = 0; diff --git a/Components/68901/MFP68901.cpp b/Components/68901/MFP68901.cpp index 4bcf9d7a3..c44fa8883 100644 --- a/Components/68901/MFP68901.cpp +++ b/Components/68901/MFP68901.cpp @@ -20,7 +20,7 @@ using namespace Motorola::MFP68901; -ClockingHint::Preference MFP68901::preferred_clocking() { +ClockingHint::Preference MFP68901::preferred_clocking() const { // Rule applied: if any timer is actively running and permitted to produce an // interrupt, request real-time running. return diff --git a/Components/68901/MFP68901.hpp b/Components/68901/MFP68901.hpp index 25cc88cc4..6f320a214 100644 --- a/Components/68901/MFP68901.hpp +++ b/Components/68901/MFP68901.hpp @@ -76,7 +76,7 @@ class MFP68901: public ClockingHint::Source { void set_interrupt_delegate(InterruptDelegate *delegate); // ClockingHint::Source. - ClockingHint::Preference preferred_clocking() final; + ClockingHint::Preference preferred_clocking() const final; private: // MARK: - Timers diff --git a/Components/8272/i8272.cpp b/Components/8272/i8272.cpp index 3e3eee410..84b5ce6fc 100644 --- a/Components/8272/i8272.cpp +++ b/Components/8272/i8272.cpp @@ -82,7 +82,7 @@ i8272::i8272(BusHandler &bus_handler, Cycles clock_rate) : posit_event(static_cast(Event8272::CommandByte)); } -ClockingHint::Preference i8272::preferred_clocking() { +ClockingHint::Preference i8272::preferred_clocking() const { const auto mfm_controller_preferred_clocking = Storage::Disk::MFMController::preferred_clocking(); if(mfm_controller_preferred_clocking != ClockingHint::Preference::None) return mfm_controller_preferred_clocking; return is_sleeping_ ? ClockingHint::Preference::None : ClockingHint::Preference::JustInTime; diff --git a/Components/8272/i8272.hpp b/Components/8272/i8272.hpp index 69ee18232..1db7e80af 100644 --- a/Components/8272/i8272.hpp +++ b/Components/8272/i8272.hpp @@ -39,7 +39,7 @@ class i8272 : public Storage::Disk::MFMController { void set_dma_acknowledge(bool dack); void set_terminal_count(bool tc); - ClockingHint::Preference preferred_clocking() final; + ClockingHint::Preference preferred_clocking() const final; protected: virtual void select_drive(int number) = 0; diff --git a/Components/8530/z8530.cpp b/Components/8530/z8530.cpp index a4cc451cb..8c3658046 100644 --- a/Components/8530/z8530.cpp +++ b/Components/8530/z8530.cpp @@ -16,7 +16,7 @@ void z8530::reset() { // TODO. } -bool z8530::get_interrupt_line() { +bool z8530::get_interrupt_line() const { return (master_interrupt_control_ & 0x8) && ( @@ -253,7 +253,7 @@ void z8530::Channel::set_dcd(bool level) { } } -bool z8530::Channel::get_interrupt_line() { +bool z8530::Channel::get_interrupt_line() const { return (interrupt_mask_ & 1) && external_status_interrupt_; // TODO: other potential causes of an interrupt. diff --git a/Components/8530/z8530.hpp b/Components/8530/z8530.hpp index 748b71081..58627161b 100644 --- a/Components/8530/z8530.hpp +++ b/Components/8530/z8530.hpp @@ -33,7 +33,7 @@ class z8530 { std::uint8_t read(int address); void write(int address, std::uint8_t value); void reset(); - bool get_interrupt_line(); + bool get_interrupt_line() const; struct Delegate { virtual void did_change_interrupt_status(z8530 *, bool new_status) = 0; @@ -53,7 +53,7 @@ class z8530 { uint8_t read(bool data, uint8_t pointer); void write(bool data, uint8_t pointer, uint8_t value); void set_dcd(bool level); - bool get_interrupt_line(); + bool get_interrupt_line() const; private: uint8_t data_ = 0xff; diff --git a/Components/AudioToggle/AudioToggle.cpp b/Components/AudioToggle/AudioToggle.cpp index 5000beacc..794fe8bc5 100644 --- a/Components/AudioToggle/AudioToggle.cpp +++ b/Components/AudioToggle/AudioToggle.cpp @@ -33,6 +33,6 @@ void Toggle::set_output(bool enabled) { }); } -bool Toggle::get_output() { +bool Toggle::get_output() const { return is_enabled_; } diff --git a/Components/AudioToggle/AudioToggle.hpp b/Components/AudioToggle/AudioToggle.hpp index c009fe781..991431244 100644 --- a/Components/AudioToggle/AudioToggle.hpp +++ b/Components/AudioToggle/AudioToggle.hpp @@ -24,10 +24,9 @@ class Toggle: public Outputs::Speaker::SampleSource { void get_samples(std::size_t number_of_samples, std::int16_t *target); void set_sample_volume_range(std::int16_t range); void skip_samples(const std::size_t number_of_samples); - static constexpr bool get_is_stereo() { return false; } void set_output(bool enabled); - bool get_output(); + bool get_output() const; private: // Accessed on the calling thread. diff --git a/Components/DiskII/DiskII.cpp b/Components/DiskII/DiskII.cpp index a27896d93..b6adb7423 100644 --- a/Components/DiskII/DiskII.cpp +++ b/Components/DiskII/DiskII.cpp @@ -225,7 +225,7 @@ void DiskII::set_component_prefers_clocking(ClockingHint::Source *component, Clo decide_clocking_preference(); } -ClockingHint::Preference DiskII::preferred_clocking() { +ClockingHint::Preference DiskII::preferred_clocking() const { return clocking_preference_; } diff --git a/Components/DiskII/DiskII.hpp b/Components/DiskII/DiskII.hpp index b168364a7..5afbf0169 100644 --- a/Components/DiskII/DiskII.hpp +++ b/Components/DiskII/DiskII.hpp @@ -76,7 +76,7 @@ class DiskII : void set_disk(const std::shared_ptr &disk, int drive); // As per Sleeper. - ClockingHint::Preference preferred_clocking() final; + ClockingHint::Preference preferred_clocking() const final; // The Disk II functions as a potential target for @c Activity::Sources. void set_activity_observer(Activity::Observer *observer); diff --git a/Machines/Atari/ST/DMAController.cpp b/Machines/Atari/ST/DMAController.cpp index 1de419abc..0259d5ed3 100644 --- a/Machines/Atari/ST/DMAController.cpp +++ b/Machines/Atari/ST/DMAController.cpp @@ -251,7 +251,7 @@ void DMAController::set_component_prefers_clocking(ClockingHint::Source *, Clock update_clocking_observer(); } -ClockingHint::Preference DMAController::preferred_clocking() { +ClockingHint::Preference DMAController::preferred_clocking() const { return (fdc_.preferred_clocking() == ClockingHint::Preference::None) ? ClockingHint::Preference::None : ClockingHint::Preference::RealTime; } diff --git a/Machines/Atari/ST/DMAController.hpp b/Machines/Atari/ST/DMAController.hpp index eb4190a2a..35d3ade03 100644 --- a/Machines/Atari/ST/DMAController.hpp +++ b/Machines/Atari/ST/DMAController.hpp @@ -50,7 +50,7 @@ class DMAController: public WD::WD1770::Delegate, public ClockingHint::Source, p void set_activity_observer(Activity::Observer *observer); // ClockingHint::Source. - ClockingHint::Preference preferred_clocking() final; + ClockingHint::Preference preferred_clocking() const final; private: HalfCycles running_time_; diff --git a/Machines/Atari/ST/IntelligentKeyboard.cpp b/Machines/Atari/ST/IntelligentKeyboard.cpp index 8db99a9cb..06f848778 100644 --- a/Machines/Atari/ST/IntelligentKeyboard.cpp +++ b/Machines/Atari/ST/IntelligentKeyboard.cpp @@ -45,7 +45,7 @@ bool IntelligentKeyboard::serial_line_did_produce_bit(Serial::Line *, int bit) { return true; } -ClockingHint::Preference IntelligentKeyboard::preferred_clocking() { +ClockingHint::Preference IntelligentKeyboard::preferred_clocking() const { return output_line_.transmission_data_time_remaining().as_integral() ? ClockingHint::Preference::RealTime : ClockingHint::Preference::None; } diff --git a/Machines/Atari/ST/IntelligentKeyboard.hpp b/Machines/Atari/ST/IntelligentKeyboard.hpp index f7fe6ba00..54b6d0560 100644 --- a/Machines/Atari/ST/IntelligentKeyboard.hpp +++ b/Machines/Atari/ST/IntelligentKeyboard.hpp @@ -58,7 +58,7 @@ class IntelligentKeyboard: public Inputs::Mouse { public: IntelligentKeyboard(Serial::Line &input, Serial::Line &output); - ClockingHint::Preference preferred_clocking() final; + ClockingHint::Preference preferred_clocking() const final; void run_for(HalfCycles duration); void set_key_state(Key key, bool is_pressed); diff --git a/Machines/ScanProducer.hpp b/Machines/ScanProducer.hpp index 4393086e1..9d811500e 100644 --- a/Machines/ScanProducer.hpp +++ b/Machines/ScanProducer.hpp @@ -10,7 +10,7 @@ #define ScanProducer_hpp #include "../Outputs/ScanTarget.hpp" -#include "../Configurable/StandardOptions.hpp" +#include "../Configurable/Configurable.hpp" #include "TimedMachine.hpp" diff --git a/Outputs/CRT/CRT.cpp b/Outputs/CRT/CRT.cpp index 8f5b0321f..c4c4f9bba 100644 --- a/Outputs/CRT/CRT.cpp +++ b/Outputs/CRT/CRT.cpp @@ -93,7 +93,7 @@ void CRT::set_display_type(Outputs::Display::DisplayType display_type) { scan_target_->set_modals(scan_target_modals_); } -Outputs::Display::DisplayType CRT::get_display_type() { +Outputs::Display::DisplayType CRT::get_display_type() const { return scan_target_modals_.display_type; } diff --git a/Outputs/CRT/CRT.hpp b/Outputs/CRT/CRT.hpp index 9988968f5..d640b01a7 100644 --- a/Outputs/CRT/CRT.hpp +++ b/Outputs/CRT/CRT.hpp @@ -299,7 +299,7 @@ class CRT { void set_display_type(Outputs::Display::DisplayType); /*! Gets the last display type provided to set_display_type. */ - Outputs::Display::DisplayType get_display_type(); + Outputs::Display::DisplayType get_display_type() const; /*! Sets the offset to apply to phase when using the PhaseLinkedLuminance8 input data type. */ void set_phase_linked_luminance_offset(float); diff --git a/Outputs/CRT/Internals/Flywheel.hpp b/Outputs/CRT/Internals/Flywheel.hpp index 43b612800..d4dc5655d 100644 --- a/Outputs/CRT/Internals/Flywheel.hpp +++ b/Outputs/CRT/Internals/Flywheel.hpp @@ -129,7 +129,7 @@ struct Flywheel { @returns The current output position. */ - inline int get_current_output_position() { + inline int get_current_output_position() const { if(counter_ < retrace_time_) { const int retrace_distance = int((int64_t(counter_) * int64_t(standard_period_)) / int64_t(retrace_time_)); if(retrace_distance > counter_before_retrace_) return 0; @@ -145,56 +145,56 @@ struct Flywheel { @returns The current output position. */ - inline int get_current_phase() { + inline int get_current_phase() const { return counter_ - retrace_time_; } /*! @returns the amount of time since retrace last began. Time then counts monotonically up from zero. */ - inline int get_current_time() { + inline int get_current_time() const { return counter_; } /*! @returns whether the output is currently retracing. */ - inline bool is_in_retrace() { + inline bool is_in_retrace() const { return counter_ < retrace_time_; } /*! @returns the expected length of the scan period (excluding retrace). */ - inline int get_scan_period() { + inline int get_scan_period() const { return standard_period_ - retrace_time_; } /*! @returns the actual length of the scan period (excluding retrace). */ - inline int get_locked_scan_period() { + inline int get_locked_scan_period() const { return expected_next_sync_ - retrace_time_; } /*! @returns the expected length of a complete scan and retrace cycle. */ - inline int get_standard_period() { + inline int get_standard_period() const { return standard_period_; } /*! @returns the actual current period for a complete scan (including retrace). */ - inline int get_locked_period() { + inline int get_locked_period() const { return expected_next_sync_; } /*! @returns the amount by which the @c locked_period was adjusted, the last time that an adjustment was applied. */ - inline int get_last_period_adjustment() { + inline int get_last_period_adjustment() const { return last_adjustment_; } @@ -211,21 +211,21 @@ struct Flywheel { /*! @returns A count of the number of retraces so far performed. */ - inline int get_number_of_retraces() { + inline int get_number_of_retraces() const { return number_of_retraces_; } /*! @returns The amount of time this flywheel spends in retrace, as supplied at construction. */ - inline int get_retrace_period() { + inline int get_retrace_period() const { return retrace_time_; } /*! @returns `true` if a sync is expected soon or if the time at which it was expected (or received) was recent. */ - inline bool is_near_expected_sync() { + inline bool is_near_expected_sync() const { return (counter_ < (standard_period_ / 100)) || (counter_ >= expected_next_sync_ - (standard_period_ / 100)); diff --git a/Storage/Disk/Controller/DiskController.cpp b/Storage/Disk/Controller/DiskController.cpp index 2c3484767..d7f2d75ba 100644 --- a/Storage/Disk/Controller/DiskController.cpp +++ b/Storage/Disk/Controller/DiskController.cpp @@ -24,7 +24,7 @@ void Controller::set_component_prefers_clocking(ClockingHint::Source *component, update_clocking_observer(); } -ClockingHint::Preference Controller::preferred_clocking() { +ClockingHint::Preference Controller::preferred_clocking() const { // Nominate RealTime clocking if any drive currently wants any clocking whatsoever. // Otherwise, ::None will do. for(auto &drive: drives_) { diff --git a/Storage/Disk/Controller/DiskController.hpp b/Storage/Disk/Controller/DiskController.hpp index b3b23ebfa..3d8c723c3 100644 --- a/Storage/Disk/Controller/DiskController.hpp +++ b/Storage/Disk/Controller/DiskController.hpp @@ -134,7 +134,7 @@ class Controller: /*! As per ClockingHint::Source. */ - ClockingHint::Preference preferred_clocking() override; + ClockingHint::Preference preferred_clocking() const override; private: Time bit_length_; diff --git a/Storage/Disk/Drive.cpp b/Storage/Disk/Drive.cpp index e8a5a461f..7437ae1fd 100644 --- a/Storage/Disk/Drive.cpp +++ b/Storage/Disk/Drive.cpp @@ -71,7 +71,7 @@ bool Drive::has_disk() const { return has_disk_; } -ClockingHint::Preference Drive::preferred_clocking() { +ClockingHint::Preference Drive::preferred_clocking() const { return (!has_disk_ || (time_until_motor_transition == Cycles(0) && !disk_is_rotating_)) ? ClockingHint::Preference::None : ClockingHint::Preference::JustInTime; } diff --git a/Storage/Disk/Drive.hpp b/Storage/Disk/Drive.hpp index 386e9ac6b..30349057e 100644 --- a/Storage/Disk/Drive.hpp +++ b/Storage/Disk/Drive.hpp @@ -152,7 +152,7 @@ class Drive: public ClockingHint::Source, public TimedEventLoop { void set_event_delegate(EventDelegate *); // As per Sleeper. - ClockingHint::Preference preferred_clocking() final; + ClockingHint::Preference preferred_clocking() const final; /// Adds an activity observer; it'll be notified of disk activity. /// The caller can specify whether to add an LED based on disk motor. diff --git a/Storage/MassStorage/SCSI/SCSI.cpp b/Storage/MassStorage/SCSI/SCSI.cpp index 90e2b0dfe..8d7909879 100644 --- a/Storage/MassStorage/SCSI/SCSI.cpp +++ b/Storage/MassStorage/SCSI/SCSI.cpp @@ -82,7 +82,7 @@ void Bus::add_observer(Observer *observer) { observers_.push_back(observer); } -ClockingHint::Preference Bus::preferred_clocking() { +ClockingHint::Preference Bus::preferred_clocking() const { return (dispatch_index_ < dispatch_times_.size()) ? ClockingHint::Preference::RealTime : ClockingHint::Preference::None; } diff --git a/Storage/MassStorage/SCSI/SCSI.hpp b/Storage/MassStorage/SCSI/SCSI.hpp index d945bd680..538f1f30f 100644 --- a/Storage/MassStorage/SCSI/SCSI.hpp +++ b/Storage/MassStorage/SCSI/SCSI.hpp @@ -139,7 +139,7 @@ class Bus: public ClockingHint::Source, public Activity::Source { void update_observers(); // As per ClockingHint::Source. - ClockingHint::Preference preferred_clocking() final; + ClockingHint::Preference preferred_clocking() const final; // Fulfilling public Activity::Source. void set_activity_observer(Activity::Observer *observer) final; diff --git a/Storage/Tape/Tape.cpp b/Storage/Tape/Tape.cpp index c14c1b4ce..89777aea1 100644 --- a/Storage/Tape/Tape.cpp +++ b/Storage/Tape/Tape.cpp @@ -64,7 +64,7 @@ void Tape::set_offset(uint64_t offset) { // MARK: - Player -ClockingHint::Preference TapePlayer::preferred_clocking() { +ClockingHint::Preference TapePlayer::preferred_clocking() const { return (!tape_ || tape_->is_at_end()) ? ClockingHint::Preference::None : ClockingHint::Preference::JustInTime; } @@ -118,7 +118,7 @@ BinaryTapePlayer::BinaryTapePlayer(int input_clock_rate) : TapePlayer(input_clock_rate) {} -ClockingHint::Preference BinaryTapePlayer::preferred_clocking() { +ClockingHint::Preference BinaryTapePlayer::preferred_clocking() const { if(!motor_is_running_) return ClockingHint::Preference::None; return TapePlayer::preferred_clocking(); } diff --git a/Storage/Tape/Tape.hpp b/Storage/Tape/Tape.hpp index e236f6cdd..a64aed0cf 100644 --- a/Storage/Tape/Tape.hpp +++ b/Storage/Tape/Tape.hpp @@ -107,7 +107,7 @@ class TapePlayer: public TimedEventLoop, public ClockingHint::Source { void run_for_input_pulse(); - ClockingHint::Preference preferred_clocking() override; + ClockingHint::Preference preferred_clocking() const override; protected: virtual void process_next_event() override; @@ -145,7 +145,7 @@ class BinaryTapePlayer : public TapePlayer { }; void set_delegate(Delegate *delegate); - ClockingHint::Preference preferred_clocking() final; + ClockingHint::Preference preferred_clocking() const final; protected: Delegate *delegate_ = nullptr;