]> sigrok.org Git - pulseview.git/blame - pv/data/signalbase.hpp
Don't use std:: in the code directly (where possible).
[pulseview.git] / pv / data / signalbase.hpp
CommitLineData
bf0edd2b
SA
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 * Copyright (C) 2016 Soeren Apel <soeren@apelpie.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
efdec55a 18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
bf0edd2b
SA
19 */
20
21#ifndef PULSEVIEW_PV_DATA_SIGNALBASE_HPP
22#define PULSEVIEW_PV_DATA_SIGNALBASE_HPP
23
24#include <QColor>
25#include <QObject>
6de38b17 26#include <QSettings>
bf0edd2b
SA
27#include <QString>
28
29#include <libsigrokcxx/libsigrokcxx.hpp>
30
6f925ba9 31using std::shared_ptr;
bf0edd2b
SA
32
33namespace sigrok {
34class Channel;
35class ChannelType;
36}
37
38namespace pv {
39namespace data {
40
cbd2a2de 41class Analog;
bb7dd726 42class DecoderStack;
cbd2a2de
SA
43class Logic;
44class SignalData;
45
bf0edd2b
SA
46class SignalBase : public QObject
47{
48 Q_OBJECT
49
50private:
51 static const int ColourBGAlpha;
52
53public:
6f925ba9 54 SignalBase(shared_ptr<sigrok::Channel> channel);
bf0edd2b
SA
55 virtual ~SignalBase() {}
56
57public:
58 /**
59 * Returns the underlying SR channel.
60 */
6f925ba9 61 shared_ptr<sigrok::Channel> channel() const;
bf0edd2b
SA
62
63 /**
64 * Returns enabled status of this channel.
65 */
66 bool enabled() const;
67
68 /**
69 * Sets the enabled status of this channel.
70 * @param value Boolean value to set.
71 */
72 void set_enabled(bool value);
73
74 /**
75 * Gets the type of this channel.
76 */
77 const sigrok::ChannelType *type() const;
78
79 /**
80 * Gets the index number of this channel.
81 */
82 unsigned int index() const;
83
84 /**
85 * Gets the name of this signal.
86 */
87 QString name() const;
88
050b5a6c
SA
89 /**
90 * Gets the internal name of this signal, i.e. how the device calls it.
91 */
92 QString internal_name() const;
93
bf0edd2b
SA
94 /**
95 * Sets the name of the signal.
96 */
97 virtual void set_name(QString name);
98
99 /**
100 * Get the colour of the signal.
101 */
102 QColor colour() const;
103
104 /**
105 * Set the colour of the signal.
106 */
107 void set_colour(QColor colour);
108
109 /**
110 * Get the background colour of the signal.
111 */
112 QColor bgcolour() const;
113
cbd2a2de
SA
114 /**
115 * Sets the internal data object.
116 */
6f925ba9 117 void set_data(shared_ptr<pv::data::SignalData> data);
cbd2a2de
SA
118
119 /**
120 * Get the internal data as analog data object in case of analog type.
121 */
6f925ba9 122 shared_ptr<pv::data::Analog> analog_data() const;
cbd2a2de
SA
123
124 /**
125 * Get the internal data as logic data object in case of logic type.
126 */
6f925ba9 127 shared_ptr<pv::data::Logic> logic_data() const;
cbd2a2de 128
bb7dd726
SA
129#ifdef ENABLE_DECODE
130 bool is_decode_signal() const;
131
6f925ba9 132 shared_ptr<pv::data::DecoderStack> decoder_stack() const;
bb7dd726 133
6f925ba9 134 void set_decoder_stack(shared_ptr<pv::data::DecoderStack> decoder_stack);
bb7dd726 135#endif
cbd2a2de 136
6de38b17
SA
137 void save_settings(QSettings &settings) const;
138
139 void restore_settings(QSettings &settings);
140
bf0edd2b
SA
141Q_SIGNALS:
142 void enabled_changed(const bool &value);
143
144 void name_changed(const QString &name);
145
146 void colour_changed(const QColor &colour);
147
148private:
6f925ba9
UH
149 shared_ptr<sigrok::Channel> channel_;
150 shared_ptr<pv::data::SignalData> data_;
cbd2a2de 151
bb7dd726 152#ifdef ENABLE_DECODE
6f925ba9 153 shared_ptr<pv::data::DecoderStack> decoder_stack_;
bb7dd726
SA
154#endif
155
050b5a6c 156 QString internal_name_, name_;
bf0edd2b
SA
157 QColor colour_, bgcolour_;
158};
159
160} // namespace data
161} // namespace pv
162
163#endif // PULSEVIEW_PV_DATA_SIGNALBASE_HPP