19 assert(
typeid(*
this) ==
typeid(other));
65 assert(!pTrack || iChannel < pTrack->NChannels());
68 const auto pAttachments =
71 if (!pAttachments ||
iChannel >= pAttachments->mAttachments.size())
91 for (
size_t ii = 0; ii < nn; ++ii) {
100 for (
size_t ii = 0; ii < nn; ++ii) {
109 for (
size_t ii = 0; ii < nn; ++ii) {
120 [&](
auto &pAttachment) {
121 bool result = pAttachment &&
122 pAttachment->HandleXMLAttribute(attr, valueView, ii);
131 assert(
typeid(*
this) ==
typeid(other));
133 assert(other.Size() <= 1);
137 for (
auto &ptr : other.mAttachments) {
138 if (
auto &pAttachment =
mAttachments.emplace_back(move(ptr)))
139 pAttachment->Reparent(parent, index++);
141 other.mAttachments.clear();
151 for (
auto ii : { 0, 1 })
153 pAttachment->Reparent(parent, ii);
164 pAttachment->Reparent(parent, index);
Adapts TrackAttachment interface with extra channel index argument.
virtual ~ChannelAttachment()
virtual void WriteXMLAttributes(XMLWriter &writer, size_t iChannel) const
Serialize persistent attributes.
virtual bool HandleXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &valueView, size_t iChannel)
Deserialize an attribute, returning true if recognized.
virtual void Reparent(const std::shared_ptr< Track > &parent, size_t iChannel)
Object may be shared among tracks but hold a special back-pointer to one of them; reassign it.
virtual void CopyTo(Track &track, size_t iChannel) const
Copy state, for undo/redo purposes.
Holds multiple objects as a single attachment to Track.
std::vector< std::shared_ptr< ChannelAttachment > > mAttachments
void Erase(const std::shared_ptr< Track > &parent, size_t index)
~ChannelAttachmentsBase() override
void SwapChannels(const std::shared_ptr< Track > &parent)
ChannelAttachmentsBase & operator=(const ChannelAttachmentsBase &)=delete
void WriteXMLAttributes(XMLWriter &writer) const override
Serialize persistent attributes.
void Reparent(const std::shared_ptr< Track > &parent) override
Object may be shared among tracks but hold a special back-pointer to one of them; reassign it.
static ChannelAttachment & Get(const AttachedTrackObjects::RegisteredFactory &key, Track &track, size_t iChannel)
std::function< std::shared_ptr< ChannelAttachment >(Track &, size_t)> Factory
static ChannelAttachment * Find(const AttachedTrackObjects::RegisteredFactory &key, Track *pTrack, size_t iChannel)
bool HandleXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &valueView) override
Deserialize an attribute, returning true if recognized.
void CopyTo(Track &track) const override
Copy state, for undo/redo purposes.
void MakeStereo(const std::shared_ptr< Track > &parent, ChannelAttachmentsBase &&other)
ChannelAttachmentsBase(Track &track, Factory factory)
virtual size_t NChannels() const =0
Report the number of channels.
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Abstract base class for an object holding data associated with points on a time axis.
A view into an attribute value. The class does not take the ownership of the data.
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)