2017-07-16 22:04:40 -04:00
|
|
|
//
|
|
|
|
// PulseQueuedTape.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 16/07/2017.
|
2018-05-13 15:19:52 -04:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-07-16 22:04:40 -04:00
|
|
|
//
|
|
|
|
|
2024-01-16 23:34:46 -05:00
|
|
|
#pragma once
|
2017-07-16 22:04:40 -04:00
|
|
|
|
|
|
|
#include "Tape.hpp"
|
|
|
|
#include <vector>
|
|
|
|
|
2023-05-10 16:02:18 -05:00
|
|
|
namespace Storage::Tape {
|
2017-07-16 22:04:40 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Provides a @c Tape with a queue of upcoming pulses and an is-at-end flag.
|
|
|
|
|
2024-12-03 22:54:29 -05:00
|
|
|
If is-at-end is set then @c next_pulse() returns a second of silence and
|
|
|
|
@c is_at_end() returns @c true.
|
2017-11-07 22:51:06 -05:00
|
|
|
|
2024-12-03 22:54:29 -05:00
|
|
|
Otherwise @c next_pulse() returns something from the pulse queue if there is
|
|
|
|
anything there, and otherwise calls @c push_next_pulses() which is
|
2017-07-16 22:04:40 -04:00
|
|
|
virtual, giving subclasses a chance to provide the next batch of pulses.
|
|
|
|
*/
|
2024-12-03 22:28:57 -05:00
|
|
|
class PulseQueuedSerialiser: public TapeSerialiser {
|
2024-12-01 21:44:14 -05:00
|
|
|
public:
|
2024-12-03 22:28:57 -05:00
|
|
|
void emplace_back(Pulse::Type, Time);
|
|
|
|
void push_back(Pulse);
|
2024-12-01 21:44:14 -05:00
|
|
|
void clear();
|
2024-12-03 17:33:09 -05:00
|
|
|
bool empty() const;
|
2024-12-01 21:44:14 -05:00
|
|
|
|
|
|
|
void set_is_at_end(bool);
|
2024-12-03 22:54:29 -05:00
|
|
|
Pulse next_pulse() override;
|
2024-12-03 22:28:57 -05:00
|
|
|
bool is_at_end() const override;
|
|
|
|
|
2024-12-03 22:54:29 -05:00
|
|
|
virtual void push_next_pulses() = 0;
|
2024-12-01 21:44:14 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<Pulse> queued_pulses_;
|
2024-12-03 22:28:57 -05:00
|
|
|
std::size_t pulse_pointer_ = 0;
|
|
|
|
bool is_at_end_ = false;
|
2017-07-16 22:04:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|