]> sigrok.org Git - pulseview.git/blobdiff - pv/data/decode/decoder.cpp
TabularDecView: Make the model/view work
[pulseview.git] / pv / data / decode / decoder.cpp
index 99118d1707e5361e9f9449fbb6b24e18b1cd61f1..600382feddb576346f9c835b44934a1cd049670b 100644 (file)
@@ -36,9 +36,10 @@ namespace pv {
 namespace data {
 namespace decode {
 
-Decoder::Decoder(const srd_decoder *const dec) :
+Decoder::Decoder(const srd_decoder *const dec, uint8_t stack_level) :
        srd_decoder_(dec),
-       shown_(true),
+       stack_level_(stack_level),
+       visible_(true),
        decoder_inst_(nullptr)
 {
        // Query the annotation output classes
@@ -69,7 +70,7 @@ Decoder::Decoder(const srd_decoder *const dec) :
        for (const GSList *rl = srd_decoder_->annotation_rows; rl; rl = rl->next) {
                const srd_decoder_annotation_row *const srd_row = (srd_decoder_annotation_row *)rl->data;
                assert(srd_row);
-               rows_.push_back({i++, this, srd_row});
+               rows_.emplace_back(i++, this, srd_row);
 
                // FIXME PV can crash from .at() if a PD's ann classes are defined incorrectly
                for (const GSList *cl = srd_row->ann_classes; cl; cl = cl->next)
@@ -78,7 +79,7 @@ Decoder::Decoder(const srd_decoder *const dec) :
 
        if (rows_.empty()) {
                // Make sure there is a row for PDs without row declarations
-               rows_.push_back({0, this});
+               rows_.emplace_back(0, this);
 
                for (AnnotationClass& c : ann_classes_)
                        c.row = &(rows_.back());
@@ -96,19 +97,24 @@ const srd_decoder* Decoder::get_srd_decoder() const
        return srd_decoder_;
 }
 
+uint8_t Decoder::get_stack_level() const
+{
+       return stack_level_;
+}
+
 const char* Decoder::name() const
 {
        return srd_decoder_->name;
 }
 
-bool Decoder::shown() const
+bool Decoder::visible() const
 {
-       return shown_;
+       return visible_;
 }
 
-void Decoder::show(bool show)
+void Decoder::set_visible(bool visible)
 {
-       shown_ = show;
+       visible_ = visible;
 }
 
 const vector<DecodeChannel*>& Decoder::channels() const
@@ -264,6 +270,14 @@ AnnotationClass* Decoder::get_ann_class_by_id(size_t id)
        return &(ann_classes_[id]);
 }
 
+const AnnotationClass* Decoder::get_ann_class_by_id(size_t id) const
+{
+       if (id >= ann_classes_.size())
+               return nullptr;
+
+       return &(ann_classes_[id]);
+}
+
 uint32_t Decoder::get_binary_class_count() const
 {
        return bin_classes_.size();