]>
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 <deque> | |
24 | #include <map> | |
25 | #include <memory> | |
26 | #include <set> | |
27 | #include <vector> | |
28 | ||
29 | #include <glib.h> | |
30 | ||
31 | #include <QObject> | |
32 | ||
33 | #include <pv/data/signalbase.hpp> | |
34 | #include <pv/data/decode/row.hpp> | |
35 | ||
36 | using std::deque; | |
37 | using std::map; | |
38 | using std::string; | |
39 | using std::vector; | |
40 | ||
41 | struct srd_decoder; | |
42 | struct srd_decoder_inst; | |
43 | struct srd_channel; | |
44 | struct srd_session; | |
45 | ||
46 | namespace pv { | |
47 | ||
48 | namespace data { | |
49 | ||
50 | class Logic; | |
51 | class SignalBase; | |
52 | ||
53 | namespace decode { | |
54 | ||
55 | class Decoder; | |
56 | ||
57 | class AnnotationClass: public QObject | |
58 | { | |
59 | Q_OBJECT | |
60 | ||
61 | public: | |
62 | AnnotationClass(size_t _id, char* _name, char* _description, Row* _row); | |
63 | ||
64 | bool visible() const; | |
65 | void set_visible(bool visible); | |
66 | ||
67 | Q_SIGNALS: | |
68 | void visibility_changed(); | |
69 | ||
70 | public: | |
71 | size_t id; | |
72 | char* name; | |
73 | char* description; | |
74 | Row* row; | |
75 | ||
76 | private: | |
77 | bool visible_; | |
78 | }; | |
79 | ||
80 | struct DecodeChannel | |
81 | { | |
82 | uint16_t id; ///< Global numerical ID for the decode channels in the stack | |
83 | uint16_t bit_id; ///< Tells which bit within a sample represents this channel | |
84 | const bool is_optional; | |
85 | const pv::data::SignalBase *assigned_signal; | |
86 | const QString name, desc; | |
87 | int initial_pin_state; | |
88 | const shared_ptr<Decoder> decoder_; | |
89 | const srd_channel *pdch_; | |
90 | }; | |
91 | ||
92 | struct DecodeBinaryClassInfo | |
93 | { | |
94 | uint32_t bin_class_id; | |
95 | char* name; | |
96 | char* description; | |
97 | }; | |
98 | ||
99 | ||
100 | class Decoder : public QObject | |
101 | { | |
102 | Q_OBJECT | |
103 | ||
104 | public: | |
105 | Decoder(const srd_decoder *const dec, uint8_t stack_level); | |
106 | ||
107 | virtual ~Decoder(); | |
108 | ||
109 | const srd_decoder* get_srd_decoder() const; | |
110 | ||
111 | uint8_t get_stack_level() const; | |
112 | ||
113 | const char* name() const; | |
114 | ||
115 | bool visible() const; | |
116 | void set_visible(bool visible); | |
117 | ||
118 | const vector<DecodeChannel*>& channels() const; | |
119 | void set_channels(vector<DecodeChannel*> channels); | |
120 | ||
121 | const map<string, GVariant*>& options() const; | |
122 | void set_option(const char *id, GVariant *value); | |
123 | ||
124 | void apply_all_options(); | |
125 | ||
126 | bool have_required_channels() const; | |
127 | ||
128 | srd_decoder_inst* create_decoder_inst(srd_session *session); | |
129 | void invalidate_decoder_inst(); | |
130 | ||
131 | vector<Row*> get_rows(); | |
132 | Row* get_row_by_id(size_t id); | |
133 | ||
134 | vector<const AnnotationClass*> ann_classes() const; | |
135 | vector<AnnotationClass*> ann_classes(); | |
136 | AnnotationClass* get_ann_class_by_id(size_t id); | |
137 | const AnnotationClass* get_ann_class_by_id(size_t id) const; | |
138 | ||
139 | uint32_t get_binary_class_count() const; | |
140 | const DecodeBinaryClassInfo* get_binary_class(uint32_t id) const; | |
141 | ||
142 | Q_SIGNALS: | |
143 | void annotation_visibility_changed(); | |
144 | ||
145 | private Q_SLOTS: | |
146 | void on_row_visibility_changed(); | |
147 | void on_class_visibility_changed(); | |
148 | ||
149 | private: | |
150 | const srd_decoder* const srd_decoder_; | |
151 | uint8_t stack_level_; | |
152 | ||
153 | bool visible_; | |
154 | ||
155 | vector<DecodeChannel*> channels_; | |
156 | deque<Row> rows_; | |
157 | deque<AnnotationClass> ann_classes_; | |
158 | vector<DecodeBinaryClassInfo> bin_classes_; | |
159 | map<string, GVariant*> options_; | |
160 | srd_decoder_inst *decoder_inst_; | |
161 | }; | |
162 | ||
163 | } // namespace decode | |
164 | } // namespace data | |
165 | } // namespace pv | |
166 | ||
167 | #endif // PULSEVIEW_PV_DATA_DECODE_DECODER_HPP |