X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fdata%2Fdecode%2Fdecoder.cpp;h=8e7ffb50072b14577c0adce5ef4013d998eb18bd;hb=a61abf09a38e9b2e0bb7bd1753903069e0cad150;hp=6ce60da8559c96e1e81e7b4e974ba4a6d42874a5;hpb=c5f473341f9198532c44525104d04792c1bd6459;p=pulseview.git diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index 6ce60da8..8e7ffb50 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; @@ -42,6 +41,14 @@ Decoder::Decoder(const srd_decoder *const dec) : shown_(true), decoder_inst_(nullptr) { + // Query the decoder outputs + uint8_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() @@ -55,6 +62,11 @@ const srd_decoder* Decoder::decoder() const return decoder_; } +const char* Decoder::name() const +{ + return decoder_->name; +} + bool Decoder::shown() const { return shown_; @@ -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); @@ -167,6 +184,16 @@ void Decoder::invalidate_decoder_inst() decoder_inst_ = nullptr; } +uint8_t Decoder::get_binary_class_count() const +{ + return bin_classes_.size(); +} + +const DecodeBinaryClassInfo* Decoder::get_binary_class(uint8_t id) const +{ + return &(bin_classes_.at(id)); +} + } // namespace decode } // namespace data } // namespace pv