From cbbd31c2e037796cf8aa7d9b3a17d72e9e74f738 Mon Sep 17 00:00:00 2001
From: Thomas Harte <thomas.harte@gmail.com>
Date: Thu, 20 Oct 2016 19:33:25 -0400
Subject: [PATCH] Explained what this recently factored-out class does, and
 removed code from the header.

---
 Storage/Tape/Tape.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++
 Storage/Tape/Tape.hpp | 37 +++++++++++++++----------------------
 2 files changed, 57 insertions(+), 22 deletions(-)

diff --git a/Storage/Tape/Tape.cpp b/Storage/Tape/Tape.cpp
index d0283ffbe..90b48e160 100644
--- a/Storage/Tape/Tape.cpp
+++ b/Storage/Tape/Tape.cpp
@@ -93,3 +93,45 @@ void TapePlayer::process_next_event()
 	process_input_pulse(_current_pulse);
 	get_next_pulse();
 }
+
+#pragma mark - Binary Player
+
+BinaryTapePlayer::BinaryTapePlayer(unsigned int input_clock_rate) :
+	TapePlayer(input_clock_rate), _motor_is_running(false)
+{}
+
+void BinaryTapePlayer::set_motor_control(bool enabled)
+{
+	_motor_is_running = enabled;
+}
+
+void BinaryTapePlayer::set_tape_output(bool set)
+{
+	// TODO
+}
+
+bool BinaryTapePlayer::get_input()
+{
+	return _input_level;
+}
+
+void BinaryTapePlayer::run_for_cycles(int number_of_cycles)
+{
+	if(_motor_is_running) TapePlayer::run_for_cycles(number_of_cycles);
+}
+
+void BinaryTapePlayer::set_delegate(Delegate *delegate)
+{
+	_delegate = delegate;
+}
+
+void BinaryTapePlayer::process_input_pulse(Storage::Tape::Tape::Pulse pulse)
+{
+	bool new_input_level = pulse.type == Tape::Pulse::Low;
+	if(_input_level != new_input_level)
+	{
+		_input_level = new_input_level;
+		if(_delegate) _delegate->tape_did_change_input(this);
+	}
+}
+
diff --git a/Storage/Tape/Tape.hpp b/Storage/Tape/Tape.hpp
index fcf2b3d2a..7b1dd7b84 100644
--- a/Storage/Tape/Tape.hpp
+++ b/Storage/Tape/Tape.hpp
@@ -94,39 +94,32 @@ class TapePlayer: public TimedEventLoop {
 		Tape::Pulse _current_pulse;
 };
 
+/*!
+	A specific subclass of the tape player for machines that sample such as to report only either a
+	high or a low current input level.
+
+	Such machines can use @c get_input() to get the current level of the input.
+
+	They can also provide a delegate to be notified upon any change in the input level.
+*/
 class BinaryTapePlayer: public TapePlayer {
 	public:
-		BinaryTapePlayer(unsigned int input_clock_rate) : TapePlayer(input_clock_rate), _motor_is_running(false) {}
-		void set_motor_control(bool enabled) { _motor_is_running = enabled; }
-		void set_tape_output(bool set) {} // TODO
-		inline bool get_input() { return _input_level; }
+		BinaryTapePlayer(unsigned int input_clock_rate);
+		void set_motor_control(bool enabled);
+		void set_tape_output(bool set);
+		bool get_input();
 
-		void run_for_cycles(int number_of_cycles) {
-			if(_motor_is_running) {
-				TapePlayer::run_for_cycles(number_of_cycles);
-			}
-		}
+		void run_for_cycles(int number_of_cycles);
 
 		class Delegate {
 			public:
 				virtual void tape_did_change_input(BinaryTapePlayer *tape_player) = 0;
 		};
-		void set_delegate(Delegate *delegate)
-		{
-			_delegate = delegate;
-		}
+		void set_delegate(Delegate *delegate);
 
 	private:
 		Delegate *_delegate;
-		virtual void process_input_pulse(Storage::Tape::Tape::Pulse pulse)
-		{
-			bool new_input_level = pulse.type == Tape::Pulse::Low;
-			if(_input_level != new_input_level)
-			{
-				_input_level = new_input_level;
-				if(_delegate) _delegate->tape_did_change_input(this);
-			}
-		}
+		virtual void process_input_pulse(Storage::Tape::Tape::Pulse pulse);
 		bool _input_level;
 		bool _motor_is_running;
 };