X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fdata%2Fdecode%2Frowdata.cpp;h=2a26169eb6cc0f14adb5a107726c40ee891838b6;hb=b9591f3a680dd35b7af2fb482a136b1bd494c6e4;hp=a06af6169a9803997dd2e2b4d130f3c85e471b3c;hpb=f9101a91fc942a28515872ae6c7285973bd54b91;p=pulseview.git
diff --git a/pv/data/decode/rowdata.cpp b/pv/data/decode/rowdata.cpp
index a06af61..2a26169 100644
--- a/pv/data/decode/rowdata.cpp
+++ b/pv/data/decode/rowdata.cpp
@@ -14,15 +14,10 @@
* 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 .
*/
-#include
-
-#include
-
-#include "rowdata.h"
+#include "rowdata.hpp"
using std::vector;
@@ -30,89 +25,28 @@ namespace pv {
namespace data {
namespace decode {
-RowData::RowData()
-{
-}
-
uint64_t RowData::get_max_sample() const
{
- if (_annotations.empty())
+ if (annotations_.empty())
return 0;
- return _annotations.back().end_sample();
+ return annotations_.back().end_sample();
}
void RowData::get_annotation_subset(
- std::vector &dest,
+ vector &dest,
uint64_t start_sample, uint64_t end_sample) const
{
- const vector::const_iterator start_iter =
- lower_bound(_ann_end_index.begin(),
- _ann_end_index.end(), start_sample,
- bind(&RowData::index_entry_end_sample_lt,
- this, _1, _2));
-
- const vector::const_iterator end_iter =
- upper_bound(_ann_start_index.begin(),
- _ann_start_index.end(), end_sample,
- bind(&RowData::index_entry_start_sample_gt,
- this, _1, _2));
-
- for (vector::const_iterator i = start_iter;
- i != _ann_end_index.end() && *i != *end_iter; i++)
- dest.push_back(_annotations[*i]);
-}
-
-void RowData::push_annotation(const Annotation &a)
-{
- const size_t offset = _annotations.size();
- _annotations.push_back(a);
-
- // Insert the annotation into the start index
- vector::iterator i = _ann_start_index.end();
- if (!_ann_start_index.empty() &&
- _annotations[_ann_start_index.back()].start_sample() >
- a.start_sample())
- i = upper_bound(_ann_start_index.begin(),
- _ann_start_index.end(), a.start_sample(),
- bind(&RowData::index_entry_start_sample_gt,
- this, _1, _2));
-
- _ann_start_index.insert(i, offset);
-
- // Insert the annotation into the end index
- vector::iterator j = _ann_end_index.end();
- if (!_ann_end_index.empty() &&
- _annotations[_ann_end_index.back()].end_sample() <
- a.end_sample())
- j = upper_bound(_ann_end_index.begin(),
- _ann_end_index.end(), a.end_sample(),
- bind(&RowData::index_entry_end_sample_gt,
- this, _1, _2));
-
- _ann_end_index.insert(j, offset);
-}
-
-bool RowData::index_entry_start_sample_gt(
- const uint64_t sample, const size_t index) const
-{
- assert(index < _annotations.size());
- return _annotations[index].start_sample() > sample;
-}
-
-bool RowData::index_entry_end_sample_lt(
- const size_t index, const uint64_t sample) const
-{
- assert(index < _annotations.size());
- return _annotations[index].end_sample() < sample;
+ for (const auto& annotation : annotations_)
+ if (annotation.end_sample() > start_sample &&
+ annotation.start_sample() <= end_sample)
+ dest.push_back(annotation);
}
-bool RowData::index_entry_end_sample_gt(
- const uint64_t sample, const size_t index) const
+void RowData::emplace_annotation(srd_proto_data *pdata, const Row *row)
{
- assert(index < _annotations.size());
- return _annotations[index].end_sample() > sample;
+ annotations_.emplace_back(pdata, row);
}
-} // decode
-} // data
-} // pv
+} // namespace decode
+} // namespace data
+} // namespace pv