X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Flogic.cpp;h=516060a0aec9013c139f8597dc0bf9bfd70de6aa;hp=ac47c29d6ac12d004f44c23ccc80b6678e44e78b;hb=b571a8e7e0dc3e3b6daa58f27050e76466f006dd;hpb=c063290ac7189bdd15221450f598504f43286b43 diff --git a/pv/data/logic.cpp b/pv/data/logic.cpp index ac47c29d..516060a0 100644 --- a/pv/data/logic.cpp +++ b/pv/data/logic.cpp @@ -44,7 +44,7 @@ unsigned int Logic::num_channels() const void Logic::push_segment(shared_ptr &segment) { - segments_.push_front(segment); + segments_.push_back(segment); } const deque< shared_ptr >& Logic::logic_segments() const @@ -57,6 +57,11 @@ vector< shared_ptr > Logic::segments() const return vector< shared_ptr >(segments_.begin(), segments_.end()); } +uint32_t Logic::get_segment_count() const +{ + return (uint32_t)segments_.size(); +} + void Logic::clear() { segments_.clear(); @@ -64,10 +69,18 @@ void Logic::clear() samples_cleared(); } +double Logic::get_samplerate() const +{ + if (segments_.empty()) + return 1.0; + + return segments_.front()->samplerate(); +} + uint64_t Logic::max_sample_count() const { uint64_t l = 0; - for (shared_ptr s : segments_) { + for (const shared_ptr& s : segments_) { assert(s); l = max(l, s->get_sample_count()); }