]> sigrok.org Git - pulseview.git/blame - pv/data/decode/decoder.hpp
Allow more than 256 binary output classes
[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
SA
30#include <pv/data/signalbase.hpp>
31
6f925ba9 32using std::map;
6f925ba9 33using std::string;
27a3f09b 34using std::vector;
6f925ba9 35
7491a29f
JH
36struct srd_decoder;
37struct srd_decoder_inst;
8bd26d8b 38struct srd_channel;
7491a29f
JH
39struct srd_session;
40
41namespace pv {
42
7491a29f 43namespace data {
ddee4cf8
JH
44
45class Logic;
04394ded 46class SignalBase;
ddee4cf8 47
7491a29f
JH
48namespace decode {
49
a82325d1
SA
50class Decoder;
51
52struct DecodeChannel
53{
54 uint16_t id; ///< Global numerical ID for the decode channels in the stack
55 uint16_t bit_id; ///< Tells which bit within a sample represents this channel
56 const bool is_optional;
57 const pv::data::SignalBase *assigned_signal;
58 const QString name, desc;
59 int initial_pin_state;
60 const shared_ptr<Decoder> decoder_;
61 const srd_channel *pdch_;
62};
63
e77de61f
SA
64struct DecodeBinaryClassInfo
65{
ac9494ef 66 uint32_t bin_class_id;
e77de61f
SA
67 char* name;
68 char* description;
69};
70
a82325d1 71
7491a29f
JH
72class Decoder
73{
74public:
520362f8 75 Decoder(const srd_decoder *const dec);
7491a29f
JH
76
77 virtual ~Decoder();
78
79 const srd_decoder* decoder() const;
80
e77de61f
SA
81 const char* name() const;
82
dd048a7e
JH
83 bool shown() const;
84 void show(bool show = true);
85
a82325d1
SA
86 const vector<DecodeChannel*>& channels() const;
87 void set_channels(vector<DecodeChannel*> channels);
7491a29f 88
6f925ba9 89 const map<string, GVariant*>& options() const;
7491a29f
JH
90
91 void set_option(const char *id, GVariant *value);
92
72486b78
SA
93 void apply_all_options();
94
6ac6242b 95 bool have_required_channels() const;
a2d4b551 96
8ce0e732
SA
97 srd_decoder_inst* create_decoder_inst(srd_session *session);
98 void invalidate_decoder_inst();
7491a29f 99
ac9494ef
SA
100 uint32_t get_binary_class_count() const;
101 const DecodeBinaryClassInfo* get_binary_class(uint32_t id) const;
a82325d1 102
7491a29f 103private:
8dbbc7f0 104 const srd_decoder *const decoder_;
dd048a7e 105
8dbbc7f0 106 bool shown_;
dd048a7e 107
a82325d1 108 vector<DecodeChannel*> channels_;
e77de61f 109 vector<DecodeBinaryClassInfo> bin_classes_;
6f925ba9 110 map<string, GVariant*> options_;
8ce0e732 111 srd_decoder_inst *decoder_inst_;
7491a29f
JH
112};
113
114} // namespace decode
115} // namespace data
116} // namespace pv
117
7a01bd36 118#endif // PULSEVIEW_PV_DATA_DECODE_DECODER_HPP