Remove DecodeStack dependency from decode binding wrapper
[pulseview.git] / pv / data / decodesignal.hpp
index 23ab209b73a2faa784806fe5d24b68abd6683e96..cdd061a9769a45484170bd8e69b82a1b131443b7 100644 (file)
 #ifndef PULSEVIEW_PV_DATA_DECODESIGNAL_HPP
 #define PULSEVIEW_PV_DATA_DECODESIGNAL_HPP
 
+#include <unordered_set>
+#include <vector>
+
+#include <QString>
+
 #include <libsigrokdecode/libsigrokdecode.h>
 
 #include <pv/data/signalbase.hpp>
+#include <pv/util.hpp>
 
+using std::list;
+using std::unordered_set;
+using std::vector;
 using std::shared_ptr;
 
 namespace pv {
 namespace data {
 
+namespace decode {
+class Annotation;
+class Decoder;
+class Row;
+}
+
 class DecoderStack;
 class Logic;
+class SignalBase;
 class SignalData;
 
+struct DecodeChannel
+{
+       uint16_t id;  // Also tells which bit within a sample represents this channel
+       const bool is_optional;
+       const pv::data::SignalBase *assigned_signal;
+       const QString name, desc;
+       int initial_pin_state;
+       const shared_ptr<pv::data::decode::Decoder> decoder_;
+       const srd_channel *pdch_;
+};
+
 class DecodeSignal : public SignalBase
 {
        Q_OBJECT
 
 public:
-       DecodeSignal(shared_ptr<pv::data::DecoderStack> decoder_stack);
+       DecodeSignal(shared_ptr<pv::data::DecoderStack> decoder_stack,
+               const unordered_set< shared_ptr<data::SignalBase> > &all_signals);
        virtual ~DecodeSignal();
 
        bool is_decode_signal() const;
-       shared_ptr<pv::data::DecoderStack> decoder_stack() const;
+       shared_ptr<data::DecoderStack> decoder_stack() const;
+       const list< shared_ptr<data::decode::Decoder> >& decoder_stack_list() const;
 
        void stack_decoder(srd_decoder *decoder);
        void remove_decoder(int index);
        bool toggle_decoder_visibility(int index);
 
+       void begin_decode();
+       QString error_message() const;
+
+       const list<data::DecodeChannel> get_channels() const;
+       void auto_assign_signals();
+       void assign_signal(const uint16_t channel_id, const SignalBase *signal);
+
+       void set_initial_pin_state(const uint16_t channel_id, const int init_state);
+
+       double samplerate() const;
+       const pv::util::Timestamp& start_time() const;
+       int64_t sample_count() const;
+       int64_t samples_decoded() const;
+
+       vector<decode::Row> visible_rows() const;
+
+       /**
+        * Extracts sorted annotations between two period into a vector.
+        */
+       void get_annotation_subset(
+               vector<pv::data::decode::Annotation> &dest,
+               const decode::Row &row, uint64_t start_sample,
+               uint64_t end_sample) const;
+
+private:
+       void update_channel_list();
+
 Q_SIGNALS:
        void new_annotations();
+       void channels_updated();
 
 private Q_SLOTS:
        void on_new_annotations();
 
 private:
        shared_ptr<pv::data::DecoderStack> decoder_stack_;
+       const unordered_set< shared_ptr<data::SignalBase> > &all_signals_;
+       list<data::DecodeChannel> channels_;
 };
 
 } // namespace data