X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fdata%2Fdecode%2Fdecoder.cpp;h=19f11399fec78bae58fc809d71bfb6b0aded71d1;hb=cbb2e4da8042495531b406f745ee9d9e20448ef6;hp=6ce60da8559c96e1e81e7b4e974ba4a6d42874a5;hpb=c5f473341f9198532c44525104d04792c1bd6459;p=pulseview.git diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index 6ce60da8..19f11399 100644 --- a/pv/data/decode/decoder.cpp +++ b/pv/data/decode/decoder.cpp @@ -29,7 +29,6 @@ #include #include -using pv::data::DecodeChannel; using std::map; using std::string; @@ -38,10 +37,18 @@ namespace data { namespace decode { Decoder::Decoder(const srd_decoder *const dec) : - decoder_(dec), + srd_decoder_(dec), shown_(true), decoder_inst_(nullptr) { + // Query the decoder outputs + uint32_t i = 0; + for (GSList *l = dec->binary; l; l = l->next) { + char **bin_class = (char**)l->data; + char *name = bin_class[0]; + char *desc = bin_class[1]; + bin_classes_.push_back({i++, name, desc}); + } } Decoder::~Decoder() @@ -52,7 +59,12 @@ Decoder::~Decoder() const srd_decoder* Decoder::decoder() const { - return decoder_; + return srd_decoder_; +} + +const char* Decoder::name() const +{ + return srd_decoder_->name; } bool Decoder::shown() const @@ -87,6 +99,11 @@ void Decoder::set_option(const char *id, GVariant *value) options_[id] = value; // If we have a decoder instance, apply option value immediately + apply_all_options(); +} + +void Decoder::apply_all_options() +{ if (decoder_inst_) { GHashTable *const opt_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref); @@ -127,7 +144,7 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session) if (decoder_inst_) qDebug() << "WARNING: previous decoder instance" << decoder_inst_ << "exists"; - decoder_inst_ = srd_inst_new(session, decoder_->id, opt_hash); + decoder_inst_ = srd_inst_new(session, srd_decoder_->id, opt_hash); g_hash_table_destroy(opt_hash); if (!decoder_inst_) @@ -167,6 +184,16 @@ void Decoder::invalidate_decoder_inst() decoder_inst_ = nullptr; } +uint32_t Decoder::get_binary_class_count() const +{ + return bin_classes_.size(); +} + +const DecodeBinaryClassInfo* Decoder::get_binary_class(uint32_t id) const +{ + return &(bin_classes_.at(id)); +} + } // namespace decode } // namespace data } // namespace pv