#include "pv/mainwindow.hpp"
#include "pv/session.hpp"
#include "pv/util.hpp"
+#include "pv/data/segment.hpp"
#ifdef ANDROID
#include <libsigrokandroidutils/libsigrokandroidutils.h>
for (int i = 0; i < argc; i++)
open_files.emplace_back(argv[i]);
- qRegisterMetaType<pv::util::Timestamp>("util::Timestamp");
qRegisterMetaType<uint64_t>("uint64_t");
+ qRegisterMetaType<pv::util::Timestamp>("util::Timestamp");
+ qRegisterMetaType<pv::data::Segment>("data::Segment");
// Prepare the global settings since logging needs them early on
pv::GlobalSettings settings;
return l;
}
-void Analog::notify_samples_added(QObject* segment, uint64_t start_sample,
+void Analog::notify_samples_added(shared_ptr<Segment> segment, uint64_t start_sample,
uint64_t end_sample)
{
samples_added(segment, start_sample, end_sample);
uint64_t max_sample_count() const;
- void notify_samples_added(QObject* segment, uint64_t start_sample,
+ void notify_samples_added(shared_ptr<Segment> segment, uint64_t start_sample,
uint64_t end_sample);
void notify_min_max_changed(float min, float max);
Q_SIGNALS:
void samples_cleared();
- void samples_added(QObject* segment, uint64_t start_sample,
+ void samples_added(shared_ptr<Segment> segment, uint64_t start_sample,
uint64_t end_sample);
void min_max_changed(float min, float max);
append_payload_to_envelope_levels();
if (sample_count > 1)
- owner_.notify_samples_added(this, prev_sample_count + 1,
- prev_sample_count + 1 + sample_count);
+ owner_.notify_samples_added(shared_ptr<Segment>(shared_from_this()),
+ prev_sample_count + 1, prev_sample_count + 1 + sample_count);
else
- owner_.notify_samples_added(this, prev_sample_count + 1,
- prev_sample_count + 1);
+ owner_.notify_samples_added(shared_ptr<Segment>(shared_from_this()),
+ prev_sample_count + 1, prev_sample_count + 1);
}
void AnalogSegment::get_samples(int64_t start_sample, int64_t end_sample,
#include <QObject>
+using std::enable_shared_from_this;
using std::pair;
namespace AnalogSegmentTest {
class Analog;
-class AnalogSegment : public Segment
+class AnalogSegment : public Segment, public enable_shared_from_this<Segment>
{
Q_OBJECT
return segments_;
}
+deque< shared_ptr<LogicSegment> >& Logic::logic_segments()
+{
+ return segments_;
+}
+
vector< shared_ptr<Segment> > Logic::segments() const
{
return vector< shared_ptr<Segment> >(segments_.begin(), segments_.end());
return l;
}
-void Logic::notify_samples_added(QObject* segment, uint64_t start_sample,
+void Logic::notify_samples_added(shared_ptr<Segment> segment, uint64_t start_sample,
uint64_t end_sample)
{
samples_added(segment, start_sample, end_sample);
void push_segment(shared_ptr<LogicSegment> &segment);
const deque< shared_ptr<LogicSegment> >& logic_segments() const;
+ deque< shared_ptr<LogicSegment> >& logic_segments();
vector< shared_ptr<Segment> > segments() const;
uint64_t max_sample_count() const;
- void notify_samples_added(QObject* segment, uint64_t start_sample,
+ void notify_samples_added(shared_ptr<Segment> segment, uint64_t start_sample,
uint64_t end_sample);
Q_SIGNALS:
void samples_cleared();
- void samples_added(QObject* segment, uint64_t start_sample,
+ void samples_added(shared_ptr<Segment> segment, uint64_t start_sample,
uint64_t end_sample);
private:
append_payload_to_mipmap();
if (sample_count > 1)
- owner_.notify_samples_added(this, prev_sample_count + 1,
- prev_sample_count + 1 + sample_count);
+ owner_.notify_samples_added(shared_ptr<Segment>(shared_from_this()),
+ prev_sample_count + 1, prev_sample_count + 1 + sample_count);
else
- owner_.notify_samples_added(this, prev_sample_count + 1,
- prev_sample_count + 1);
+ owner_.notify_samples_added(shared_ptr<Segment>(shared_from_this()),
+ prev_sample_count + 1, prev_sample_count + 1);
}
void LogicSegment::get_samples(int64_t start_sample,
#include "segment.hpp"
-#include <utility>
#include <vector>
#include <QObject>
+using std::enable_shared_from_this;
using std::pair;
using std::shared_ptr;
using std::vector;
class Logic;
-class LogicSegment : public Segment
+class LogicSegment : public Segment, public enable_shared_from_this<Segment>
{
Q_OBJECT
} // namespace data
} // namespace pv
+Q_DECLARE_METATYPE(pv::data::Segment);
+
#endif // PULSEVIEW_PV_DATA_SEGMENT_HPP
if (data_) {
disconnect(data.get(), SIGNAL(samples_cleared()),
this, SLOT(on_samples_cleared()));
- disconnect(data.get(), SIGNAL(samples_added(QObject*, uint64_t, uint64_t)),
- this, SLOT(on_samples_added(QObject*, uint64_t, uint64_t)));
+ disconnect(data.get(), SIGNAL(samples_added(shared_ptr<Segment>, uint64_t, uint64_t)),
+ this, SLOT(on_samples_added(shared_ptr<Segment>, uint64_t, uint64_t)));
if (channel_type_ == AnalogChannel) {
shared_ptr<Analog> analog = analog_data();
if (data_) {
connect(data.get(), SIGNAL(samples_cleared()),
this, SLOT(on_samples_cleared()));
- connect(data.get(), SIGNAL(samples_added(QObject*, uint64_t, uint64_t)),
- this, SLOT(on_samples_added(QObject*, uint64_t, uint64_t)));
+ connect(data.get(), SIGNAL(samples_added(shared_ptr<Segment>, uint64_t, uint64_t)),
+ this, SLOT(on_samples_added(shared_ptr<Segment>, uint64_t, uint64_t)));
if (channel_type_ == AnalogChannel) {
shared_ptr<Analog> analog = analog_data();
samples_cleared();
}
-void SignalBase::on_samples_added(QObject* segment, uint64_t start_sample,
+void SignalBase::on_samples_added(shared_ptr<Segment> segment, uint64_t start_sample,
uint64_t end_sample)
{
if (conversion_type_ != NoConversion) {
}
}
- data::Segment* s = qobject_cast<data::Segment*>(segment);
- samples_added(s->segment_id(), start_sample, end_sample);
+ samples_added(segment->segment_id(), start_sample, end_sample);
}
void SignalBase::on_min_max_changed(float min, float max)
class DecoderStack;
class Logic;
class LogicSegment;
+class Segment;
class SignalData;
class SignalBase : public QObject
private Q_SLOTS:
void on_samples_cleared();
- void on_samples_added(QObject* segment, uint64_t start_sample,
+ void on_samples_added(shared_ptr<Segment> segment, uint64_t start_sample,
uint64_t end_sample);
void on_min_max_changed(float min, float max);