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

46 lines
1.0 KiB
C++
Raw Normal View History

//
// PulseQueuedTape.hpp
// Clock Signal
//
// Created by Thomas Harte on 16/07/2017.
// Copyright 2017 Thomas Harte. All rights reserved.
//
#pragma once
#include "Tape.hpp"
#include <vector>
2023-05-10 21:02:18 +00:00
namespace Storage::Tape {
/*!
Provides a @c Tape with a queue of upcoming pulses and an is-at-end flag.
2024-12-04 03:54:29 +00:00
If is-at-end is set then @c next_pulse() returns a second of silence and
@c is_at_end() returns @c true.
2024-12-04 03:54:29 +00: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
virtual, giving subclasses a chance to provide the next batch of pulses.
*/
class PulseQueuedSerialiser: public TapeSerialiser {
public:
void emplace_back(Pulse::Type, Time);
void push_back(Pulse);
void clear();
2024-12-03 22:33:09 +00:00
bool empty() const;
void set_is_at_end(bool);
2024-12-04 03:54:29 +00:00
Pulse next_pulse() override;
bool is_at_end() const override;
2024-12-04 03:54:29 +00:00
virtual void push_next_pulses() = 0;
private:
std::vector<Pulse> queued_pulses_;
std::size_t pulse_pointer_ = 0;
bool is_at_end_ = false;
};
}