]> sigrok.org Git - pulseview.git/blobdiff - pv/data/decode/annotation.cpp
Rework decoder infrastructure
[pulseview.git] / pv / data / decode / annotation.cpp
index 96a594c3c6ce57a07f621ce9ddf9cd439fed1acd..55caa2d7adbfb9810260811ef5b6c0b1372ef2f3 100644 (file)
@@ -24,7 +24,7 @@ extern "C" {
 #include <cassert>
 #include <vector>
 
-#include "annotation.hpp"
+#include <pv/data/decode/annotation.hpp>
 
 using std::vector;
 
@@ -32,9 +32,10 @@ namespace pv {
 namespace data {
 namespace decode {
 
-Annotation::Annotation(const srd_proto_data *const pdata) :
+Annotation::Annotation(const srd_proto_data *const pdata, const Row *row) :
        start_sample_(pdata->start_sample),
-       end_sample_(pdata->end_sample)
+       end_sample_(pdata->end_sample),
+       row_(row)
 {
        assert(pdata);
        const srd_proto_data_annotation *const pda =
@@ -48,6 +49,8 @@ Annotation::Annotation(const srd_proto_data *const pdata) :
                annotations_.push_back(QString::fromUtf8(*annotations));
                annotations++;
        }
+
+       annotations_.shrink_to_fit();
 }
 
 uint64_t Annotation::start_sample() const
@@ -70,6 +73,16 @@ const vector<QString>& Annotation::annotations() const
        return annotations_;
 }
 
+const Row* Annotation::row() const
+{
+       return row_;
+}
+
+bool Annotation::operator<(const Annotation &other) const
+{
+       return (start_sample_ < other.start_sample_);
+}
+
 } // namespace decode
 } // namespace data
 } // namespace pv