From 0f3a52cbc8abde43ef6ed584eb2403960d994fc1 Mon Sep 17 00:00:00 2001 From: Stefan Pöschel Date: Mon, 6 Feb 2017 15:51:15 +0100 Subject: PAD: make PADPacketizer queue private --- src/odr-padenc.cpp | 12 ++++++------ src/pad_common.cpp | 7 +++++++ src/pad_common.h | 7 +++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/odr-padenc.cpp b/src/odr-padenc.cpp index 0766411..c96ca7a 100644 --- a/src/odr-padenc.cpp +++ b/src/odr-padenc.cpp @@ -1038,8 +1038,8 @@ int encodeFile(int output_fd, const std::string& fname, int fidx, bool raw_slide mscdg = packMscDG(&msc); dgli = createDataGroupLengthIndicator(mscdg->data.size()); - pad_packetizer->queue.push_back(dgli); - pad_packetizer->queue.push_back(mscdg); + pad_packetizer->AddDG(dgli, false); + pad_packetizer->AddDG(mscdg, false); for (i = 0; i < nseg; i++) { curseg = blob + i * MAXSEGLEN; @@ -1056,8 +1056,8 @@ int encodeFile(int output_fd, const std::string& fname, int fidx, bool raw_slide mscdg = packMscDG(&msc); dgli = createDataGroupLengthIndicator(mscdg->data.size()); - pad_packetizer->queue.push_back(dgli); - pad_packetizer->queue.push_back(mscdg); + pad_packetizer->AddDG(dgli, false); + pad_packetizer->AddDG(mscdg, false); } pad_packetizer->WriteAllPADs(output_fd); @@ -1492,7 +1492,7 @@ void writeDLS(int output_fd, const std::string& dls_file, uint8_t charset, bool prepend_dl_dgs(dl_state, charset); if (remove_label_dg) - pad_packetizer->queue.push_front(remove_label_dg); + pad_packetizer->AddDG(remove_label_dg, true); pad_packetizer->WriteAllPADs(output_fd); } @@ -1556,7 +1556,7 @@ void prepend_dl_dgs(const DL_STATE& dl_state, uint8_t charset) { segs.push_back(createDynamicLabelPlus(dl_state)); // prepend to packetizer - pad_packetizer->queue.insert(pad_packetizer->queue.begin(), segs.begin(), segs.end()); + pad_packetizer->AddDGs(segs, true); #ifdef DEBUG fprintf(stderr, "PAD length: %d\n", padlen); diff --git a/src/pad_common.cpp b/src/pad_common.cpp index 9cbd11f..450b122 100644 --- a/src/pad_common.cpp +++ b/src/pad_common.cpp @@ -98,6 +98,13 @@ PADPacketizer::~PADPacketizer() { } } +void PADPacketizer::AddDG(DATA_GROUP* dg, bool prepend) { + queue.insert(prepend ? queue.begin() : queue.end(), dg); +} + +void PADPacketizer::AddDGs(const std::vector& dgs, bool prepend) { + queue.insert(prepend ? queue.begin() : queue.end(), dgs.cbegin(), dgs.cend()); +} pad_t* PADPacketizer::GetPAD() { bool pad_flushable = false; diff --git a/src/pad_common.h b/src/pad_common.h index 064774c..c997d83 100644 --- a/src/pad_common.h +++ b/src/pad_common.h @@ -65,6 +65,8 @@ private: const bool short_xpad; const size_t max_cis; + std::deque queue; + size_t xpad_size; uint8_t subfields[4*48]; size_t subfields_size; @@ -98,11 +100,12 @@ public: static const size_t VARSIZE_PAD_MAX; static const std::string ALLOWED_PADLEN; - std::deque queue; - PADPacketizer(size_t pad_size); ~PADPacketizer(); + void AddDG(DATA_GROUP* dg, bool prepend); + void AddDGs(const std::vector& dgs, bool prepend); + pad_t* GetPAD(); // will be removed, when pull (instead of push) approach is implemented! -- cgit v1.2.3