X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fdecodesignal.cpp;h=05dc3428ab5ce8e9f2bcb964175b55fceb3557d2;hp=9da7de6766c418e759ea1f02d88ba8ab8614c551;hb=5a914348e8c95f92fd7c1c5988d563c5fb472aa2;hpb=1ed996b433f3391f54846784d76da4fe6b07500f diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 9da7de6..05dc342 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -17,6 +17,7 @@ * along with this program; if not, see . */ +#include #include #include @@ -32,6 +33,7 @@ #include #include +using std::forward_list; using std::lock_guard; using std::make_pair; using std::make_shared; @@ -471,6 +473,33 @@ void DecodeSignal::get_annotation_subset( } } +void DecodeSignal::get_annotation_subset( + vector &dest, + uint32_t segment_id, uint64_t start_sample, uint64_t end_sample) const +{ + // Note: We put all vectors and lists on the heap, not the stack + + const vector rows = visible_rows(); + + // Use forward_lists for faster merging + forward_list *all_ann_list = new forward_list(); + + for (const Row& row : rows) { + vector *ann_vector = new vector(); + get_annotation_subset(*ann_vector, row, segment_id, start_sample, end_sample); + + forward_list *ann_list = + new forward_list(ann_vector->begin(), ann_vector->end()); + delete ann_vector; + + all_ann_list->merge(*ann_list); + delete ann_list; + } + + move(all_ann_list->begin(), all_ann_list->end(), back_inserter(dest)); + delete all_ann_list; +} + void DecodeSignal::save_settings(QSettings &settings) const { SignalBase::save_settings(settings); @@ -1225,7 +1254,7 @@ void DecodeSignal::annotation_callback(srd_proto_data *pdata, void *decode_signa } // Add the annotation - (*row_iter).second.emplace_annotation(pdata); + (*row_iter).second.emplace_annotation(pdata, &((*row_iter).first)); } void DecodeSignal::on_capture_state_changed(int state)