2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef PULSEVIEW_PV_DATA_DECODERSTACK_H
22 #define PULSEVIEW_PV_DATA_DECODERSTACK_H
24 #include "signaldata.h"
28 #include <boost/shared_ptr.hpp>
29 #include <boost/thread.hpp>
34 #include <pv/data/decode/row.h>
35 #include <pv/data/decode/rowdata.h>
38 struct srd_decoder_annotation_row;
40 struct srd_proto_data;
43 namespace DecoderStackTest {
44 class TwoDecoderStack;
66 class DecoderStack : public QObject, public SignalData
71 static const double DecodeMargin;
72 static const double DecodeThreshold;
73 static const int64_t DecodeChunkLength;
76 DecoderStack(pv::SigSession &_session,
77 const srd_decoder *const decoder);
79 virtual ~DecoderStack();
81 const std::list< boost::shared_ptr<decode::Decoder> >& stack() const;
82 void push(boost::shared_ptr<decode::Decoder> decoder);
83 void remove(int index);
85 int64_t samples_decoded() const;
87 std::vector<decode::Row> get_visible_rows() const;
90 * Extracts sorted annotations between two period into a vector.
92 void get_annotation_subset(
93 std::vector<pv::data::decode::Annotation> &dest,
94 const decode::Row &row, uint64_t start_sample,
95 uint64_t end_sample) const;
97 QString error_message();
101 uint64_t get_max_sample_count() const;
107 const boost::shared_ptr<pv::data::LogicSnapshot> &snapshot,
108 srd_session *const session);
110 void decode_proc(boost::shared_ptr<data::Logic> data);
112 static void annotation_callback(srd_proto_data *pdata,
119 void new_decode_data();
122 pv::SigSession &_session;
125 * This mutex prevents more than one decode operation occuring
127 * @todo A proper solution should be implemented to allow multiple
130 static boost::mutex _global_decode_mutex;
132 std::list< boost::shared_ptr<decode::Decoder> > _stack;
134 mutable boost::mutex _output_mutex;
135 int64_t _samples_decoded;
137 std::map<const decode::Row, decode::RowData> _rows;
139 std::map<std::pair<const srd_decoder*, int>, decode::Row> _class_rows;
141 QString _error_message;
143 boost::thread _decode_thread;
145 friend class DecoderStackTest::TwoDecoderStack;
151 #endif // PULSEVIEW_PV_DATA_DECODERSTACK_H