]> sigrok.org Git - pulseview.git/blame - pv/data/decoderstack.h
Added decoder stack item deletion
[pulseview.git] / pv / data / decoderstack.h
CommitLineData
119aff65
JH
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
6e89374a
JH
21#ifndef PULSEVIEW_PV_DATA_DECODERSTACK_H
22#define PULSEVIEW_PV_DATA_DECODERSTACK_H
119aff65
JH
23
24#include "signaldata.h"
25
7491a29f 26#include <list>
708c5523
JH
27
28#include <boost/shared_ptr.hpp>
640d69ce 29#include <boost/thread.hpp>
708c5523 30
e0fc5810 31#include <QObject>
b6b267bb 32#include <QString>
e0fc5810 33
119aff65 34struct srd_decoder;
708c5523 35struct srd_probe;
b213ef09 36struct srd_proto_data;
b6b267bb 37
6e89374a
JH
38namespace DecoderStackTest {
39class TwoDecoderStack;
b6b267bb 40}
119aff65
JH
41
42namespace pv {
708c5523
JH
43
44namespace view {
3045c869 45class LogicSignal;
e0fc5810
JH
46
47namespace decode {
48class Annotation;
49}
50
708c5523
JH
51}
52
119aff65
JH
53namespace data {
54
7491a29f
JH
55namespace decode {
56class Decoder;
57}
58
640d69ce
JH
59class Logic;
60
6e89374a 61class DecoderStack : public QObject, public SignalData
119aff65 62{
e0fc5810
JH
63 Q_OBJECT
64
65private:
66 static const double DecodeMargin;
67 static const double DecodeThreshold;
68 static const int64_t DecodeChunkLength;
69
119aff65 70public:
6e89374a 71 DecoderStack(const srd_decoder *const decoder);
119aff65 72
6e89374a 73 virtual ~DecoderStack();
640d69ce 74
7491a29f
JH
75 const std::list< boost::shared_ptr<decode::Decoder> >& stack() const;
76 void push(boost::shared_ptr<decode::Decoder> decoder);
613d097c 77 void remove(int index);
119aff65 78
e0fc5810
JH
79 const std::vector< boost::shared_ptr<pv::view::decode::Annotation> >
80 annotations() const;
640d69ce 81
b6b267bb
JH
82 QString error_message();
83
119aff65
JH
84 void clear_snapshots();
85
e0fc5810
JH
86 void begin_decode();
87
7491a29f 88private:
640d69ce
JH
89 void decode_proc(boost::shared_ptr<data::Logic> data);
90
e0fc5810
JH
91 static void annotation_callback(srd_proto_data *pdata,
92 void *decoder);
93
9cef9567
JH
94signals:
95 void new_decode_data();
96
119aff65 97private:
fe89c961
JH
98
99 /**
100 * This mutex prevents more than one decode operation occuring
101 * concurrently.
102 * @todo A proper solution should be implemented to allow multiple
103 * decode operations.
104 */
105 static boost::mutex _global_decode_mutex;
106
7491a29f 107 std::list< boost::shared_ptr<decode::Decoder> > _stack;
e332f6d3 108
b6b267bb 109 mutable boost::mutex _mutex;
e0fc5810
JH
110 std::vector< boost::shared_ptr<pv::view::decode::Annotation> >
111 _annotations;
b6b267bb 112 QString _error_message;
e0fc5810 113
640d69ce 114 boost::thread _decode_thread;
b6b267bb 115
6e89374a 116 friend class DecoderStackTest::TwoDecoderStack;
119aff65
JH
117};
118
119} // namespace data
120} // namespace pv
121
6e89374a 122#endif // PULSEVIEW_PV_DATA_DECODERSTACK_H