| 110 | } |
| 111 | |
| 112 | uint64_t Dg4Block::Write(std::streambuf& buffer) { |
| 113 | const bool update = FilePosition() > 0; // True if already written to file |
| 114 | if (!update) { |
| 115 | block_type_ = "##DG"; |
| 116 | block_length_ = 24 + (4 * 8) + 8; |
| 117 | link_list_.resize(4, 0); |
| 118 | } |
| 119 | |
| 120 | WriteLink4List(buffer, cg_list_, kIndexCg, |
| 121 | UpdateOption::DoUpdateAllBlocks); // Save nof samples in CG block |
| 122 | WriteMdComment(buffer, kIndexMd); |
| 123 | |
| 124 | |
| 125 | uint64_t bytes = update ? MdfBlock::Update(buffer) : MdfBlock::Write(buffer); |
| 126 | if (update) { |
| 127 | bytes = block_length_; |
| 128 | } else { |
| 129 | bytes += WriteNumber(buffer, rec_id_size_); |
| 130 | bytes += WriteBytes(buffer, 7); |
| 131 | UpdateBlockSize(buffer, bytes); |
| 132 | // Need to update the signal data link for any channels referencing |
| 133 | // VLSD CG blocks. |
| 134 | for (auto& cg4 : cg_list_) { |
| 135 | if (cg4 && (cg4->Flags() & CgFlag::VlsdChannel) ) { |
| 136 | // The previous CG block has a channel which needs to update its |
| 137 | // signal data link. |
| 138 | auto* other_cg4 = FindCgRecordId(cg4->RecordId() -1); |
| 139 | auto* cn4 = other_cg4 != nullptr ? |
| 140 | other_cg4->FindVlsdChannel(cg4->RecordId()) : nullptr; |
| 141 | if (cn4 != nullptr) { |
| 142 | cn4->UpdateDataLink(buffer, cg4->FilePosition()); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | // Need to write any data block, so it is positioned last in the file |
| 148 | // as any DT block should be appended with data bytes. The DT block must be |
| 149 | // last in the file |
| 150 | WriteLink4List(buffer, block_list_, kIndexData, |
| 151 | UpdateOption::DoUpdateOnlyLastBlock); // Update last HL or DT |
| 152 | return bytes; |
| 153 | } |
| 154 | |
| 155 | uint64_t Dg4Block::DataSize() const { return DataListBlock::DataSize(); } |
| 156 |
no test coverage detected