]> sigrok.org Git - pulseview.git/blame_incremental - pv/data/decoderstack.h
Draw stacked decoder traces below the other PDs (avoids overlap).
[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
34struct srd_decoder;
35struct srd_probe;
36struct srd_proto_data;
37
38namespace DecoderStackTest {
39class TwoDecoderStack;
40}
41
42namespace pv {
43
44namespace view {
45class LogicSignal;
46}
47
48namespace data {
49
50namespace decode {
51class Annotation;
52class Decoder;
53}
54
55class Logic;
56
57class DecoderStack : public QObject, public SignalData
58{
59 Q_OBJECT
60
61private:
62 static const double DecodeMargin;
63 static const double DecodeThreshold;
64 static const int64_t DecodeChunkLength;
65
66public:
67 DecoderStack(const srd_decoder *const decoder);
68
69 virtual ~DecoderStack();
70
71 const std::list< boost::shared_ptr<decode::Decoder> >& stack() const;
72 void push(boost::shared_ptr<decode::Decoder> decoder);
73 void remove(int index);
74
75 int64_t samples_decoded() const;
76
77 const std::vector<pv::data::decode::Annotation> annotations() const;
78
79 QString error_message();
80
81 void clear();
82
83 uint64_t get_max_sample_count() const;
84
85 void begin_decode();
86
87private:
88 void decode_proc(boost::shared_ptr<data::Logic> data);
89
90 static void annotation_callback(srd_proto_data *pdata,
91 void *decoder);
92
93signals:
94 void new_decode_data();
95
96private:
97
98 /**
99 * This mutex prevents more than one decode operation occuring
100 * concurrently.
101 * @todo A proper solution should be implemented to allow multiple
102 * decode operations.
103 */
104 static boost::mutex _global_decode_mutex;
105
106 std::list< boost::shared_ptr<decode::Decoder> > _stack;
107
108 mutable boost::mutex _mutex;
109 int64_t _samples_decoded;
110 std::vector<pv::data::decode::Annotation> _annotations;
111 QString _error_message;
112
113 boost::thread _decode_thread;
114
115 friend class DecoderStackTest::TwoDecoderStack;
116};
117
118} // namespace data
119} // namespace pv
120
121#endif // PULSEVIEW_PV_DATA_DECODERSTACK_H