Rather than as pointers to heap allocated objects.
return _samples_decoded;
}
-const vector< shared_ptr<view::decode::Annotation> >
- DecoderStack::annotations() const
+const vector<view::decode::Annotation> DecoderStack::annotations() const
{
lock_guard<mutex> lock(_mutex);
return _annotations;
{
if (_annotations.empty())
return 0;
- return _annotations.back()->end_sample();
+ return _annotations.back().end_sample();
}
void DecoderStack::decode_proc(shared_ptr<data::Logic> data)
DecoderStack *const d = (DecoderStack*)decoder;
- shared_ptr<Annotation> a(new Annotation(pdata));
lock_guard<mutex> lock(d->_mutex);
- d->_annotations.push_back(a);
+ d->_annotations.push_back(Annotation(pdata));
d->new_decode_data();
}
int64_t samples_decoded() const;
- const std::vector< boost::shared_ptr<pv::view::decode::Annotation> >
- annotations() const;
+ const std::vector<pv::view::decode::Annotation> annotations() const;
QString error_message();
mutable boost::mutex _mutex;
int64_t _samples_decoded;
- std::vector< boost::shared_ptr<pv::view::decode::Annotation> >
- _annotations;
+ std::vector<pv::view::decode::Annotation> _annotations;
QString _error_message;
boost::thread _decode_thread;
void Annotation::paint(QPainter &p, QColor text_color, int h,
int left, int right, double samples_per_pixel, double pixels_offset,
- int y)
+ int y) const
{
const double start = _start_sample / samples_per_pixel -
pixels_offset;
}
void Annotation::draw_instant(QPainter &p, QColor fill, QColor outline,
- QColor text_color, int h, double x, int y)
+ QColor text_color, int h, double x, int y) const
{
const QString text = _annotations.empty() ?
QString() : _annotations.back();
}
void Annotation::draw_range(QPainter &p, QColor fill, QColor outline,
- QColor text_color, int h, double start, double end, int y)
+ QColor text_color, int h, double start, double end, int y) const
{
const double top = y + .5 - h / 2;
const double bottom = y + .5 + h / 2;
QString best_annotation;
int best_width = 0;
- BOOST_FOREACH(QString &a, _annotations) {
+ BOOST_FOREACH(const QString &a, _annotations) {
const int w = p.boundingRect(QRectF(), 0, a).width();
if (w <= rect.width() && w > best_width)
best_annotation = a, best_width = w;
void paint(QPainter &p, QColor text_colour, int text_height, int left,
int right, double samples_per_pixel, double pixels_offset,
- int y);
+ int y) const;
private:
void draw_instant(QPainter &p, QColor fill, QColor outline,
- QColor text_color, int h, double x, int y);
+ QColor text_color, int h, double x, int y) const;
void draw_range(QPainter &p, QColor fill, QColor outline,
QColor text_color, int h, double start,
- double end, int y);
+ double end, int y) const;
private:
uint64_t _start_sample;
const int y = get_y();
assert(_decoder_stack);
- vector< shared_ptr<Annotation> > annotations(_decoder_stack->annotations());
- BOOST_FOREACH(shared_ptr<Annotation> a, annotations) {
- assert(a);
- a->paint(p, get_text_colour(), h, left, right,
+ vector<Annotation> annotations(_decoder_stack->annotations());
+ BOOST_FOREACH(const Annotation &a, annotations)
+ a.paint(p, get_text_colour(), h, left, right,
samples_per_pixel, pixels_offset, y);
- }
draw_unresolved_period(p, h, left, right,
samples_per_pixel, pixels_offset);