namespace decode {
Decoder::Decoder(const srd_decoder *const dec) :
- decoder_(dec),
+ srd_decoder_(dec),
shown_(true),
decoder_inst_(nullptr)
{
const srd_decoder* Decoder::decoder() const
{
- return decoder_;
+ return srd_decoder_;
}
const char* Decoder::name() const
{
- return decoder_->name;
+ return srd_decoder_->name;
}
bool Decoder::shown() const
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_)
const DecodeBinaryClassInfo* get_binary_class(uint32_t id) const;
private:
- const srd_decoder *const decoder_;
+ const srd_decoder* const srd_decoder_;
bool shown_;
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "decoder.hpp"
#include "row.hpp"
#include <libsigrokdecode/libsigrokdecode.h>
{
}
-Row::Row(int index, const srd_decoder *decoder, const srd_decoder_annotation_row *row) :
+Row::Row(int index, const Decoder* decoder, const srd_decoder_annotation_row* row) :
index_(index),
decoder_(decoder),
row_(row)
{
}
-const srd_decoder* Row::decoder() const
+const Decoder* Row::decoder() const
{
return decoder_;
}
-const srd_decoder_annotation_row* Row::row() const
+const srd_decoder_annotation_row* Row::srd_row() const
{
return row_;
}
const QString Row::title() const
{
- if (decoder_ && decoder_->name && row_ && row_->desc)
+ if (decoder_ && decoder_->name() && row_ && row_->desc)
return QString("%1: %2")
- .arg(QString::fromUtf8(decoder_->name),
+ .arg(QString::fromUtf8(decoder_->name()),
QString::fromUtf8(row_->desc));
- if (decoder_ && decoder_->name)
- return QString::fromUtf8(decoder_->name);
+ if (decoder_ && decoder_->name())
+ return QString::fromUtf8(decoder_->name());
if (row_ && row_->desc)
return QString::fromUtf8(row_->desc);
return QString();
return index_;
}
-bool Row::operator<(const Row &other) const
+bool Row::operator<(const Row& other) const
{
return (decoder_ < other.decoder_) ||
(decoder_ == other.decoder_ && row_ < other.row_);
}
-bool Row::operator==(const Row &other) const
+bool Row::operator==(const Row& other) const
{
- return ((decoder_ == other.decoder()) && (row_ == other.row()));
+ return ((decoder_ == other.decoder()) && (row_ == other.srd_row()));
}
} // namespace decode
namespace data {
namespace decode {
+class Decoder;
+
class Row
{
public:
Row();
- Row(int index, const srd_decoder *decoder,
- const srd_decoder_annotation_row *row = nullptr);
+ Row(int index, const Decoder* decoder,
+ const srd_decoder_annotation_row* row = nullptr);
- const srd_decoder* decoder() const;
- const srd_decoder_annotation_row* row() const;
+ const Decoder* decoder() const;
+ const srd_decoder_annotation_row* srd_row() const;
const QString title() const;
const QString class_name() const;
int index() const;
- bool operator<(const Row &other) const;
- bool operator==(const Row &other) const;
+ bool operator<(const Row& other) const;
+ bool operator==(const Row& other) const;
private:
int index_;
- const srd_decoder *decoder_;
- const srd_decoder_annotation_row *row_;
+ const Decoder* decoder_;
+ const srd_decoder_annotation_row* row_;
};
} // namespace decode
(srd_decoder_annotation_row *)l->data;
assert(ann_row);
- const Row row(row_index++, decc, ann_row);
+ const Row row(row_index++, dec.get(), ann_row);
for (const GSList *ll = ann_row->ann_classes;
ll; ll = ll->next)
- class_rows_[make_pair(decc,
- GPOINTER_TO_INT(ll->data))] = row;
+ class_rows_[make_pair(decc, GPOINTER_TO_INT(ll->data))] = row;
}
}
return result;
}
-vector<Row> DecodeSignal::get_rows() const
+vector<Row> DecodeSignal::get_rows(bool visible_only) const
{
lock_guard<mutex> lock(output_mutex_);
for (const shared_ptr<decode::Decoder>& dec : stack_) {
assert(dec);
+ if (visible_only && !dec->shown())
+ continue;
+
const srd_decoder *const decc = dec->decoder();
assert(dec->decoder());
int row_index = 0;
// Add a row for the decoder if it doesn't have a row list
if (!decc->annotation_rows)
- rows.emplace_back(row_index++, decc);
+ rows.emplace_back(row_index++, dec.get());
// Add the decoder rows
for (const GSList *l = decc->annotation_rows; l; l = l->next) {
const srd_decoder_annotation_row *const ann_row =
(srd_decoder_annotation_row *)l->data;
assert(ann_row);
- rows.emplace_back(row_index++, decc, ann_row);
+ rows.emplace_back(row_index++, dec.get(), ann_row);
}
}
int row_index = 0;
// Add a row for the decoder if it doesn't have a row list
if (!decc->annotation_rows)
- (segments_.back().annotation_rows)[Row(row_index++, decc)] =
+ (segments_.back().annotation_rows)[Row(row_index++, dec.get())] =
decode::RowData();
// Add the decoder rows
(srd_decoder_annotation_row *)l->data;
assert(ann_row);
- const Row row(row_index++, decc, ann_row);
+ const Row row(row_index++, dec.get(), ann_row);
// Add a new empty row data object
- (segments_.back().annotation_rows)[row] =
- decode::RowData();
+ (segments_.back().annotation_rows)[row] = decode::RowData();
}
}
row_iter = ds->segments_.at(ds->current_segment_id_).annotation_rows.find((*r).second);
else {
// Failing that, use the decoder as a key
- row_iter = ds->segments_.at(ds->current_segment_id_).annotation_rows.find(Row(0, decc));
+ for (const shared_ptr<decode::Decoder>& dec : ds->decoder_stack())
+ if (dec->decoder() == decc)
+ row_iter = ds->segments_.at(ds->current_segment_id_).annotation_rows.find(Row(0, dec.get()));
}
if (row_iter == ds->segments_.at(ds->current_segment_id_).annotation_rows.end()) {
int64_t get_decoded_sample_count(uint32_t segment_id,
bool include_processing) const;
- vector<decode::Row> get_rows() const;
+ vector<decode::Row> get_rows(bool visible_only=false) const;
uint64_t get_annotation_count(const decode::Row &row, uint32_t segment_id) const;
QString out_text = format;
out_text = out_text.replace("%s", sample_range);
out_text = out_text.replace("%d",
- quote + QString::fromUtf8(ann.row()->decoder()->name) + quote);
+ quote + QString::fromUtf8(ann.row()->decoder()->name()) + quote);
out_text = out_text.replace("%c", class_name);
out_text = out_text.replace("%1", first_ann_text);
out_text = out_text.replace("%a", all_ann_text);