]> sigrok.org Git - pulseview.git/blame_incremental - pv/data/decoderstack.h
Added DevInst pointer to Signal
[pulseview.git] / pv / data / decoderstack.h
... / ...
CommitLineData
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2012 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, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef PULSEVIEW_PV_DATA_DECODERSTACK_H
22#define PULSEVIEW_PV_DATA_DECODERSTACK_H
23
24#include "signaldata.h"
25
26#include <list>
27
28#include <boost/shared_ptr.hpp>
29#include <boost/thread.hpp>
30
31#include <QObject>
32#include <QString>
33
34#include <pv/data/decode/row.h>
35#include <pv/data/decode/rowdata.h>
36
37struct srd_decoder;
38struct srd_decoder_annotation_row;
39struct srd_probe;
40struct srd_proto_data;
41
42namespace DecoderStackTest {
43class TwoDecoderStack;
44}
45
46namespace pv {
47
48namespace view {
49class LogicSignal;
50}
51
52namespace data {
53
54namespace decode {
55class Annotation;
56class Decoder;
57}
58
59class Logic;
60
61class DecoderStack : public QObject, public SignalData
62{
63 Q_OBJECT
64
65private:
66 static const double DecodeMargin;
67 static const double DecodeThreshold;
68 static const int64_t DecodeChunkLength;
69
70public:
71 DecoderStack(const srd_decoder *const decoder);
72
73 virtual ~DecoderStack();
74
75 const std::list< boost::shared_ptr<decode::Decoder> >& stack() const;
76 void push(boost::shared_ptr<decode::Decoder> decoder);
77 void remove(int index);
78
79 int64_t samples_decoded() const;
80
81 std::vector<decode::Row> get_visible_rows() const;
82
83 /**
84 * Extracts sorted annotations between two period into a vector.
85 */
86 void get_annotation_subset(
87 std::vector<pv::data::decode::Annotation> &dest,
88 const decode::Row &row, uint64_t start_sample,
89 uint64_t end_sample) const;
90
91 QString error_message();
92
93 void clear();
94
95 uint64_t get_max_sample_count() const;
96
97 void begin_decode();
98
99private:
100 void decode_proc(boost::shared_ptr<data::Logic> data);
101
102 static void annotation_callback(srd_proto_data *pdata,
103 void *decoder);
104
105signals:
106 void new_decode_data();
107
108private:
109
110 /**
111 * This mutex prevents more than one decode operation occuring
112 * concurrently.
113 * @todo A proper solution should be implemented to allow multiple
114 * decode operations.
115 */
116 static boost::mutex _global_decode_mutex;
117
118 std::list< boost::shared_ptr<decode::Decoder> > _stack;
119
120 mutable boost::mutex _mutex;
121 int64_t _samples_decoded;
122
123 std::map<const decode::Row, decode::RowData> _rows;
124
125 std::map<std::pair<const srd_decoder*, int>, decode::Row> _class_rows;
126
127 QString _error_message;
128
129 boost::thread _decode_thread;
130
131 friend class DecoderStackTest::TwoDecoderStack;
132};
133
134} // namespace data
135} // namespace pv
136
137#endif // PULSEVIEW_PV_DATA_DECODERSTACK_H