]> sigrok.org Git - pulseview.git/blobdiff - pv/data/analogsegment.hpp
Segment: Do not alter chunks when there are active iterators
[pulseview.git] / pv / data / analogsegment.hpp
index 46c6b6754655d4067e5b5e8c6fd5e1124cfd24ae..27c9863b07b0a830806ba7ec5dd122653648a6e2 100644 (file)
@@ -14,8 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #ifndef PULSEVIEW_PV_DATA_ANALOGSEGMENT_HPP
@@ -26,6 +25,8 @@
 #include <utility>
 #include <vector>
 
+#include <QObject>
+
 namespace AnalogSegmentTest {
 struct Basic;
 }
@@ -33,8 +34,18 @@ struct Basic;
 namespace pv {
 namespace data {
 
-class AnalogSegment : public Segment
+class Analog;
+
+typedef struct {
+       uint64_t sample_index, chunk_num, chunk_offs;
+       uint8_t* chunk;
+       float* value;
+} SegmentAnalogDataIterator;
+
+class AnalogSegment : public QObject, public Segment
 {
+       Q_OBJECT
+
 public:
        struct EnvelopeSample
        {
@@ -66,7 +77,7 @@ private:
        static const uint64_t EnvelopeDataUnit;
 
 public:
-       AnalogSegment(uint64_t samplerate, uint64_t expected_num_samples = 0);
+       AnalogSegment(Analog& owner, uint64_t samplerate);
 
        virtual ~AnalogSegment();
 
@@ -76,6 +87,12 @@ public:
        const float* get_samples(int64_t start_sample,
                int64_t end_sample) const;
 
+       const std::pair<float, float> get_min_max() const;
+
+       SegmentAnalogDataIterator* begin_sample_iteration(uint64_t start);
+       void continue_sample_iteration(SegmentAnalogDataIterator* it, uint64_t increase);
+       void end_sample_iteration(SegmentAnalogDataIterator* it);
+
        void get_envelope_section(EnvelopeSection &s,
                uint64_t start, uint64_t end, float min_length) const;
 
@@ -85,8 +102,12 @@ private:
        void append_payload_to_envelope_levels();
 
 private:
+       Analog& owner_;
+
        struct Envelope envelope_levels_[ScaleStepCount];
 
+       float min_value_, max_value_;
+
        friend struct AnalogSegmentTest::Basic;
 };