]> sigrok.org Git - pulseview.git/blame - pv/data/decode/decoder.hpp
TabularDecView: Implement "hide hidden rows/classes" checkbox
[pulseview.git] / pv / data / decode / decoder.hpp
CommitLineData
7491a29f
JH
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
efdec55a 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
7491a29f
JH
18 */
19
7a01bd36
JH
20#ifndef PULSEVIEW_PV_DATA_DECODE_DECODER_HPP
21#define PULSEVIEW_PV_DATA_DECODE_DECODER_HPP
7491a29f
JH
22
23#include <map>
f9abf97e 24#include <memory>
ddee4cf8 25#include <set>
27a3f09b 26#include <vector>
7491a29f 27
7491a29f
JH
28#include <glib.h>
29
a82325d1 30#include <pv/data/signalbase.hpp>
6a26fc44 31#include <pv/data/decode/row.hpp>
a82325d1 32
6f925ba9 33using std::map;
6f925ba9 34using std::string;
27a3f09b 35using std::vector;
6f925ba9 36
7491a29f
JH
37struct srd_decoder;
38struct srd_decoder_inst;
8bd26d8b 39struct srd_channel;
7491a29f
JH
40struct srd_session;
41
42namespace pv {
43
7491a29f 44namespace data {
ddee4cf8
JH
45
46class Logic;
04394ded 47class SignalBase;
ddee4cf8 48
7491a29f
JH
49namespace decode {
50
a82325d1
SA
51class Decoder;
52
6a26fc44
SA
53struct AnnotationClass
54{
55 size_t id;
56 char* name;
57 char* description;
58 Row* row;
59 bool visible;
60};
61
a82325d1
SA
62struct DecodeChannel
63{
64 uint16_t id; ///< Global numerical ID for the decode channels in the stack
65 uint16_t bit_id; ///< Tells which bit within a sample represents this channel
66 const bool is_optional;
67 const pv::data::SignalBase *assigned_signal;
68 const QString name, desc;
69 int initial_pin_state;
70 const shared_ptr<Decoder> decoder_;
71 const srd_channel *pdch_;
72};
73
e77de61f
SA
74struct DecodeBinaryClassInfo
75{
ac9494ef 76 uint32_t bin_class_id;
e77de61f
SA
77 char* name;
78 char* description;
79};
80
a82325d1 81
7491a29f
JH
82class Decoder
83{
84public:
f54e68b0 85 Decoder(const srd_decoder *const dec, uint8_t stack_level);
7491a29f
JH
86
87 virtual ~Decoder();
88
6a26fc44 89 const srd_decoder* get_srd_decoder() const;
7491a29f 90
f54e68b0
SA
91 uint8_t get_stack_level() const;
92
e77de61f
SA
93 const char* name() const;
94
5d3ca591
SA
95 bool visible() const;
96 void set_visible(bool visible);
dd048a7e 97
a82325d1
SA
98 const vector<DecodeChannel*>& channels() const;
99 void set_channels(vector<DecodeChannel*> channels);
7491a29f 100
6f925ba9 101 const map<string, GVariant*>& options() const;
7491a29f
JH
102 void set_option(const char *id, GVariant *value);
103
72486b78
SA
104 void apply_all_options();
105
6ac6242b 106 bool have_required_channels() const;
a2d4b551 107
8ce0e732
SA
108 srd_decoder_inst* create_decoder_inst(srd_session *session);
109 void invalidate_decoder_inst();
7491a29f 110
6a26fc44
SA
111 vector<Row*> get_rows();
112 Row* get_row_by_id(size_t id);
113
114 vector<const AnnotationClass*> ann_classes() const;
41293691 115 vector<AnnotationClass*> ann_classes();
6a26fc44 116 AnnotationClass* get_ann_class_by_id(size_t id);
761f8302 117 const AnnotationClass* get_ann_class_by_id(size_t id) const;
6a26fc44 118
ac9494ef
SA
119 uint32_t get_binary_class_count() const;
120 const DecodeBinaryClassInfo* get_binary_class(uint32_t id) const;
a82325d1 121
7491a29f 122private:
cbb2e4da 123 const srd_decoder* const srd_decoder_;
f54e68b0 124 uint8_t stack_level_;
dd048a7e 125
5d3ca591 126 bool visible_;
dd048a7e 127
a82325d1 128 vector<DecodeChannel*> channels_;
6a26fc44
SA
129 vector<Row> rows_;
130 vector<AnnotationClass> ann_classes_;
e77de61f 131 vector<DecodeBinaryClassInfo> bin_classes_;
6f925ba9 132 map<string, GVariant*> options_;
8ce0e732 133 srd_decoder_inst *decoder_inst_;
7491a29f
JH
134};
135
136} // namespace decode
137} // namespace data
138} // namespace pv
139
7a01bd36 140#endif // PULSEVIEW_PV_DATA_DECODE_DECODER_HPP