From: Soeren Apel Date: Sun, 7 Jan 2018 19:15:19 +0000 (+0100) Subject: Session: Make get_segment_count() consider all segments X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=9009d9b5ca2e2039725040060c0fec19e7bc3caa;p=pulseview.git Session: Make get_segment_count() consider all segments Also changes the type for the getters to uint32_t. --- diff --git a/pv/data/analog.cpp b/pv/data/analog.cpp index ed15867c..364ee5a8 100644 --- a/pv/data/analog.cpp +++ b/pv/data/analog.cpp @@ -51,9 +51,9 @@ vector< shared_ptr > Analog::segments() const segments_.begin(), segments_.end()); } -int Analog::get_segment_count() const +uint32_t Analog::get_segment_count() const { - return segments_.size(); + return (uint32_t)segments_.size(); } void Analog::clear() diff --git a/pv/data/analog.hpp b/pv/data/analog.hpp index b53e7f04..859b3e01 100644 --- a/pv/data/analog.hpp +++ b/pv/data/analog.hpp @@ -49,7 +49,7 @@ public: vector< shared_ptr > segments() const; - int get_segment_count() const; + uint32_t get_segment_count() const; void clear(); diff --git a/pv/data/logic.cpp b/pv/data/logic.cpp index 3e194d54..e78c2846 100644 --- a/pv/data/logic.cpp +++ b/pv/data/logic.cpp @@ -57,9 +57,9 @@ vector< shared_ptr > Logic::segments() const return vector< shared_ptr >(segments_.begin(), segments_.end()); } -int Logic::get_segment_count() const +uint32_t Logic::get_segment_count() const { - return segments_.size(); + return (uint32_t)segments_.size(); } void Logic::clear() diff --git a/pv/data/logic.hpp b/pv/data/logic.hpp index a371d22b..d11e0cca 100644 --- a/pv/data/logic.hpp +++ b/pv/data/logic.hpp @@ -50,7 +50,7 @@ public: vector< shared_ptr > segments() const; - int get_segment_count() const; + uint32_t get_segment_count() const; void clear(); diff --git a/pv/data/signaldata.hpp b/pv/data/signaldata.hpp index adede1c2..01dd93ab 100644 --- a/pv/data/signaldata.hpp +++ b/pv/data/signaldata.hpp @@ -45,7 +45,7 @@ public: public: virtual vector< shared_ptr > segments() const = 0; - virtual int get_segment_count() const = 0; + virtual uint32_t get_segment_count() const = 0; virtual void clear() = 0; diff --git a/pv/session.cpp b/pv/session.cpp index fb1732bb..11a867ab 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -677,16 +677,16 @@ double Session::get_samplerate() const return samplerate; } -int Session::get_segment_count() const +uint32_t Session::get_segment_count() const { - int min_val = INT_MAX; + uint32_t value = 0; - // Find the lowest common number of segments + // Find the highest number of segments for (shared_ptr data : all_signal_data_) - if (data->get_segment_count() < min_val) - min_val = data->get_segment_count(); + if (data->get_segment_count() > value) + value = data->get_segment_count(); - return (min_val != INT_MAX) ? min_val : 0; + return value; } const unordered_set< shared_ptr > Session::signalbases() const diff --git a/pv/session.hpp b/pv/session.hpp index 8ae66738..6bdfaa24 100644 --- a/pv/session.hpp +++ b/pv/session.hpp @@ -163,7 +163,7 @@ public: double get_samplerate() const; - int get_segment_count() const; + uint32_t get_segment_count() const; void register_view(shared_ptr view);