1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
From 586443347689523018e36be7bd439c5572fcbd87 Mon Sep 17 00:00:00 2001
From: Mike Walters <mike@flomp.net>
Date: Fri, 21 Jan 2022 21:41:56 +0000
Subject: [PATCH 25/31] sigmf: construct Annotations in-place
---
src/inputsource.cpp | 10 ++++------
src/samplesource.h | 5 ++++-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/inputsource.cpp b/src/inputsource.cpp
index 86b2fd5..974dac9 100644
--- a/src/inputsource.cpp
+++ b/src/inputsource.cpp
@@ -273,8 +273,6 @@ void InputSource::readMetaData(const QString &filename)
if(annotation_ref.isObject()) {
auto sigmf_annotation = annotation_ref.toObject();
- Annotation a;
-
const size_t sample_start = sigmf_annotation["core:sample_start"].toDouble();
if (sample_start < offset)
@@ -283,15 +281,15 @@ void InputSource::readMetaData(const QString &filename)
const size_t rel_sample_start = sample_start - offset;
const size_t sample_count = sigmf_annotation["core:sample_count"].toDouble();
- a.sampleRange = range_t<size_t>{rel_sample_start, rel_sample_start + sample_count - 1};
+ auto sampleRange = range_t<size_t>{rel_sample_start, rel_sample_start + sample_count - 1};
const double freq_lower_edge = sigmf_annotation["core:freq_lower_edge"].toDouble();
const double freq_upper_edge = sigmf_annotation["core:freq_upper_edge"].toDouble();
- a.frequencyRange = range_t<double>{freq_lower_edge, freq_upper_edge};
+ auto frequencyRange = range_t<double>{freq_lower_edge, freq_upper_edge};
- a.description = sigmf_annotation["core:description"].toString();
+ auto description = sigmf_annotation["core:description"].toString();
- annotationList.append(a);
+ annotationList.emplace_back(sampleRange, frequencyRange, description);
}
}
}
diff --git a/src/samplesource.h b/src/samplesource.h
index 9995eb4..88e53a3 100644
--- a/src/samplesource.h
+++ b/src/samplesource.h
@@ -33,6 +33,9 @@ public:
range_t<size_t> sampleRange;
range_t<double> frequencyRange;
QString description;
+
+ Annotation(range_t<size_t> sampleRange, range_t<double>frequencyRange, QString description)
+ : sampleRange(sampleRange), frequencyRange(frequencyRange), description(description) {}
};
template<typename T>
@@ -49,7 +52,7 @@ public:
virtual size_t count() = 0;
virtual double rate() = 0;
virtual float relativeBandwidth() = 0;
- QList<Annotation> annotationList;
+ std::vector<Annotation> annotationList;
std::type_index sampleType() override;
virtual bool realSignal() { return false; };
double getFrequency();
--
2.35.1
|