X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=pv%2Fdata%2Fdecode%2Fannotation.cpp;h=9f86b2bab84362e26503233c3cb516ee7ebcdf41;hb=1dcd9b18186741d3ce3164f7e8d6cb13abb578d3;hp=573fefaffa8c0829bc1440e362203d15dc5065b5;hpb=3f53457656c72dc870f603677843613b708b4ea1;p=pulseview.git
diff --git a/pv/data/decode/annotation.cpp b/pv/data/decode/annotation.cpp
index 573fefaf..9f86b2ba 100644
--- a/pv/data/decode/annotation.cpp
+++ b/pv/data/decode/annotation.cpp
@@ -14,69 +14,103 @@
* 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 .
*/
extern "C" {
#include
}
+#include
#include
-#include "annotation.h"
+#include
+#include
+#include "pv/data/decode/rowdata.hpp"
+
+using std::vector;
namespace pv {
namespace data {
namespace decode {
-Annotation::Annotation(const srd_proto_data *const pdata) :
- _start_sample(pdata->start_sample),
- _end_sample(pdata->end_sample)
+Annotation::Annotation(uint64_t start_sample, uint64_t end_sample,
+ const vector* texts, Class ann_class_id, const RowData *data) :
+ start_sample_(start_sample),
+ end_sample_(end_sample),
+ texts_(texts),
+ ann_class_id_(ann_class_id),
+ data_(data)
{
- assert(pdata);
- const srd_proto_data_annotation *const pda =
- (const srd_proto_data_annotation*)pdata->data;
- assert(pda);
-
- _format = pda->ann_format;
- _row = 0;
-
- const char *const *annotations = (char**)pda->ann_text;
- while(*annotations) {
- _annotations.push_back(QString::fromUtf8(*annotations));
- annotations++;
+}
+
+Annotation::Annotation(Annotation&& a) :
+ start_sample_(a.start_sample_),
+ end_sample_(a.end_sample_),
+ texts_(a.texts_),
+ ann_class_id_(a.ann_class_id_),
+ data_(a.data_)
+{
+}
+
+Annotation& Annotation::operator=(Annotation&& a)
+{
+ if (&a != this) {
+ start_sample_ = a.start_sample_;
+ end_sample_ = a.end_sample_;
+ texts_ = a.texts_;
+ ann_class_id_ = a.ann_class_id_;
+ data_ = a.data_;
}
+
+ return *this;
+}
+
+Annotation::~Annotation()
+{
}
uint64_t Annotation::start_sample() const
{
- return _start_sample;
+ return start_sample_;
}
uint64_t Annotation::end_sample() const
{
- return _end_sample;
+ return end_sample_;
+}
+
+Annotation::Class Annotation::ann_class_id() const
+{
+ return ann_class_id_;
+}
+
+const QString Annotation::ann_class_name() const
+{
+ const AnnotationClass* ann_class =
+ data_->row()->decoder()->get_ann_class_by_id(ann_class_id_);
+
+ return QString(ann_class->name);
}
-int Annotation::format() const
+const vector* Annotation::annotations() const
{
- return _format;
+ return texts_;
}
-int Annotation::row() const
+const QString Annotation::longest_annotation() const
{
- return _row;
+ return texts_->front();
}
-const std::vector& Annotation::annotations() const
+const Row* Annotation::row() const
{
- return _annotations;
+ return data_->row();
}
-void Annotation::set_row(int row)
+bool Annotation::operator<(const Annotation &other) const
{
- _row = row;
+ return (start_sample_ < other.start_sample_);
}
} // namespace decode