]>
Commit | Line | Data |
---|---|---|
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 | |
17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
20 | #ifndef PULSEVIEW_PV_DATA_DECODE_DECODER_HPP | |
21 | #define PULSEVIEW_PV_DATA_DECODE_DECODER_HPP | |
22 | ||
23 | #include <map> | |
24 | #include <memory> | |
25 | #include <set> | |
26 | #include <vector> | |
27 | ||
28 | #include <glib.h> | |
29 | ||
30 | #include <pv/data/signalbase.hpp> | |
31 | ||
32 | using std::map; | |
33 | using std::string; | |
34 | using std::vector; | |
35 | ||
36 | struct srd_decoder; | |
37 | struct srd_decoder_inst; | |
38 | struct srd_channel; | |
39 | struct srd_session; | |
40 | ||
41 | namespace pv { | |
42 | ||
43 | namespace data { | |
44 | ||
45 | class Logic; | |
46 | class SignalBase; | |
47 | ||
48 | namespace decode { | |
49 | ||
50 | class Decoder; | |
51 | ||
52 | struct 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 | ||
64 | struct DecodeBinaryClassInfo | |
65 | { | |
66 | uint32_t bin_class_id; | |
67 | char* name; | |
68 | char* description; | |
69 | }; | |
70 | ||
71 | ||
72 | class Decoder | |
73 | { | |
74 | public: | |
75 | Decoder(const srd_decoder *const dec); | |
76 | ||
77 | virtual ~Decoder(); | |
78 | ||
79 | const srd_decoder* decoder() const; | |
80 | ||
81 | const char* name() const; | |
82 | ||
83 | bool shown() const; | |
84 | void show(bool show = true); | |
85 | ||
86 | const vector<DecodeChannel*>& channels() const; | |
87 | void set_channels(vector<DecodeChannel*> channels); | |
88 | ||
89 | const map<string, GVariant*>& options() const; | |
90 | ||
91 | void set_option(const char *id, GVariant *value); | |
92 | ||
93 | void apply_all_options(); | |
94 | ||
95 | bool have_required_channels() const; | |
96 | ||
97 | srd_decoder_inst* create_decoder_inst(srd_session *session); | |
98 | void invalidate_decoder_inst(); | |
99 | ||
100 | uint32_t get_binary_class_count() const; | |
101 | const DecodeBinaryClassInfo* get_binary_class(uint32_t id) const; | |
102 | ||
103 | private: | |
104 | const srd_decoder* const srd_decoder_; | |
105 | ||
106 | bool shown_; | |
107 | ||
108 | vector<DecodeChannel*> channels_; | |
109 | vector<DecodeBinaryClassInfo> bin_classes_; | |
110 | map<string, GVariant*> options_; | |
111 | srd_decoder_inst *decoder_inst_; | |
112 | }; | |
113 | ||
114 | } // namespace decode | |
115 | } // namespace data | |
116 | } // namespace pv | |
117 | ||
118 | #endif // PULSEVIEW_PV_DATA_DECODE_DECODER_HPP |