if (open_files.empty())
w.add_default_session();
else
- for (string open_file : open_files)
+ for (string& open_file : open_files)
w.add_session_with_file(open_file, open_file_format);
#ifdef ENABLE_SIGNALS
#endif
// Device drivers
- for (auto entry : context->drivers())
+ for (auto& entry : context->drivers())
driver_list_.emplace_back(QString::fromUtf8(entry.first.c_str()),
QString::fromUtf8(entry.second->long_name().c_str()));
// Input formats
- for (auto entry : context->input_formats())
+ for (auto& entry : context->input_formats())
input_format_list_.emplace_back(QString::fromUtf8(entry.first.c_str()),
QString::fromUtf8(entry.second->description().c_str()));
// Output formats
- for (auto entry : context->output_formats())
+ for (auto& entry : context->output_formats())
output_format_list_.emplace_back(QString::fromUtf8(entry.first.c_str()),
QString::fromUtf8(entry.second->description().c_str()));
cout << PV_TITLE << " " << PV_VERSION_STRING << endl;
cout << endl << "Libraries and features:" << endl;
- for (pair<QString, QString> &entry : version_info_)
+ for (pair<QString, QString>& entry : version_info_)
cout << " " << entry.first.toStdString() << " " << entry.second.toStdString() << endl;
cout << endl << "Firmware search paths:" << endl;
- for (QString &entry : fw_path_list_)
+ for (QString& entry : fw_path_list_)
cout << " " << entry.toStdString() << endl;
cout << endl << "Protocol decoder search paths:" << endl;
- for (QString &entry : pd_path_list_)
+ for (QString& entry : pd_path_list_)
cout << " " << entry.toStdString() << endl;
cout << endl << "Supported hardware drivers:" << endl;
- for (pair<QString, QString> &entry : driver_list_)
+ for (pair<QString, QString>& entry : driver_list_)
cout << " " << entry.first.leftJustified(21, ' ').toStdString() <<
entry.second.toStdString() << endl;
cout << endl << "Supported input formats:" << endl;
- for (pair<QString, QString> &entry : input_format_list_)
+ for (pair<QString, QString>& entry : input_format_list_)
cout << " " << entry.first.leftJustified(21, ' ').toStdString() <<
entry.second.toStdString() << endl;
cout << endl << "Supported output formats:" << endl;
- for (pair<QString, QString> &entry : output_format_list_)
+ for (pair<QString, QString>& entry : output_format_list_)
cout << " " << entry.first.leftJustified(21, ' ').toStdString() <<
entry.second.toStdString() << endl;
#ifdef ENABLE_DECODE
cout << endl << "Supported protocol decoders:" << endl;
- for (pair<QString, QString> &entry : pd_list_)
+ for (pair<QString, QString>& entry : pd_list_)
cout << " " << entry.first.leftJustified(21, ' ').toStdString() <<
entry.second.toStdString() << endl;
#endif
InputOutput::InputOutput(
const map<string, shared_ptr<Option>> &options)
{
- for (pair<string, shared_ptr<Option>> o : options) {
+ for (const pair<string, shared_ptr<Option>>& o : options) {
const shared_ptr<Option> &opt = o.second;
assert(opt);
uint64_t Analog::max_sample_count() const
{
uint64_t l = 0;
- for (const shared_ptr<AnalogSegment> s : segments_) {
+ for (const shared_ptr<AnalogSegment>& s : segments_) {
assert(s);
l = max(l, s->get_sample_count());
}
// Make sure that all assigned channels still provide logic data
// (can happen when a converted signal was assigned but the
// conversion removed in the meanwhile)
- for (data::DecodeChannel &ch : channels_)
+ for (data::DecodeChannel& ch : channels_)
if (ch.assigned_signal && !(ch.assigned_signal->logic_data() != nullptr))
ch.assigned_signal = nullptr;
// Check that all decoders have the required channels
- for (const shared_ptr<decode::Decoder> &dec : stack_)
+ for (const shared_ptr<decode::Decoder>& dec : stack_)
if (!dec->have_required_channels()) {
set_error_message(tr("One or more required channels "
"have not been specified"));
// Map out all the annotation classes
int row_index = 0;
- for (const shared_ptr<decode::Decoder> &dec : stack_) {
+ for (const shared_ptr<decode::Decoder>& dec : stack_) {
assert(dec);
const srd_decoder *const decc = dec->decoder();
assert(dec->decoder());
bool new_assignment = false;
// Try to auto-select channels that don't have signals assigned yet
- for (data::DecodeChannel &ch : channels_) {
+ for (data::DecodeChannel& ch : channels_) {
// If a decoder is given, auto-assign only its channels
if (dec && (ch.decoder_ != dec))
continue;
ch_name = ch_name.replace(QRegExp("[-_.]"), " ");
shared_ptr<data::SignalBase> match;
- for (shared_ptr<data::SignalBase> s : session_.signalbases()) {
+ for (const shared_ptr<data::SignalBase>& s : session_.signalbases()) {
if (!s->enabled())
continue;
void DecodeSignal::assign_signal(const uint16_t channel_id, const SignalBase *signal)
{
- for (data::DecodeChannel &ch : channels_)
+ for (data::DecodeChannel& ch : channels_)
if (ch.id == channel_id) {
ch.assigned_signal = signal;
logic_mux_data_invalid_ = true;
void DecodeSignal::set_initial_pin_state(const uint16_t channel_id, const int init_state)
{
- for (data::DecodeChannel &ch : channels_)
+ for (data::DecodeChannel& ch : channels_)
if (ch.id == channel_id)
ch.initial_pin_state = init_state;
int64_t count = std::numeric_limits<int64_t>::max();
bool no_signals_assigned = true;
- for (const data::DecodeChannel &ch : channels_)
+ for (const data::DecodeChannel& ch : channels_)
if (ch.assigned_signal) {
no_signals_assigned = false;
vector<Row> rows;
- for (const shared_ptr<decode::Decoder> &dec : stack_) {
+ for (const shared_ptr<decode::Decoder>& dec : stack_) {
assert(dec);
if (!dec->shown())
continue;
// Save decoder stack
int decoder_idx = 0;
- for (shared_ptr<decode::Decoder> decoder : stack_) {
+ for (const shared_ptr<decode::Decoder>& decoder : stack_) {
settings.beginGroup("decoder" + QString::number(decoder_idx++));
settings.setValue("id", decoder->decoder()->id);
// Note: decode::Decoder::options() returns only the options
// that differ from the default. See binding::Decoder::getter()
int i = 0;
- for (auto option : options) {
+ for (auto& option : options) {
settings.beginGroup("option" + QString::number(i));
settings.setValue("name", QString::fromStdString(option.first));
GlobalSettings::store_gvariant(settings, option.second);
QString assigned_signal_name = settings.value("assigned_signal_name").toString();
- for (shared_ptr<data::SignalBase> signal : signalbases)
+ for (const shared_ptr<data::SignalBase>& signal : signalbases)
if (signal->name() == assigned_signal_name)
channel->assigned_signal = signal.get();
uint64_t count = std::numeric_limits<uint64_t>::max();
bool no_signals_assigned = true;
- for (const data::DecodeChannel &ch : channels_)
+ for (const data::DecodeChannel& ch : channels_)
if (ch.assigned_signal) {
no_signals_assigned = false;
{
double samplerate = 0;
- for (const data::DecodeChannel &ch : channels_)
+ for (const data::DecodeChannel& ch : channels_)
if (ch.assigned_signal) {
const shared_ptr<Logic> logic_data = ch.assigned_signal->logic_data();
if (!logic_data || logic_data->logic_segments().empty())
uint16_t id = 0;
// Copy existing entries, create new as needed
- for (shared_ptr<Decoder> decoder : stack_) {
+ for (shared_ptr<Decoder>& decoder : stack_) {
const srd_decoder* srd_d = decoder->decoder();
const GSList *l;
bool ch_added = false;
// Copy but update ID if this channel was in the list before
- for (data::DecodeChannel &ch : prev_channels)
+ for (data::DecodeChannel& ch : prev_channels)
if (ch.pdch_ == pdch) {
ch.id = id++;
channels_.push_back(ch);
bool ch_added = false;
// Copy but update ID if this channel was in the list before
- for (data::DecodeChannel &ch : prev_channels)
+ for (data::DecodeChannel& ch : prev_channels)
if (ch.pdch_ == pdch) {
ch.id = id++;
channels_.push_back(ch);
} else {
// Same number but assignment may still differ, so compare all channels
for (size_t i = 0; i < channels_.size(); i++) {
- const data::DecodeChannel &p_ch = prev_channels[i];
- const data::DecodeChannel &ch = channels_[i];
+ const data::DecodeChannel& p_ch = prev_channels[i];
+ const data::DecodeChannel& ch = channels_[i];
if ((p_ch.pdch_ != ch.pdch_) ||
(p_ch.assigned_signal != ch.assigned_signal)) {
for (shared_ptr<decode::Decoder> dec : stack_) {
vector<data::DecodeChannel*> channel_list;
- for (data::DecodeChannel &ch : channels_)
+ for (data::DecodeChannel& ch : channels_)
if (ch.decoder_ == dec)
channel_list.push_back(&ch);
// Channel bit IDs must be in sync with the channel's apperance in channels_
int id = 0;
- for (data::DecodeChannel &ch : channels_)
+ for (data::DecodeChannel& ch : channels_)
if (ch.assigned_signal)
ch.bit_id = id++;
}
vector<uint8_t> signal_in_bytepos;
vector<uint8_t> signal_in_bitpos;
- for (data::DecodeChannel &ch : channels_)
+ for (data::DecodeChannel& ch : channels_)
if (ch.assigned_signal) {
const shared_ptr<Logic> logic_data = ch.assigned_signal->logic_data();
if (samplerate)
srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE,
g_variant_new_uint64(samplerate));
- for (const shared_ptr<decode::Decoder> &dec : stack_)
+ for (const shared_ptr<decode::Decoder>& dec : stack_)
dec->apply_all_options();
srd_session_start(srd_session_);
// Create the decoders
srd_decoder_inst *prev_di = nullptr;
- for (const shared_ptr<decode::Decoder> &dec : stack_) {
+ for (const shared_ptr<decode::Decoder>& dec : stack_) {
srd_decoder_inst *const di = dec->create_decoder_inst(srd_session_);
if (!di) {
if (samplerate)
srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE,
g_variant_new_uint64(samplerate));
- for (const shared_ptr<decode::Decoder> &dec : stack_)
+ for (const shared_ptr<decode::Decoder>& dec : stack_)
dec->apply_all_options();
}
}
srd_session_ = nullptr;
// Mark the decoder instances as non-existant since they were deleted
- for (const shared_ptr<decode::Decoder> &dec : stack_)
+ for (const shared_ptr<decode::Decoder>& dec : stack_)
dec->invalidate_decoder_inst();
}
}
disconnect(this, SLOT(on_data_received()));
// Connect the currently used signals to our slot
- for (data::DecodeChannel &ch : channels_) {
+ for (data::DecodeChannel& ch : channels_) {
if (!ch.assigned_signal)
continue;
segments_.emplace_back(DecodeSegment());
// Add annotation classes
- for (const shared_ptr<decode::Decoder> &dec : stack_) {
+ for (const shared_ptr<decode::Decoder>& dec : stack_) {
assert(dec);
const srd_decoder *const decc = dec->decoder();
assert(dec->decoder());
uint64_t Logic::max_sample_count() const
{
uint64_t l = 0;
- for (shared_ptr<LogicSegment> s : segments_) {
+ for (const shared_ptr<LogicSegment>& s : segments_) {
assert(s);
l = max(l, s->get_sample_count());
}
settings.setValue("conv_options", (int)(conversion_options_.size()));
int i = 0;
- for (auto kvp : conversion_options_) {
+ for (auto& kvp : conversion_options_) {
settings.setValue(QString("conv_option%1_key").arg(i), kvp.first);
settings.setValue(QString("conv_option%1_value").arg(i), kvp.second);
i++;
* Scan for devices. No specific options apply here, this is
* best effort auto detection.
*/
- for (auto entry : context->drivers()) {
+ for (auto& entry : context->drivers()) {
if (!do_scan)
break;
{
map<const ConfigKey *, Glib::VariantBase> result;
- for (auto entry : user_spec) {
+ for (auto& entry : user_spec) {
/*
* Split key=value specs. Accept entries without separator
* (for simplified boolean specifications).
auto devices = driver->scan(drvopts);
// Add the scanned devices to the main list, set display names and sort.
- for (shared_ptr<sigrok::HardwareDevice> device : devices) {
+ for (shared_ptr<sigrok::HardwareDevice>& device : devices) {
const shared_ptr<devices::HardwareDevice> d(
new devices::HardwareDevice(context_, device));
driver_devices.push_back(d);
settings.setValue("options", (int)options_.size());
int i = 0;
- for (pair<string, Glib::VariantBase> option : options_) {
+ for (const pair<string, Glib::VariantBase>& option : options_) {
settings.beginGroup("option" + QString::number(i));
settings.setValue("name", QString::fromStdString(option.first));
GlobalSettings::store_variantbase(settings, option.second);
void Connect::populate_drivers()
{
- for (auto entry : device_manager_.context()->drivers()) {
+ for (auto& entry : device_manager_.context()->drivers()) {
auto name = entry.first;
auto driver = entry.second;
/**
void Connect::populate_serials(shared_ptr<Driver> driver)
{
serial_devices_.clear();
- for (auto serial : device_manager_.context()->serials(driver))
+ for (auto& serial : device_manager_.context()->serials(driver))
serial_devices_.addItem(QString("%1 (%2)").arg(
serial.first.c_str(), serial.second.c_str()),
QString::fromStdString(serial.first));
const list< shared_ptr<HardwareDevice> > devices =
device_manager_.driver_scan(driver, drvopts);
- for (shared_ptr<HardwareDevice> device : devices) {
+ for (const shared_ptr<HardwareDevice>& device : devices) {
assert(device);
QString text = QString::fromStdString(device->display_name(device_manager_));
general_group->setLayout(general_layout);
QComboBox *theme_cb = new QComboBox();
- for (pair<QString, QString> entry : Themes)
+ for (const pair<QString, QString>& entry : Themes)
theme_cb->addItem(entry.first, entry.second);
theme_cb->setCurrentIndex(
{
tracking_ = false;
- for (auto entry : tracked_changes_)
+ for (auto& entry : tracked_changes_)
setValue(entry.first, entry.second);
tracked_changes_.clear();
}
// Get the view contained in the dock widget
- for (auto entry : view_docks_)
+ for (auto& entry : view_docks_)
if (entry.first == dock)
return entry.second;
shared_ptr<views::ViewBase> v;
QMainWindow *main_window = nullptr;
- for (auto entry : session_windows_)
+ for (auto& entry : session_windows_)
if (entry.first.get() == &session)
main_window = entry.second;
continue;
// Find the dock the view is contained in and remove it
- for (auto entry : view_docks_)
+ for (auto& entry : view_docks_)
if (entry.second == view) {
// Remove the view from the session
session->deregister_view(view);
session->stop_capture();
QApplication::processEvents();
- for (shared_ptr<views::ViewBase> view : session->views())
+ for (const shared_ptr<views::ViewBase>& view : session->views())
remove_view(view);
QMainWindow *window = session_windows_.at(session);
// one of the auto detected devices that are not the demo device.
// Pick demo in the absence of "genuine" hardware devices.
shared_ptr<devices::HardwareDevice> user_device, other_device, demo_device;
- for (shared_ptr<devices::HardwareDevice> dev : device_manager_.devices()) {
+ for (const shared_ptr<devices::HardwareDevice>& dev : device_manager_.devices()) {
if (dev == device_manager_.user_spec_device()) {
user_device = dev;
} else if (dev->hardware_device()->driver()->name() == "demo") {
QSettings settings;
int id = 0;
- for (shared_ptr<Session> session : sessions_) {
+ for (shared_ptr<Session>& session : sessions_) {
// Ignore sessions using the demo device or no device at all
if (session->device()) {
shared_ptr<devices::HardwareDevice> device =
shared_ptr<Session> MainWindow::get_tab_session(int index) const
{
// Find the session that belongs to the tab's main window
- for (auto entry : session_windows_)
+ for (auto& entry : session_windows_)
if (entry.second == session_selector_.widget(index))
return entry.first;
{
bool data_saved = true;
- for (auto entry : session_windows_)
+ for (auto& entry : session_windows_)
if (!entry.first->data_saved())
data_saved = false;
Session *session)
{
// We get a pointer and need a reference
- for (shared_ptr<Session> s : sessions_)
+ for (shared_ptr<Session>& s : sessions_)
if (s.get() == session)
add_view(title, type, *s);
}
Session *session = qobject_cast<Session*>(QObject::sender());
assert(session);
- for (shared_ptr<views::ViewBase> view : session->views()) {
+ for (const shared_ptr<views::ViewBase>& view : session->views()) {
// Get the dock that contains the view
- for (auto entry : view_docks_)
+ for (auto& entry : view_docks_)
if (entry.second == view) {
entry.first->setObjectName(session->name());
entry.first->setWindowTitle(session->name());
}
// Update the tab widget by finding the main window and the tab from that
- for (auto entry : session_windows_)
+ for (auto& entry : session_windows_)
if (entry.first.get() == session) {
QMainWindow *window = entry.second;
const int index = session_selector_.indexOf(window);
void MainWindow::on_new_view(Session *session)
{
// We get a pointer and need a reference
- for (shared_ptr<Session> s : sessions_)
+ for (shared_ptr<Session>& s : sessions_)
if (s.get() == session)
add_view(session->name(), views::ViewTypeTrace, *s);
}
// Get the view contained in the dock widget
shared_ptr<views::ViewBase> view;
- for (auto entry : view_docks_)
+ for (auto& entry : view_docks_)
if (entry.first == dock)
view = entry.second;
{
bool state = new_value.toBool();
- for (auto entry : view_docks_) {
+ for (auto& entry : view_docks_) {
shared_ptr<views::ViewBase> viewbase = entry.second;
// Only trace views have this setting
{
bool state = new_value.toBool();
- for (auto entry : view_docks_) {
+ for (auto& entry : view_docks_) {
shared_ptr<views::ViewBase> viewbase = entry.second;
// Only trace views have this setting
{
bool state = new_value.toBool();
- for (auto entry : view_docks_) {
+ for (auto& entry : view_docks_) {
shared_ptr<views::ViewBase> viewbase = entry.second;
// Only trace views have this setting
map<shared_ptr<Channel>, shared_ptr<SignalBase> > signal_map;
unordered_set< shared_ptr<SignalBase> > sigs;
- for (const shared_ptr<data::SignalBase> b : session_.signalbases())
+ for (const shared_ptr<data::SignalBase>& b : session_.signalbases())
sigs.insert(b);
for (const shared_ptr<SignalBase> &sig : sigs)
signal_map[sig->channel()] = sig;
// Populate channel groups
- for (auto entry : device->channel_groups()) {
+ for (auto& entry : device->channel_groups()) {
const shared_ptr<ChannelGroup> group = entry.second;
// Make a set of signals and remove these signals from the signal map
vector< shared_ptr<SignalBase> > group_sigs;
- for (auto channel : group->channels()) {
+ for (auto& channel : group->channels()) {
const auto iter = signal_map.find(channel);
if (iter == signal_map.end())
// Make a vector of the remaining channels
vector< shared_ptr<SignalBase> > global_analog_sigs, global_logic_sigs;
- for (auto channel : device->channels()) {
+ for (auto& channel : device->channels()) {
const map<shared_ptr<Channel>, shared_ptr<SignalBase> >::
const_iterator iter = signal_map.find(channel);
{
updating_channels_ = true;
- for (auto entry : check_box_signal_map_) {
+ for (auto& entry : check_box_signal_map_) {
QCheckBox *cb = entry.first;
const shared_ptr<SignalBase> sig = entry.second;
assert(sig);
{
updating_channels_ = true;
- for (auto entry : check_box_signal_map_) {
+ for (auto& entry : check_box_signal_map_) {
QCheckBox *cb = entry.first;
const shared_ptr<SignalBase> sig = entry.second;
assert(sig);
{
updating_channels_ = true;
- for (auto entry : check_box_signal_map_) {
+ for (auto& entry : check_box_signal_map_) {
QCheckBox *cb = entry.first;
const shared_ptr<SignalBase> sig = entry.second;
assert(sig);
assert(device);
// Update group labels
- for (auto entry : device->channel_groups()) {
+ for (auto& entry : device->channel_groups()) {
const shared_ptr<ChannelGroup> group = entry.second;
try {
updating_channels_ = true;
- for (auto entry : check_box_signal_map_) {
+ for (auto& entry : check_box_signal_map_) {
QCheckBox *cb = entry.first;
const shared_ptr<SignalBase> sig = entry.second;
assert(sig);
dev_info = device_manager_.get_device_info(device_);
- for (string key : key_list) {
+ for (string& key : key_list) {
if (dev_info.count(key))
settings.setValue(QString::fromUtf8(key.c_str()),
QString::fromUtf8(dev_info.at(key).c_str()));
}
// Save channels and decoders
- for (shared_ptr<data::SignalBase> base : signalbases_) {
+ for (const shared_ptr<data::SignalBase>& base : signalbases_) {
#ifdef ENABLE_DECODE
if (base->is_decode_signal()) {
settings.beginGroup("decode_signal" + QString::number(decode_signals++));
main_view_->save_settings(settings);
settings.endGroup();
- for (shared_ptr<views::ViewBase> view : views_) {
+ for (const shared_ptr<views::ViewBase>& view : views_) {
if (view != main_view_) {
settings.beginGroup("view" + QString::number(views++));
view->save_settings(settings);
#endif
view->reset_view_state();
}
- for (const shared_ptr<data::SignalData> d : all_signal_data_)
+ for (const shared_ptr<data::SignalData>& d : all_signal_data_)
d->clear();
all_signal_data_.clear();
signalbases_.clear();
cur_logic_segment_.reset();
- for (auto entry : cur_analog_segments_) {
+ for (auto& entry : cur_analog_segments_) {
shared_ptr<sigrok::Channel>(entry.first).reset();
shared_ptr<data::AnalogSegment>(entry.second).reset();
}
{
map<string, Glib::VariantBase> result;
- for (auto entry : user_spec) {
+ for (auto& entry : user_spec) {
/*
* Split key=value specs. Accept entries without separator
* (for simplified boolean specifications).
}
// Clear signal data
- for (const shared_ptr<data::SignalData> d : all_signal_data_)
+ for (const shared_ptr<data::SignalData>& d : all_signal_data_)
d->clear();
trigger_list_.clear();
qobject_cast<views::trace::View*>(view.get());
if (trace_view) {
- for (shared_ptr<data::SignalBase> signalbase : signalbases_) {
+ for (const shared_ptr<data::SignalBase>& signalbase : signalbases_) {
const int sb_exists = count_if(
view_signalbases.cbegin(), view_signalbases.cend(),
[&](const shared_ptr<data::SignalBase> &sb) {
bool Session::has_view(shared_ptr<views::ViewBase> view)
{
- for (shared_ptr<views::ViewBase> v : views_)
+ for (shared_ptr<views::ViewBase>& v : views_)
if (v == view)
return true;
{
double samplerate = 0.0;
- for (const shared_ptr<pv::data::SignalData> d : all_signal_data_) {
+ for (const shared_ptr<pv::data::SignalData>& d : all_signal_data_) {
assert(d);
const vector< shared_ptr<pv::data::Segment> > segments =
d->segments();
- for (const shared_ptr<pv::data::Segment> &s : segments)
+ for (const shared_ptr<pv::data::Segment>& s : segments)
samplerate = max(samplerate, s->samplerate());
}
// If there is no sample rate given we use samples as unit
uint32_t value = 0;
// Find the highest number of segments
- for (shared_ptr<data::SignalData> data : all_signal_data_)
+ for (const shared_ptr<data::SignalData>& data : all_signal_data_)
if (data->get_segment_count() > value)
value = data->get_segment_count();
{
vector<util::Timestamp> result;
- for (pair<uint32_t, util::Timestamp> entry : trigger_list_)
+ for (const pair<uint32_t, util::Timestamp>& entry : trigger_list_)
if (entry.first == segment_id)
result.push_back(entry.second);
{
bool all_complete = true;
- for (shared_ptr<data::SignalBase> base : signalbases_)
+ for (const shared_ptr<data::SignalBase>& base : signalbases_)
if (!base->segment_is_complete(segment_id))
all_complete = false;
signalbases_.insert(signal);
// Add the decode signal to all views
- for (shared_ptr<views::ViewBase> view : views_)
+ for (shared_ptr<views::ViewBase>& view : views_)
view->add_decode_signal(signal);
} catch (runtime_error& e) {
remove_decode_signal(signal);
{
signalbases_.erase(signal);
- for (shared_ptr<views::ViewBase> view : views_)
+ for (shared_ptr<views::ViewBase>& view : views_)
view->remove_decode_signal(signal);
signals_changed();
if (!device_) {
signalbases_.clear();
logic_data_.reset();
- for (shared_ptr<views::ViewBase> view : views_) {
+ for (shared_ptr<views::ViewBase>& view : views_) {
view->clear_signals();
#ifdef ENABLE_DECODE
view->clear_decode_signals();
if (!sr_dev) {
signalbases_.clear();
logic_data_.reset();
- for (shared_ptr<views::ViewBase> view : views_) {
+ for (shared_ptr<views::ViewBase>& view : views_) {
view->clear_signals();
#ifdef ENABLE_DECODE
view->clear_decode_signals();
}
// Make the signals list
- for (shared_ptr<views::ViewBase> viewbase : views_) {
+ for (shared_ptr<views::ViewBase>& viewbase : views_) {
views::trace::View *trace_view =
qobject_cast<views::trace::View*>(viewbase.get());
} else {
// Find the signalbase for this channel if possible
signalbase.reset();
- for (const shared_ptr<data::SignalBase> b : signalbases_)
+ for (const shared_ptr<data::SignalBase>& b : signalbases_)
if (b->channel() == channel)
signalbase = b;
void Session::free_unused_memory()
{
- for (shared_ptr<data::SignalData> data : all_signal_data_) {
+ for (const shared_ptr<data::SignalData>& data : all_signal_data_) {
const vector< shared_ptr<data::Segment> > segments = data->segments();
- for (shared_ptr<data::Segment> segment : segments) {
+ for (const shared_ptr<data::Segment>& segment : segments)
segment->free_unused_memory();
- }
}
}
{
int segment_id = 0;
- for (shared_ptr<data::SignalBase> signalbase : signalbases_) {
+ for (const shared_ptr<data::SignalBase>& signalbase : signalbases_) {
// We only care about analog and logic channels, not derived ones
if (signalbase->type() == data::SignalBase::AnalogChannel) {
segment_id = signalbase->analog_data()->get_segment_count() - 1;
void Session::feed_in_meta(shared_ptr<Meta> meta)
{
- for (auto entry : meta->config()) {
+ for (auto& entry : meta->config()) {
switch (entry.first->id()) {
case SR_CONF_SAMPLERATE:
cur_samplerate_ = g_variant_get_uint64(entry.second.gobj());
uint64_t sample_count = 0;
{
- for (const shared_ptr<pv::data::SignalData> d : all_signal_data_) {
+ for (const shared_ptr<pv::data::SignalData>& d : all_signal_data_) {
assert(d);
uint64_t temp_count = 0;
if (cur_logic_segment_)
cur_logic_segment_->set_complete();
- for (auto entry : cur_analog_segments_) {
+ for (auto& entry : cur_analog_segments_) {
shared_ptr<data::AnalogSegment> segment = entry.second;
segment->set_complete();
}
update_signals();
float *channel_data = data.get();
- for (auto channel : channels) {
+ for (auto& channel : channels) {
shared_ptr<data::AnalogSegment> segment;
// Try to get the segment of the channel
if (cur_logic_segment_)
cur_logic_segment_->set_complete();
- for (auto entry : cur_analog_segments_) {
+ for (auto& entry : cur_analog_segments_) {
shared_ptr<data::AnalogSegment> segment = entry.second;
segment->set_complete();
}
vector< shared_ptr<data::SignalBase> > achannel_list;
vector< shared_ptr<data::AnalogSegment> > asegment_list;
- for (shared_ptr<data::SignalBase> signal : sigs) {
+ for (const shared_ptr<data::SignalBase>& signal : sigs) {
if (!signal->enabled())
continue;
conv_threshold_cb_->blockSignals(true);
// Set available options depending on chosen conversion
- for (pair<QString, int> preset : presets)
+ for (pair<QString, int>& preset : presets)
conv_threshold_cb_->addItem(preset.first, preset.second);
map < QString, QVariant > options = base_->get_conversion_options();
static double prev_min = 0, prev_max = 0;
double min = 0, max = 0;
- for (shared_ptr<pv::data::AnalogSegment> segment : segments) {
+ for (const shared_ptr<pv::data::AnalogSegment>& segment : segments) {
pair<double, double> mm = segment->get_min_max();
min = std::min(min, mm.first);
max = std::max(max, mm.second);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
- for (const shared_ptr<RowItem> r : items) {
+ for (const shared_ptr<RowItem>& r : items) {
assert(r);
const bool highlight = !item_dragging_ &&
restart = false;
const vector< shared_ptr<TraceGroup> > groups(
view_.list_by_type<TraceGroup>());
- for (const shared_ptr<TraceGroup> tg : groups)
+ for (const shared_ptr<TraceGroup>& tg : groups)
if (tg->selected()) {
tg->ungroup();
restart = true;
QRectF TraceGroup::label_rect(const QRectF &rect) const
{
QRectF child_rect;
- for (const shared_ptr<ViewItem> r : child_items())
+ for (const shared_ptr<ViewItem>& r : child_items())
if (r && r->enabled())
child_rect = child_rect.united(r->label_rect(rect));
const vector<shared_ptr<TraceTreeItem>> items(trace_tree_child_items());
clear_child_items();
- for (shared_ptr<TraceTreeItem> r : items)
+ for (const shared_ptr<TraceTreeItem>& r : items)
owner_->add_child_item(r);
owner_->remove_child_item(shared_from_this());
bool has_children = false;
pair<int, int> extents(INT_MAX, INT_MIN);
- for (const shared_ptr<TraceTreeItem> t : trace_tree_child_items()) {
+ for (const shared_ptr<TraceTreeItem>& t : trace_tree_child_items()) {
assert(t);
if (!t->enabled())
continue;
settings.setValue("offset", QString::fromStdString(ss.str()));
}
- for (shared_ptr<Signal> signal : signals_) {
+ for (const shared_ptr<Signal>& signal : signals_) {
settings.beginGroup(signal->base()->internal_name());
signal->save_settings(settings);
settings.endGroup();
items.push_back(cursors_->second());
}
- for (auto trigger_marker : trigger_markers_)
+ for (auto& trigger_marker : trigger_markers_)
items.push_back(trigger_marker);
return items;
{
current_segment_ = segment_id;
- for (shared_ptr<Signal> signal : signals_)
+ for (const shared_ptr<Signal>& signal : signals_)
signal->set_current_segment(current_segment_);
#ifdef ENABLE_DECODE
- for (shared_ptr<DecodeTrace> dt : decode_traces_)
+ for (shared_ptr<DecodeTrace>& dt : decode_traces_)
dt->set_current_segment(current_segment_);
#endif
{
segment_display_mode_ = mode;
- for (shared_ptr<Signal> signal : signals_)
+ for (const shared_ptr<Signal>& signal : signals_)
signal->set_segment_display_mode(mode);
uint32_t last_segment = session_.get_segment_count() - 1;
{
// Make a set of all the visible data objects
set< shared_ptr<SignalData> > visible_data;
- for (const shared_ptr<Signal> sig : signals_)
+ for (const shared_ptr<Signal>& sig : signals_)
if (sig->enabled())
visible_data.insert(sig->data());
{
boost::optional<Timestamp> left_time, right_time;
const set< shared_ptr<SignalData> > visible_data = get_visible_data();
- for (const shared_ptr<SignalData> d : visible_data) {
+ for (const shared_ptr<SignalData>& d : visible_data) {
const vector< shared_ptr<Segment> > segments = d->segments();
- for (const shared_ptr<Segment> &s : segments) {
+ for (const shared_ptr<Segment>& s : segments) {
double samplerate = s->samplerate();
samplerate = (samplerate <= 0.0) ? 1.0 : samplerate;
vector<TraceTreeItemOwner*> owner_list;
// Make a set and a list of all the owners
- for (const auto &channel : group->channels()) {
- for (auto entry : signal_map) {
+ for (const auto& channel : group->channels()) {
+ for (auto& entry : signal_map) {
if (entry.first->channel() == channel) {
TraceTreeItemOwner *const o = (entry.second)->owner();
owner_list.push_back(o);
{
vector< shared_ptr<Trace> > filtered_traces;
- for (const auto &channel : channels) {
- for (auto entry : signal_map) {
+ for (const auto& channel : channels) {
+ for (auto& entry : signal_map) {
if (entry.first->channel() == channel) {
shared_ptr<Trace> trace = entry.second;
const auto list_iter = add_list.find(trace);
// Check whether we know the sample rate and hence can use time as the unit
if (time_unit_ == util::TimeUnit::Samples) {
// Check all signals but...
- for (const shared_ptr<Signal> signal : signals_) {
+ for (const shared_ptr<Signal>& signal : signals_) {
const shared_ptr<SignalData> data = signal->data();
// ...only check first segment of each
// Determine signal that the mouse cursor is hovering over
signal_under_mouse_cursor_.reset();
if (hover_widget_ == this) {
- for (shared_ptr<Signal> s : signals_) {
+ for (const shared_ptr<Signal>& s : signals_) {
const pair<int, int> extents = s->v_extents();
const int top = s->get_visual_y() + extents.first;
const int btm = s->get_visual_y() + extents.second;
// Update all trace tree items
const vector<shared_ptr<TraceTreeItem>> trace_tree_items(
list_by_type<TraceTreeItem>());
- for (shared_ptr<TraceTreeItem> r : trace_tree_items)
+ for (const shared_ptr<TraceTreeItem>& r : trace_tree_items)
r->hover_point_changed(hover_point_);
// Notify any other listeners
// Make a look-up table of sigrok Channels to pulseview Signals
unordered_map<shared_ptr<data::SignalBase>, shared_ptr<Signal> >
signal_map;
- for (const shared_ptr<Signal> &sig : signals_)
+ for (const shared_ptr<Signal>& sig : signals_)
signal_map[sig->base()] = sig;
// Populate channel groups
if (sr_dev)
- for (auto entry : sr_dev->channel_groups()) {
+ for (auto& entry : sr_dev->channel_groups()) {
const shared_ptr<sigrok::ChannelGroup> &group = entry.second;
if (group->channels().size() <= 1)
// Add the traces to the group
const pair<int, int> prev_v_extents = owner->v_extents();
int offset = prev_v_extents.second - prev_v_extents.first;
- for (shared_ptr<Trace> trace : new_traces_in_group) {
+ for (const shared_ptr<Trace>& trace : new_traces_in_group) {
assert(trace);
owner->add_child_item(trace);
if (non_grouped_logic_signals.size() > 0) {
const shared_ptr<TraceGroup> non_grouped_trace_group(
make_shared<TraceGroup>());
- for (shared_ptr<Trace> trace : non_grouped_logic_signals)
+ for (const shared_ptr<Trace>& trace : non_grouped_logic_signals)
non_grouped_trace_group->add_child_item(trace);
non_grouped_trace_group->restack_items();
add_traces.begin(), add_traces.end());
// Remove any removed traces
- for (shared_ptr<Trace> trace : remove_traces) {
+ for (const shared_ptr<Trace>& trace : remove_traces) {
TraceTreeItemOwner *const owner = trace->owner();
assert(owner);
owner->remove_child_item(trace);
for (LayerPaintFunc *paint_func = layer_paint_funcs;
*paint_func; paint_func++) {
ViewItemPaintParams time_pp(rect(), view_.scale(), view_.offset());
- for (const shared_ptr<TimeItem> t : time_items)
+ for (const shared_ptr<TimeItem>& t : time_items)
(t.get()->*(*paint_func))(p, time_pp);
ViewItemPaintParams row_pp(rect(), view_.scale(), view_.offset());
- for (const shared_ptr<RowItem> r : row_items)
+ for (const shared_ptr<RowItem>& r : row_items)
(r.get()->*(*paint_func))(p, row_pp);
}
if (any_row_items_selected && !any_time_items_selected) {
// Check all the drag items share a common owner
TraceTreeItemOwner *item_owner = nullptr;
- for (shared_ptr<TraceTreeItem> r : trace_tree_items)
+ for (const shared_ptr<TraceTreeItem>& r : trace_tree_items)
if (r->dragging()) {
if (!item_owner)
item_owner = r->owner();
// Drag the row items
const vector< shared_ptr<RowItem> > row_items(
view_.list_by_type<RowItem>());
- for (shared_ptr<RowItem> r : row_items)
+ for (const shared_ptr<RowItem>& r : row_items)
if (r->dragging()) {
r->drag_by(delta);
TraceTreeItemOwner *item_owner = nullptr;
const vector< shared_ptr<TraceTreeItem> > trace_tree_items(
view_.list_by_type<TraceTreeItem>());
- for (shared_ptr<TraceTreeItem> i : trace_tree_items)
+ for (const shared_ptr<TraceTreeItem>& i : trace_tree_items)
if (i->dragging())
item_owner = i->owner();
void ViewBase::clear_signalbases()
{
- for (shared_ptr<data::SignalBase> signalbase : signalbases_) {
+ for (const shared_ptr<data::SignalBase>& signalbase : signalbases_) {
disconnect(signalbase.get(), SIGNAL(samples_cleared()),
this, SLOT(on_data_updated()));
disconnect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)),
menu_.setDefaultAction(connect_action_);
menu_.addSeparator();
- for (weak_ptr<Device> dev_weak_ptr : devices_) {
+ for (weak_ptr<Device>& dev_weak_ptr : devices_) {
shared_ptr<Device> dev(dev_weak_ptr.lock());
if (!dev)
continue;
selected_device_.reset();
Device *const dev = (Device*)((QAction*)action)->data().value<void*>();
- for (weak_ptr<Device> dev_weak_ptr : devices_) {
+ for (weak_ptr<Device>& dev_weak_ptr : devices_) {
shared_ptr<Device> dev_ptr(dev_weak_ptr);
if (dev_ptr.get() == dev) {
selected_device_ = shared_ptr<Device>(dev_ptr);