]>
Commit | Line | Data |
---|---|---|
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 | 32 | using std::map; |
6f925ba9 | 33 | using std::string; |
27a3f09b | 34 | using std::vector; |
6f925ba9 | 35 | |
7491a29f JH |
36 | struct srd_decoder; |
37 | struct srd_decoder_inst; | |
8bd26d8b | 38 | struct srd_channel; |
7491a29f JH |
39 | struct srd_session; |
40 | ||
41 | namespace pv { | |
42 | ||
7491a29f | 43 | namespace data { |
ddee4cf8 JH |
44 | |
45 | class Logic; | |
04394ded | 46 | class SignalBase; |
ddee4cf8 | 47 | |
7491a29f JH |
48 | namespace decode { |
49 | ||
a82325d1 SA |
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 | ||
7491a29f JH |
65 | class Decoder |
66 | { | |
67 | public: | |
520362f8 | 68 | Decoder(const srd_decoder *const dec); |
7491a29f JH |
69 | |
70 | virtual ~Decoder(); | |
71 | ||
72 | const srd_decoder* decoder() const; | |
73 | ||
dd048a7e JH |
74 | bool shown() const; |
75 | void show(bool show = true); | |
76 | ||
a82325d1 SA |
77 | const vector<DecodeChannel*>& channels() const; |
78 | void set_channels(vector<DecodeChannel*> channels); | |
7491a29f | 79 | |
6f925ba9 | 80 | const map<string, GVariant*>& options() const; |
7491a29f JH |
81 | |
82 | void set_option(const char *id, GVariant *value); | |
83 | ||
72486b78 SA |
84 | void apply_all_options(); |
85 | ||
6ac6242b | 86 | bool have_required_channels() const; |
a2d4b551 | 87 | |
8ce0e732 SA |
88 | srd_decoder_inst* create_decoder_inst(srd_session *session); |
89 | void invalidate_decoder_inst(); | |
7491a29f | 90 | |
a82325d1 SA |
91 | |
92 | ||
7491a29f | 93 | private: |
8dbbc7f0 | 94 | const srd_decoder *const decoder_; |
dd048a7e | 95 | |
8dbbc7f0 | 96 | bool shown_; |
dd048a7e | 97 | |
a82325d1 | 98 | vector<DecodeChannel*> channels_; |
6f925ba9 | 99 | map<string, GVariant*> options_; |
8ce0e732 | 100 | srd_decoder_inst *decoder_inst_; |
7491a29f JH |
101 | }; |
102 | ||
103 | } // namespace decode | |
104 | } // namespace data | |
105 | } // namespace pv | |
106 | ||
7a01bd36 | 107 | #endif // PULSEVIEW_PV_DATA_DECODE_DECODER_HPP |