2016-12-17 00:20:38 +00:00
|
|
|
//
|
|
|
|
// PCMPatchedTrack.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 15/12/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef PCMPatchedTrack_hpp
|
|
|
|
#define PCMPatchedTrack_hpp
|
|
|
|
|
|
|
|
#include "PCMTrack.hpp"
|
2016-12-19 12:42:43 +00:00
|
|
|
#include "PCMSegment.hpp"
|
2016-12-17 00:20:38 +00:00
|
|
|
|
|
|
|
namespace Storage {
|
|
|
|
namespace Disk {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
A subclass of @c Track that patches an existing track with PCM segments.
|
|
|
|
*/
|
|
|
|
class PCMPatchedTrack: public Track {
|
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
Constructs a @c PCMPatchedTrack that will return events from @c underlying_track in
|
|
|
|
regions where it has not had alternative PCM data installed.
|
|
|
|
*/
|
2016-12-17 23:17:22 +00:00
|
|
|
PCMPatchedTrack(std::shared_ptr<Track> underlying_track);
|
2016-12-17 00:20:38 +00:00
|
|
|
|
2016-12-30 22:25:39 +00:00
|
|
|
/*!
|
|
|
|
Copy constructor, for Track.
|
|
|
|
*/
|
|
|
|
PCMPatchedTrack(const PCMPatchedTrack &);
|
|
|
|
|
2016-12-17 00:20:38 +00:00
|
|
|
/*!
|
|
|
|
Replaces whatever is currently on the track from @c start_position to @c start_position + segment length
|
|
|
|
with the contents of @c segment.
|
|
|
|
*/
|
2016-12-19 12:42:43 +00:00
|
|
|
void add_segment(const Time &start_time, const PCMSegment &segment);
|
2016-12-17 00:20:38 +00:00
|
|
|
|
|
|
|
// To satisfy Storage::Disk::Track
|
|
|
|
Event get_next_event();
|
2016-12-17 21:26:45 +00:00
|
|
|
Time seek_to(const Time &time_since_index_hole);
|
2016-12-30 22:25:39 +00:00
|
|
|
Track *clone();
|
2016-12-17 00:20:38 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-17 23:17:22 +00:00
|
|
|
std::shared_ptr<Track> underlying_track_;
|
2016-12-19 12:42:43 +00:00
|
|
|
|
|
|
|
struct Period {
|
|
|
|
Time start_time, end_time;
|
|
|
|
Time segment_start_time;
|
2016-12-20 23:13:10 +00:00
|
|
|
std::shared_ptr<PCMSegmentEventSource> event_source; // nullptr => use the underlying track
|
2016-12-19 12:42:43 +00:00
|
|
|
|
2016-12-20 23:32:49 +00:00
|
|
|
void push_start_to_time(const Storage::Time &new_start_time);
|
|
|
|
void trim_end_to_time(const Storage::Time &new_end_time);
|
|
|
|
|
2016-12-20 23:13:10 +00:00
|
|
|
Period(const Time &start_time, const Time &end_time, const Time &segment_start_time, std::shared_ptr<PCMSegmentEventSource> event_source) :
|
2016-12-19 12:42:43 +00:00
|
|
|
start_time(start_time), end_time(end_time), segment_start_time(segment_start_time), event_source(event_source) {}
|
2016-12-30 22:39:52 +00:00
|
|
|
Period(const Period &);
|
2016-12-17 00:20:38 +00:00
|
|
|
};
|
2016-12-19 12:42:43 +00:00
|
|
|
std::vector<Period> periods_;
|
2016-12-20 12:30:57 +00:00
|
|
|
std::vector<Period>::iterator active_period_;
|
2016-12-26 03:00:39 +00:00
|
|
|
Time current_time_, insertion_error_;
|
2016-12-19 12:42:43 +00:00
|
|
|
|
|
|
|
void insert_period(const Period &period);
|
2016-12-17 00:20:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* PCMPatchedTrack_hpp */
|