Use "using std::foo" to make the actual code itself a lot more readable.
There are some exceptions where we usually cannot do this, e.g. std::thread
often conflicts with "thread" from Qt or Boost.
using namespace pv;
+using std::string;
+using std::unique_ptr;
+
AndroidAssetReader::~AndroidAssetReader()
{}
-void AndroidAssetReader::open(struct sr_resource *res, std::string name)
+void AndroidAssetReader::open(struct sr_resource *res, string name)
{
if (res->type == SR_RESOURCE_FIRMWARE) {
auto path = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
if (path.isEmpty())
path = QString::fromStdString("assets:/sigrok-firmware/" + name);
- std::unique_ptr<QFile> file {new QFile{path}};
+ unique_ptr<QFile> file {new QFile{path}};
if (!file->open(QIODevice::ReadOnly))
throw sigrok::Error{SR_ERR};
qCritical("AndroidAssetReader: Invalid handle");
throw sigrok::Error{SR_ERR_ARG};
}
- const std::unique_ptr<QFile> file {static_cast<QFile*>(res->handle)};
+ const unique_ptr<QFile> file {static_cast<QFile*>(res->handle)};
res->handle = nullptr;
file->close();
#include <libsigrokcxx/libsigrokcxx.hpp>
+using std::string;
+
namespace pv {
class AndroidAssetReader : public sigrok::ResourceReader
virtual ~AndroidAssetReader();
private:
- void open(struct sr_resource *res, std::string name) override;
+ void open(struct sr_resource *res, string name) override;
void close(struct sr_resource *res) override;
size_t read(const struct sr_resource *res, void *buf, size_t count) override;
};
Q_IMPORT_PLUGIN(QSvgPlugin)
#endif
+using std::exception;
+using std::shared_ptr;
+using std::string;
+
void usage()
{
fprintf(stdout,
int main(int argc, char *argv[])
{
int ret = 0;
- std::shared_ptr<sigrok::Context> context;
- std::string open_file, open_file_format;
+ shared_ptr<sigrok::Context> context;
+ string open_file, open_file_format;
Application a(argc, argv);
// Run the application
ret = a.exec();
- } catch (std::exception e) {
+ } catch (exception e) {
qDebug() << e.what();
}
#include <iostream>
+using std::cerr;
+using std::endl;
+using std::exception;
+
Application::Application(int &argc, char* argv[]) :
QApplication(argc, argv)
{
{
try {
return QApplication::notify(receiver, event);
- } catch (std::exception& e) {
- std::cerr << "Caught exception: " << e.what() << std::endl;
+ } catch (exception& e) {
+ cerr << "Caught exception: " << e.what() << endl;
exit(1);
return false;
}
#include "binding.hpp"
using std::shared_ptr;
+using std::string;
+using std::vector;
namespace pv {
namespace binding {
-const std::vector< std::shared_ptr<prop::Property> >& Binding::properties()
+const vector< shared_ptr<prop::Property> >& Binding::properties()
{
return properties_;
}
s = QString::fromStdString("(null)");
else if (gvar.is_of_type(Glib::VariantType("s")))
s = QString::fromStdString(
- Glib::VariantBase::cast_dynamic<Glib::Variant<std::string>>(
+ Glib::VariantBase::cast_dynamic<Glib::Variant<string>>(
gvar).get());
else
s = QString::fromStdString(gvar.print());
#include <QString>
+using std::shared_ptr;
+using std::vector;
+
class QFormLayout;
class QWidget;
class Binding
{
public:
- const std::vector< std::shared_ptr<prop::Property> >& properties();
+ const vector< shared_ptr<prop::Property> >& properties();
void commit();
static QString print_gvariant(Glib::VariantBase gvar);
protected:
- std::vector< std::shared_ptr<prop::Property> > properties_;
+ vector< shared_ptr<prop::Property> > properties_;
};
} // binding
#include <pv/prop/property.hpp>
+using std::shared_ptr;
+
struct srd_decoder_option;
namespace pv {
class Decoder : public Binding
{
public:
- Decoder(std::shared_ptr<pv::data::DecoderStack> decoder_stack,
- std::shared_ptr<pv::data::decode::Decoder> decoder);
+ Decoder(shared_ptr<pv::data::DecoderStack> decoder_stack,
+ shared_ptr<pv::data::decode::Decoder> decoder);
private:
- static std::shared_ptr<prop::Property> bind_enum(const QString &name,
+ static shared_ptr<prop::Property> bind_enum(const QString &name,
const srd_decoder_option *option,
prop::Property::Getter getter, prop::Property::Setter setter);
void setter(const char *id, Glib::VariantBase value);
private:
- std::shared_ptr<pv::data::DecoderStack> decoder_stack_;
- std::shared_ptr<pv::data::decode::Decoder> decoder_;
+ shared_ptr<pv::data::DecoderStack> decoder_stack_;
+ shared_ptr<pv::data::decode::Decoder> decoder_;
};
} // binding
#include <libsigrokcxx/libsigrokcxx.hpp>
using boost::optional;
+
using std::function;
using std::make_pair;
using std::pair;
+using std::set;
using std::shared_ptr;
using std::string;
using std::vector;
}
void Device::bind_enum(const QString &name,
- const ConfigKey *key, std::set<const Capability *> capabilities,
+ const ConfigKey *key, set<const Capability *> capabilities,
Property::Getter getter,
Property::Setter setter, function<QString (Glib::VariantBase)> printer)
{
}
void Device::bind_int(const QString &name, QString suffix,
- optional< std::pair<int64_t, int64_t> > range,
+ optional< pair<int64_t, int64_t> > range,
Property::Getter getter, Property::Setter setter)
{
assert(configurable_);
#include <libsigrokcxx/libsigrokcxx.hpp>
+using std::function;
+using std::pair;
+using std::set;
+using std::shared_ptr;
+
namespace pv {
namespace binding {
Q_OBJECT
public:
- Device(std::shared_ptr<sigrok::Configurable> configurable);
+ Device(shared_ptr<sigrok::Configurable> configurable);
Q_SIGNALS:
void config_changed();
prop::Property::Getter getter, prop::Property::Setter setter);
void bind_enum(const QString &name,
const sigrok::ConfigKey *key,
- std::set<const sigrok::Capability *> capabilities,
+ set<const sigrok::Capability *> capabilities,
prop::Property::Getter getter, prop::Property::Setter setter,
- std::function<QString (Glib::VariantBase)> printer = print_gvariant);
+ function<QString (Glib::VariantBase)> printer = print_gvariant);
void bind_int(const QString &name, QString suffix,
- boost::optional< std::pair<int64_t, int64_t> > range,
+ boost::optional< pair<int64_t, int64_t> > range,
prop::Property::Getter getter, prop::Property::Setter setter);
static QString print_timebase(Glib::VariantBase gvar);
static QString print_probe_factor(Glib::VariantBase gvar);
protected:
- std::shared_ptr<sigrok::Configurable> configurable_;
+ shared_ptr<sigrok::Configurable> configurable_;
};
} // binding
#include <pv/prop/property.hpp>
+using std::map;
+using std::shared_ptr;
+using std::string;
+using std::vector;
+
namespace sigrok {
class Option;
}
* Constructs a new @c InputOutput binding.
* @param options the map of options to use as a template.
*/
- InputOutput(
- const std::map<std::string, std::shared_ptr<sigrok::Option>>
- &options);
+ InputOutput(const map<string, shared_ptr<sigrok::Option>> &options);
/**
* Gets the map of selected options.
* @return the options.
*/
- const std::map<std::string, Glib::VariantBase>& options() const;
+ const map<string, Glib::VariantBase>& options() const;
private:
/**
* @param getter the getter that will read the values out of the map.
* @param setter the setter that will set the values into the map.
*/
- std::shared_ptr<prop::Property> bind_enum(const QString &name,
- const std::vector<Glib::VariantBase> &values,
+ shared_ptr<prop::Property> bind_enum(const QString &name,
+ const vector<Glib::VariantBase> &values,
prop::Property::Getter getter, prop::Property::Setter setter);
private:
/**
* The current map of options.
*/
- std::map<std::string, Glib::VariantBase> options_;
+ map<string, Glib::VariantBase> options_;
};
} // binding
uint64_t Analog::max_sample_count() const
{
uint64_t l = 0;
- for (const std::shared_ptr<AnalogSegment> s : segments_) {
+ for (const shared_ptr<AnalogSegment> s : segments_) {
assert(s);
l = max(l, s->get_sample_count());
}
#include <QObject>
+using std::deque;
+using std::shared_ptr;
+using std::vector;
+
namespace pv {
namespace data {
public:
Analog();
- void push_segment(
- std::shared_ptr<AnalogSegment> &segment);
+ void push_segment(shared_ptr<AnalogSegment> &segment);
- const std::deque< std::shared_ptr<AnalogSegment> >&
- analog_segments() const;
+ const deque< shared_ptr<AnalogSegment> >& analog_segments() const;
- std::vector< std::shared_ptr<Segment> > segments() const;
+ vector< shared_ptr<Segment> > segments() const;
void clear();
uint64_t end_sample);
private:
- std::deque< std::shared_ptr<AnalogSegment> > segments_;
+ deque< shared_ptr<AnalogSegment> > segments_;
};
} // namespace data
using std::lock_guard;
using std::recursive_mutex;
+using std::make_pair;
using std::max;
using std::max_element;
using std::min;
using std::min_element;
+using std::pair;
namespace pv {
namespace data {
return (float*)get_raw_samples(start_sample, (end_sample - start_sample));
}
-const std::pair<float, float> AnalogSegment::get_min_max() const
+const pair<float, float> AnalogSegment::get_min_max() const
{
- return std::make_pair(min_value_, max_value_);
+ return make_pair(min_value_, max_value_);
}
SegmentAnalogDataIterator* AnalogSegment::begin_sample_iteration(uint64_t start)
#include <QObject>
+using std::pair;
+
namespace AnalogSegmentTest {
struct Basic;
}
const float* get_samples(int64_t start_sample,
int64_t end_sample) const;
- const std::pair<float, float> get_min_max() const;
+ const pair<float, float> get_min_max() const;
SegmentAnalogDataIterator* begin_sample_iteration(uint64_t start);
void continue_sample_iteration(SegmentAnalogDataIterator* it, uint64_t increase);
#include "annotation.hpp"
+using std::vector;
+
namespace pv {
namespace data {
namespace decode {
return format_;
}
-const std::vector<QString>& Annotation::annotations() const
+const vector<QString>& Annotation::annotations() const
{
return annotations_;
}
#include <QString>
+using std::vector;
+
struct srd_proto_data;
namespace pv {
uint64_t start_sample() const;
uint64_t end_sample() const;
int format() const;
- const std::vector<QString>& annotations() const;
+ const vector<QString>& annotations() const;
private:
uint64_t start_sample_;
uint64_t end_sample_;
int format_;
- std::vector<QString> annotations_;
+ vector<QString> annotations_;
};
} // namespace decode
return channels_;
}
-void Decoder::set_channels(std::map<const srd_channel*,
- std::shared_ptr<data::SignalBase> > channels)
+void Decoder::set_channels(map<const srd_channel*,
+ shared_ptr<data::SignalBase> > channels)
{
channels_ = channels;
}
-const std::map<std::string, GVariant*>& Decoder::options() const
+const map<string, GVariant*>& Decoder::options() const
{
return options_;
}
#include <glib.h>
+using std::map;
+using std::set;
+using std::shared_ptr;
+using std::string;
+
struct srd_decoder;
struct srd_decoder_inst;
struct srd_channel;
bool shown() const;
void show(bool show = true);
- const std::map<const srd_channel*,
- std::shared_ptr<data::SignalBase> >& channels() const;
- void set_channels(std::map<const srd_channel*,
- std::shared_ptr<data::SignalBase> > channels);
+ const map<const srd_channel*,
+ shared_ptr<data::SignalBase> >& channels() const;
+ void set_channels(map<const srd_channel*,
+ shared_ptr<data::SignalBase> > channels);
- const std::map<std::string, GVariant*>& options() const;
+ const map<string, GVariant*>& options() const;
void set_option(const char *id, GVariant *value);
srd_decoder_inst* create_decoder_inst(
srd_session *session) const;
- std::set< std::shared_ptr<pv::data::Logic> > get_data();
+ set< shared_ptr<pv::data::Logic> > get_data();
private:
const srd_decoder *const decoder_;
bool shown_;
- std::map<const srd_channel*, std::shared_ptr<pv::data::SignalBase> >
- channels_;
- std::map<std::string, GVariant*> options_;
+ map<const srd_channel*, shared_ptr<pv::data::SignalBase> > channels_;
+ map<string, GVariant*> options_;
};
} // namespace decode
#include "annotation.hpp"
+using std::vector;
+
namespace pv {
namespace data {
namespace decode {
* Extracts sorted annotations between two period into a vector.
*/
void get_annotation_subset(
- std::vector<pv::data::decode::Annotation> &dest,
+ vector<pv::data::decode::Annotation> &dest,
uint64_t start_sample, uint64_t end_sample) const;
void push_annotation(const Annotation &a);
private:
- std::vector<Annotation> annotations_;
+ vector<Annotation> annotations_;
};
}
using std::lock_guard;
using std::mutex;
-using boost::optional;
using std::unique_lock;
using std::deque;
using std::make_pair;
using std::make_shared;
using std::vector;
+using boost::optional;
+
using namespace pv::data::decode;
namespace pv {
}
}
-const std::list< std::shared_ptr<decode::Decoder> >&
-DecoderStack::stack() const
+const list< shared_ptr<decode::Decoder> >& DecoderStack::stack() const
{
return stack_;
}
-void DecoderStack::push(std::shared_ptr<decode::Decoder> decoder)
+void DecoderStack::push(shared_ptr<decode::Decoder> decoder)
{
assert(decoder);
stack_.push_back(decoder);
return samples_decoded_;
}
-std::vector<Row> DecoderStack::get_visible_rows() const
+vector<Row> DecoderStack::get_visible_rows() const
{
lock_guard<mutex> lock(output_mutex_);
}
void DecoderStack::get_annotation_subset(
- std::vector<pv::data::decode::Annotation> &dest,
+ vector<pv::data::decode::Annotation> &dest,
const Row &row, uint64_t start_sample,
uint64_t end_sample) const
{
#include <pv/data/decode/rowdata.hpp>
#include <pv/util.hpp>
+using std::atomic;
+using std::condition_variable;
+using std::list;
+using std::map;
+using std::mutex;
+using std::pair;
+using std::shared_ptr;
+using std::vector;
+
struct srd_decoder;
struct srd_decoder_annotation_row;
struct srd_channel;
virtual ~DecoderStack();
- const std::list< std::shared_ptr<decode::Decoder> >& stack() const;
- void push(std::shared_ptr<decode::Decoder> decoder);
+ const list< shared_ptr<decode::Decoder> >& stack() const;
+ void push(shared_ptr<decode::Decoder> decoder);
void remove(int index);
double samplerate() const;
int64_t samples_decoded() const;
- std::vector<decode::Row> get_visible_rows() const;
+ vector<decode::Row> get_visible_rows() const;
/**
* Extracts sorted annotations between two period into a vector.
*/
void get_annotation_subset(
- std::vector<pv::data::decode::Annotation> &dest,
+ vector<pv::data::decode::Annotation> &dest,
const decode::Row &row, uint64_t start_sample,
uint64_t end_sample) const;
* @todo A proper solution should be implemented to allow multiple
* decode operations in parallel.
*/
- static std::mutex global_srd_mutex_;
+ static mutex global_srd_mutex_;
- std::list< std::shared_ptr<decode::Decoder> > stack_;
+ list< shared_ptr<decode::Decoder> > stack_;
- std::shared_ptr<pv::data::LogicSegment> segment_;
+ shared_ptr<pv::data::LogicSegment> segment_;
- mutable std::mutex input_mutex_;
- mutable std::condition_variable input_cond_;
+ mutable mutex input_mutex_;
+ mutable condition_variable input_cond_;
int64_t sample_count_;
bool frame_complete_;
- mutable std::mutex output_mutex_;
+ mutable mutex output_mutex_;
int64_t samples_decoded_;
- std::map<const decode::Row, decode::RowData> rows_;
+ map<const decode::Row, decode::RowData> rows_;
- std::map<std::pair<const srd_decoder*, int>, decode::Row> class_rows_;
+ map<pair<const srd_decoder*, int>, decode::Row> class_rows_;
QString error_message_;
std::thread decode_thread_;
- std::atomic<bool> interrupt_;
+ atomic<bool> interrupt_;
friend struct DecoderStackTest::TwoDecoderStack;
};
uint64_t Logic::max_sample_count() const
{
uint64_t l = 0;
- for (std::shared_ptr<LogicSegment> s : segments_) {
+ for (shared_ptr<LogicSegment> s : segments_) {
assert(s);
l = max(l, s->get_sample_count());
}
#include <QObject>
+using std::deque;
+using std::shared_ptr;
+using std::vector;
+
namespace pv {
namespace data {
unsigned int num_channels() const;
- void push_segment(
- std::shared_ptr<LogicSegment> &segment);
+ void push_segment(shared_ptr<LogicSegment> &segment);
- const std::deque< std::shared_ptr<LogicSegment> >&
- logic_segments() const;
+ const deque< shared_ptr<LogicSegment> >& logic_segments() const;
- std::vector< std::shared_ptr<Segment> > segments() const;
+ vector< shared_ptr<Segment> > segments() const;
void clear();
private:
const unsigned int num_channels_;
- std::deque< std::shared_ptr<LogicSegment> > segments_;
+ deque< shared_ptr<LogicSegment> > segments_;
};
} // namespace data
using std::min;
using std::pair;
using std::shared_ptr;
+using std::vector;
using sigrok::Logic;
}
void LogicSegment::get_subsampled_edges(
- std::vector<EdgePair> &edges,
+ vector<EdgePair> &edges,
uint64_t start, uint64_t end,
float min_length, int sig_index)
{
#include <QObject>
+using std::pair;
+using std::shared_ptr;
+using std::vector;
+
namespace sigrok {
class Logic;
}
static const uint64_t MipMapDataUnit;
public:
- typedef std::pair<int64_t, bool> EdgePair;
+ typedef pair<int64_t, bool> EdgePair;
public:
- LogicSegment(pv::data::Logic& owner, std::shared_ptr<sigrok::Logic> data, uint64_t samplerate);
+ LogicSegment(pv::data::Logic& owner, shared_ptr<sigrok::Logic> data, uint64_t samplerate);
virtual ~LogicSegment();
- void append_payload(std::shared_ptr<sigrok::Logic> logic);
+ void append_payload(shared_ptr<sigrok::Logic> logic);
const uint8_t* get_samples(int64_t start_sample, int64_t end_sample) const;
* can be resolved at this level of detail.
* @param[in] sig_index The index of the signal.
*/
- void get_subsampled_edges(std::vector<EdgePair> &edges,
+ void get_subsampled_edges(vector<EdgePair> &edges,
uint64_t start, uint64_t end,
float min_length, int sig_index);
#include <vector>
using std::lock_guard;
+using std::min;
using std::recursive_mutex;
using std::vector;
// Determine the number of samples we can fit in one chunk
// without exceeding MaxChunkSize
- chunk_size_ = std::min(MaxChunkSize,
- (MaxChunkSize / unit_size_) * unit_size_);
+ chunk_size_ = min(MaxChunkSize, (MaxChunkSize / unit_size_) * unit_size_);
// Create the initial chunk
current_chunk_ = new uint8_t[chunk_size_];
while (count > 0) {
const uint8_t* chunk = data_chunks_[chunk_num];
- uint64_t copy_size = std::min(count * unit_size_,
+ uint64_t copy_size = min(count * unit_size_,
chunk_size_ - chunk_offs);
memcpy(dest_ptr, chunk + chunk_offs, copy_size);
#include <mutex>
#include <vector>
+using std::recursive_mutex;
+using std::vector;
+
namespace SegmentTest {
struct SmallSize8Single;
struct MediumSize8Single;
void continue_raw_sample_iteration(SegmentRawDataIterator* it, uint64_t increase);
void end_raw_sample_iteration(SegmentRawDataIterator* it);
- mutable std::recursive_mutex mutex_;
- std::vector<uint8_t*> data_chunks_;
+ mutable recursive_mutex mutex_;
+ vector<uint8_t*> data_chunks_;
uint8_t* current_chunk_;
uint64_t used_samples_, unused_samples_;
uint64_t sample_count_;
return (decoder_stack_ != nullptr);
}
-std::shared_ptr<pv::data::DecoderStack> SignalBase::decoder_stack() const
+shared_ptr<pv::data::DecoderStack> SignalBase::decoder_stack() const
{
return decoder_stack_;
}
-void SignalBase::set_decoder_stack(std::shared_ptr<pv::data::DecoderStack>
+void SignalBase::set_decoder_stack(shared_ptr<pv::data::DecoderStack>
decoder_stack)
{
decoder_stack_ = decoder_stack;
#include <libsigrokcxx/libsigrokcxx.hpp>
+using std::shared_ptr;
namespace sigrok {
class Channel;
static const int ColourBGAlpha;
public:
- SignalBase(std::shared_ptr<sigrok::Channel> channel);
+ SignalBase(shared_ptr<sigrok::Channel> channel);
virtual ~SignalBase() {}
public:
/**
* Returns the underlying SR channel.
*/
- std::shared_ptr<sigrok::Channel> channel() const;
+ shared_ptr<sigrok::Channel> channel() const;
/**
* Returns enabled status of this channel.
/**
* Sets the internal data object.
*/
- void set_data(std::shared_ptr<pv::data::SignalData> data);
+ void set_data(shared_ptr<pv::data::SignalData> data);
/**
* Get the internal data as analog data object in case of analog type.
*/
- std::shared_ptr<pv::data::Analog> analog_data() const;
+ shared_ptr<pv::data::Analog> analog_data() const;
/**
* Get the internal data as logic data object in case of logic type.
*/
- std::shared_ptr<pv::data::Logic> logic_data() const;
+ shared_ptr<pv::data::Logic> logic_data() const;
#ifdef ENABLE_DECODE
bool is_decode_signal() const;
- std::shared_ptr<pv::data::DecoderStack> decoder_stack() const;
+ shared_ptr<pv::data::DecoderStack> decoder_stack() const;
- void set_decoder_stack(std::shared_ptr<pv::data::DecoderStack>
- decoder_stack);
+ void set_decoder_stack(shared_ptr<pv::data::DecoderStack> decoder_stack);
#endif
void save_settings(QSettings &settings) const;
void colour_changed(const QColor &colour);
private:
- std::shared_ptr<sigrok::Channel> channel_;
- std::shared_ptr<pv::data::SignalData> data_;
+ shared_ptr<sigrok::Channel> channel_;
+ shared_ptr<pv::data::SignalData> data_;
#ifdef ENABLE_DECODE
- std::shared_ptr<pv::data::DecoderStack> decoder_stack_;
+ shared_ptr<pv::data::DecoderStack> decoder_stack_;
#endif
QString internal_name_, name_;
#include <memory>
#include <vector>
+using std::shared_ptr;
+using std::vector;
+
namespace pv {
namespace data {
virtual ~SignalData() {}
public:
- virtual std::vector< std::shared_ptr<Segment> > segments() const = 0;
+ virtual vector< shared_ptr<Segment> > segments() const = 0;
virtual void clear() = 0;
driver_scan(entry.second, map<const ConfigKey *, VariantBase>());
}
-const std::shared_ptr<sigrok::Context>& DeviceManager::context() const
+const shared_ptr<sigrok::Context>& DeviceManager::context() const
{
return context_;
}
#include <memory>
#include <string>
+using std::list;
+using std::map;
+using std::shared_ptr;
+using std::string;
+
namespace Glib {
class VariantBase;
}
class DeviceManager
{
public:
- DeviceManager(std::shared_ptr<sigrok::Context> context);
+ DeviceManager(shared_ptr<sigrok::Context> context);
~DeviceManager() = default;
- const std::shared_ptr<sigrok::Context>& context() const;
+ const shared_ptr<sigrok::Context>& context() const;
- std::shared_ptr<sigrok::Context> context();
+ shared_ptr<sigrok::Context> context();
- const std::list< std::shared_ptr<devices::HardwareDevice> >&
- devices() const;
+ const list< shared_ptr<devices::HardwareDevice> >& devices() const;
- std::list< std::shared_ptr<devices::HardwareDevice> > driver_scan(
- std::shared_ptr<sigrok::Driver> driver,
- std::map<const sigrok::ConfigKey *, Glib::VariantBase> drvopts);
+ list< shared_ptr<devices::HardwareDevice> > driver_scan(
+ shared_ptr<sigrok::Driver> driver,
+ map<const sigrok::ConfigKey *, Glib::VariantBase> drvopts);
- const std::map<std::string, std::string> get_device_info(
- const std::shared_ptr<devices::Device> device);
+ const map<string, string> get_device_info(
+ const shared_ptr<devices::Device> device);
- const std::shared_ptr<devices::HardwareDevice> find_device_from_info(
- const std::map<std::string, std::string> search_info);
+ const shared_ptr<devices::HardwareDevice> find_device_from_info(
+ const map<string, string> search_info);
private:
- bool compare_devices(std::shared_ptr<devices::Device> a,
- std::shared_ptr<devices::Device> b);
+ bool compare_devices(shared_ptr<devices::Device> a,
+ shared_ptr<devices::Device> b);
protected:
- std::shared_ptr<sigrok::Context> context_;
- std::list< std::shared_ptr<devices::HardwareDevice> > devices_;
+ shared_ptr<sigrok::Context> context_;
+ list< shared_ptr<devices::HardwareDevice> > devices_;
};
} // namespace pv
using std::map;
using std::set;
+using std::shared_ptr;
using sigrok::ConfigKey;
using sigrok::Capability;
session_->remove_datafeed_callbacks();
}
-std::shared_ptr<sigrok::Session> Device::session() const
+shared_ptr<sigrok::Session> Device::session() const
{
return session_;
}
-std::shared_ptr<sigrok::Device> Device::device() const
+shared_ptr<sigrok::Device> Device::device() const
{
return device_;
}
#include <memory>
#include <string>
+using std::shared_ptr;
+using std::string;
+
namespace sigrok {
class ConfigKey;
class Device;
public:
virtual ~Device();
- std::shared_ptr<sigrok::Session> session() const;
+ shared_ptr<sigrok::Session> session() const;
- std::shared_ptr<sigrok::Device> device() const;
+ shared_ptr<sigrok::Device> device() const;
template<typename T>
T read_config(const sigrok::ConfigKey *key, const T default_value = 0);
/**
* Builds the full name. It only contains all the fields.
*/
- virtual std::string full_name() const = 0;
+ virtual string full_name() const = 0;
/**
* Builds the display name. It only contains fields as required.
* @param device_manager a reference to the device manager is needed
* so that other similarly titled devices can be detected.
*/
- virtual std::string display_name(
+ virtual string display_name(
const DeviceManager &device_manager) const = 0;
virtual void open() = 0;
virtual void stop();
protected:
- std::shared_ptr<sigrok::Session> session_;
- std::shared_ptr<sigrok::Device> device_;
+ shared_ptr<sigrok::Session> session_;
+ shared_ptr<sigrok::Device> device_;
};
} // namespace devices
#include "file.hpp"
+using std::string;
+
namespace pv {
namespace devices {
-File::File(const std::string &file_name) :
+File::File(const string &file_name) :
file_name_(file_name)
{
}
-std::string File::full_name() const
+string File::full_name() const
{
return file_name_;
}
-std::string File::display_name(const DeviceManager&) const
+string File::display_name(const DeviceManager&) const
{
return boost::filesystem::path(file_name_).filename().string();
}
#include "device.hpp"
+using std::string;
+
namespace pv {
namespace devices {
class File : public Device
{
protected:
- File(const std::string &file_name);
+ File(const string &file_name);
public:
/**
* Builds the full name. It only contains all the fields.
*/
- std::string full_name() const;
+ string full_name() const;
/**
* Builds the display name. It only contains fields as required.
*/
- std::string display_name(const DeviceManager&) const;
+ string display_name(const DeviceManager&) const;
protected:
- const std::string file_name_;
+ const string file_name_;
};
} // namespace devices
namespace pv {
namespace devices {
-HardwareDevice::HardwareDevice(const std::shared_ptr<sigrok::Context> &context,
- std::shared_ptr<sigrok::HardwareDevice> device) :
+HardwareDevice::HardwareDevice(const shared_ptr<sigrok::Context> &context,
+ shared_ptr<sigrok::HardwareDevice> device) :
context_(context),
device_open_(false)
{
#include "device.hpp"
+using std::shared_ptr;
+using std::string;
+
namespace sigrok {
class Context;
class HardwareDevice;
class HardwareDevice final : public Device
{
public:
- HardwareDevice(const std::shared_ptr<sigrok::Context> &context,
- std::shared_ptr<sigrok::HardwareDevice> device);
+ HardwareDevice(const shared_ptr<sigrok::Context> &context,
+ shared_ptr<sigrok::HardwareDevice> device);
~HardwareDevice();
- std::shared_ptr<sigrok::HardwareDevice> hardware_device() const;
+ shared_ptr<sigrok::HardwareDevice> hardware_device() const;
/**
* Builds the full name. It only contains all the fields.
*/
- std::string full_name() const;
+ string full_name() const;
/**
* Builds the display name. It only contains fields as required.
* @param device_manager a reference to the device manager is needed
* so that other similarly titled devices can be detected.
*/
- std::string display_name(const DeviceManager &device_manager) const;
+ string display_name(const DeviceManager &device_manager) const;
void open();
void close();
private:
- const std::shared_ptr<sigrok::Context> context_;
+ const shared_ptr<sigrok::Context> context_;
bool device_open_;
};
#include "inputfile.hpp"
+using std::map;
+using std::shared_ptr;
+using std::streamsize;
+using std::string;
+using std::ifstream;
+using std::ios;
+
namespace pv {
namespace devices {
-const std::streamsize InputFile::BufferSize = 16384;
+const streamsize InputFile::BufferSize = 16384;
-InputFile::InputFile(const std::shared_ptr<sigrok::Context> &context,
- const std::string &file_name,
- std::shared_ptr<sigrok::InputFormat> format,
- const std::map<std::string, Glib::VariantBase> &options) :
+InputFile::InputFile(const shared_ptr<sigrok::Context> &context,
+ const string &file_name,
+ shared_ptr<sigrok::InputFormat> format,
+ const map<string, Glib::VariantBase> &options) :
File(file_name),
context_(context),
format_(format),
// open() should add the input device to the session but
// we can't open the device without sending some data first
- f = new std::ifstream(file_name_, std::ios::binary);
+ f = new ifstream(file_name_, ios::binary);
char buffer[BufferSize];
f->read(buffer, BufferSize);
- const std::streamsize size = f->gcount();
+ const streamsize size = f->gcount();
if (size == 0)
return;
if (!f) {
// Previous call to run() processed the entire file already
- f = new std::ifstream(file_name_, std::ios::binary);
+ f = new ifstream(file_name_, ios::binary);
input_->reset();
}
interrupt_ = false;
while (!interrupt_ && !f->eof()) {
f->read(buffer, BufferSize);
- const std::streamsize size = f->gcount();
+ const streamsize size = f->gcount();
if (size == 0)
break;
#include "file.hpp"
+using std::atomic;
+using std::ifstream;
+using std::map;
+using std::shared_ptr;
+using std::streamsize;
+using std::string;
+
namespace pv {
namespace devices {
class InputFile final : public File
{
private:
- static const std::streamsize BufferSize;
+ static const streamsize BufferSize;
public:
- InputFile(const std::shared_ptr<sigrok::Context> &context,
- const std::string &file_name,
- std::shared_ptr<sigrok::InputFormat> format,
- const std::map<std::string, Glib::VariantBase> &options);
+ InputFile(const shared_ptr<sigrok::Context> &context,
+ const string &file_name,
+ shared_ptr<sigrok::InputFormat> format,
+ const map<string, Glib::VariantBase> &options);
void open();
void stop();
private:
- const std::shared_ptr<sigrok::Context> context_;
- const std::shared_ptr<sigrok::InputFormat> format_;
- const std::map<std::string, Glib::VariantBase> options_;
- std::shared_ptr<sigrok::Input> input_;
+ const shared_ptr<sigrok::Context> context_;
+ const shared_ptr<sigrok::InputFormat> format_;
+ const map<string, Glib::VariantBase> options_;
+ shared_ptr<sigrok::Input> input_;
- std::ifstream *f;
- std::atomic<bool> interrupt_;
+ ifstream *f;
+ atomic<bool> interrupt_;
};
} // namespace devices
#include "sessionfile.hpp"
+using std::shared_ptr;
+using std::string;
+
namespace pv {
namespace devices {
-SessionFile::SessionFile(const std::shared_ptr<sigrok::Context> context,
- const std::string &file_name) :
+SessionFile::SessionFile(const shared_ptr<sigrok::Context> context,
+ const string &file_name) :
File(file_name),
context_(context)
{
#include "file.hpp"
+using std::shared_ptr;
+using std::string;
+
namespace sigrok {
class Context;
} // sigrok
class SessionFile final : public File
{
public:
- SessionFile(const std::shared_ptr<sigrok::Context> context,
- const std::string &file_name);
+ SessionFile(const shared_ptr<sigrok::Context> context,
+ const string &file_name);
void open();
void close();
private:
- const std::shared_ptr<sigrok::Context> context_;
+ const shared_ptr<sigrok::Context> context_;
};
} // namespace devices
#include <QPushButton>
#include <QVBoxLayout>
+using std::shared_ptr;
+
namespace sigrok {
class Driver;
}
}
}
-Q_DECLARE_METATYPE(std::shared_ptr<sigrok::Driver>);
-Q_DECLARE_METATYPE(std::shared_ptr<pv::devices::HardwareDevice>);
+Q_DECLARE_METATYPE(shared_ptr<sigrok::Driver>);
+Q_DECLARE_METATYPE(shared_ptr<pv::devices::HardwareDevice>);
namespace pv {
public:
Connect(QWidget *parent, pv::DeviceManager &device_manager);
- std::shared_ptr<devices::HardwareDevice> get_selected_device() const;
+ shared_ptr<devices::HardwareDevice> get_selected_device() const;
private:
void populate_drivers();
- void populate_serials(std::shared_ptr<sigrok::Driver> driver);
+ void populate_serials(shared_ptr<sigrok::Driver> driver);
void unset_connection();
#include <pv/binding/inputoutput.hpp>
+using std::map;
+using std::shared_ptr;
+using std::string;
+
namespace pv {
namespace dialogs {
* @param parent the parent widget of the dialog.
*/
InputOutputOptions(const QString &title,
- const std::map<std::string, std::shared_ptr<sigrok::Option>>
- &options,
+ const map<string, shared_ptr<sigrok::Option>> &options,
QWidget *parent);
/**
* Gets the map of selected options.
* @return the options.
*/
- const std::map<std::string, Glib::VariantBase>& options() const;
+ const map<string, Glib::VariantBase>& options() const;
protected:
void accept();
#include <libsigrokdecode/libsigrokdecode.h>
#endif
+using std::shared_ptr;
+
namespace pv {
namespace dialogs {
QApplication::organizationDomain()));
version_info->setOpenExternalLinks(true);
- std::shared_ptr<sigrok::Context> context = device_manager_.context();
+ shared_ptr<sigrok::Context> context = device_manager_.context();
QString s;
s.append("<table>");
#include "storeprogress.hpp"
using std::map;
+using std::pair;
+using std::shared_ptr;
using std::string;
using Glib::VariantBase;
namespace dialogs {
StoreProgress::StoreProgress(const QString &file_name,
- const std::shared_ptr<sigrok::OutputFormat> output_format,
+ const shared_ptr<sigrok::OutputFormat> output_format,
const map<string, VariantBase> &options,
- const std::pair<uint64_t, uint64_t> sample_range,
+ const pair<uint64_t, uint64_t> sample_range,
const Session &session, QWidget *parent) :
QProgressDialog(tr("Saving..."), tr("Cancel"), 0, 0, parent),
session_(file_name.toStdString(), output_format, options, sample_range,
void StoreProgress::on_progress_updated()
{
- const std::pair<int, int> p = session_.progress();
+ const pair<int, int> p = session_.progress();
assert(p.first <= p.second);
if (p.second) {
#include <pv/storesession.hpp>
+using std::map;
+using std::pair;
+using std::shared_ptr;
+using std::string;
+
namespace pv {
class Session;
public:
StoreProgress(const QString &file_name,
- const std::shared_ptr<sigrok::OutputFormat> output_format,
- const std::map<std::string, Glib::VariantBase> &options,
- const std::pair<uint64_t, uint64_t> sample_range,
+ const shared_ptr<sigrok::OutputFormat> output_format,
+ const map<string, Glib::VariantBase> &options,
+ const pair<uint64_t, uint64_t> sample_range,
const Session &session,
QWidget *parent = 0);
#include "globalsettings.hpp"
+using std::function;
+using std::map;
+using std::multimap;
+
namespace pv {
const QString GlobalSettings::Key_View_AlwaysZoomToFit = "View_AlwaysZoomToFit";
const QString GlobalSettings::Key_View_StickyScrolling = "View_StickyScrolling";
const QString GlobalSettings::Key_View_ShowSamplingPoints = "View_ShowSamplingPoints";
-std::multimap< QString, std::function<void(QVariant)> > GlobalSettings::callbacks_;
+multimap< QString, function<void(QVariant)> > GlobalSettings::callbacks_;
bool GlobalSettings::tracking_ = false;
-std::map<QString, QVariant> GlobalSettings::tracked_changes_;
+map<QString, QVariant> GlobalSettings::tracked_changes_;
GlobalSettings::GlobalSettings() :
QSettings()
}
void GlobalSettings::register_change_handler(const QString key,
- std::function<void(QVariant)> cb)
+ function<void(QVariant)> cb)
{
callbacks_.emplace(key, cb);
}
#include <QString>
#include <QVariant>
+using std::function;
+using std::map;
+using std::multimap;
+
namespace pv {
class GlobalSettings : public QSettings
GlobalSettings();
static void register_change_handler(const QString key,
- std::function<void(QVariant)> cb);
+ function<void(QVariant)> cb);
void setValue(const QString& key, const QVariant& value);
void undo_tracked_changes();
private:
- static std::multimap< QString, std::function<void(QVariant)> > callbacks_;
+ static multimap< QString, function<void(QVariant)> > callbacks_;
static bool tracking_;
- static std::map<QString, QVariant> tracked_changes_;
+ static map<QString, QVariant> tracked_changes_;
};
} // namespace pv
#include <libsigrokcxx/libsigrokcxx.hpp>
+using std::bind;
using std::dynamic_pointer_cast;
using std::list;
using std::make_shared;
using std::map;
+using std::placeholders::_1;
using std::shared_ptr;
using std::string;
using toolbars::MainBar;
-using std::bind;
-using std::placeholders::_1;
-
const QString MainWindow::WindowTitle = tr("PulseView");
MainWindow::MainWindow(DeviceManager &device_manager,
}
}
-std::shared_ptr<Session> MainWindow::get_tab_session(int index) const
+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_)
Session *session)
{
// We get a pointer and need a reference
- for (std::shared_ptr<Session> s : sessions_)
+ for (shared_ptr<Session> s : sessions_)
if (s.get() == session)
add_view(title, type, *s);
}
void MainWindow::on_new_view(Session *session)
{
// We get a pointer and need a reference
- for (std::shared_ptr<Session> s : sessions_)
+ for (shared_ptr<Session> s : sessions_)
if (s.get() == session)
add_view(session->name(), views::ViewTypeTrace, *s);
}
#include "session.hpp"
#include "views/viewbase.hpp"
+using std::list;
+using std::map;
+using std::shared_ptr;
+using std::string;
+
struct srd_decoder;
class QVBoxLayout;
public:
explicit MainWindow(DeviceManager &device_manager,
- std::string open_file_name = std::string(),
- std::string open_file_format = std::string(),
+ string open_file_name = string(),
+ string open_file_format = string(),
QWidget *parent = 0);
~MainWindow();
- std::shared_ptr<views::ViewBase> get_active_view() const;
+ shared_ptr<views::ViewBase> get_active_view() const;
- std::shared_ptr<views::ViewBase> add_view(const QString &title,
+ shared_ptr<views::ViewBase> add_view(const QString &title,
views::ViewType type, Session &session);
- void remove_view(std::shared_ptr<views::ViewBase> view);
+ void remove_view(shared_ptr<views::ViewBase> view);
- std::shared_ptr<Session> add_session();
+ shared_ptr<Session> add_session();
- void remove_session(std::shared_ptr<Session> session);
+ void remove_session(shared_ptr<Session> session);
private:
void setup_ui();
void restore_ui_settings();
- std::shared_ptr<Session> get_tab_session(int index) const;
+ shared_ptr<Session> get_tab_session(int index) const;
void closeEvent(QCloseEvent *event);
Session *session);
void on_focus_changed();
- void on_focused_session_changed(std::shared_ptr<Session> session);
+ void on_focused_session_changed(shared_ptr<Session> session);
void on_new_session_clicked();
void on_run_stop_clicked();
private:
DeviceManager &device_manager_;
- std::list< std::shared_ptr<Session> > sessions_;
- std::shared_ptr<Session> last_focused_session_;
+ list< shared_ptr<Session> > sessions_;
+ shared_ptr<Session> last_focused_session_;
- std::map< QDockWidget*, std::shared_ptr<views::ViewBase> > view_docks_;
+ map< QDockWidget*, shared_ptr<views::ViewBase> > view_docks_;
- std::map< std::shared_ptr<Session>, QMainWindow*> session_windows_;
+ map< shared_ptr<Session>, QMainWindow*> session_windows_;
QWidget *static_tab_widget_;
QToolButton *new_session_button_, *run_stop_button_, *settings_button_;
#include <pv/widgets/popup.hpp>
+using std::map;
+using std::shared_ptr;
+using std::vector;
+
class QCheckBox;
class QGridLayout;
private:
void set_all_channels(bool set);
- void populate_group(std::shared_ptr<sigrok::ChannelGroup> group,
- const std::vector< std::shared_ptr<pv::data::SignalBase> > sigs);
+ void populate_group(shared_ptr<sigrok::ChannelGroup> group,
+ const vector< shared_ptr<pv::data::SignalBase> > sigs);
QGridLayout* create_channel_group_grid(
- const std::vector< std::shared_ptr<pv::data::SignalBase> > sigs);
+ const vector< shared_ptr<pv::data::SignalBase> > sigs);
private:
void showEvent(QShowEvent *event);
bool updating_channels_;
- std::vector< std::shared_ptr<pv::binding::Device> >
- group_bindings_;
- std::map< QCheckBox*, std::shared_ptr<pv::data::SignalBase> >
+ vector< shared_ptr<pv::binding::Device> > group_bindings_;
+ map< QCheckBox*, shared_ptr<pv::data::SignalBase> >
check_box_signal_map_;
QHBoxLayout buttons_bar_;
#include <pv/binding/device.hpp>
#include <pv/widgets/popup.hpp>
+using std::shared_ptr;
+
namespace sigrok {
class Device;
}
Q_OBJECT
public:
- DeviceOptions(std::shared_ptr<sigrok::Device> device,
- QWidget *parent);
+ DeviceOptions(shared_ptr<sigrok::Device> device, QWidget *parent);
pv::binding::Device& binding();
private:
- std::shared_ptr<sigrok::Device> device_;
+ shared_ptr<sigrok::Device> device_;
QVBoxLayout layout_;
#include "property.hpp"
+using std::pair;
+
class QDoubleSpinBox;
namespace pv {
public:
Double(QString name, int decimals, QString suffix,
- boost::optional< std::pair<double, double> > range,
+ boost::optional< pair<double, double> > range,
boost::optional<double> step,
Getter getter,
Setter setter);
private:
const int decimals_;
const QString suffix_;
- const boost::optional< std::pair<double, double> > range_;
+ const boost::optional< pair<double, double> > range_;
const boost::optional<double> step_;
QDoubleSpinBox *spin_box_;
#include <QMetaType>
+using std::pair;
+using std::vector;
+
Q_DECLARE_METATYPE(Glib::VariantBase);
class QComboBox;
Q_OBJECT;
public:
- Enum(QString name, std::vector<std::pair<Glib::VariantBase, QString> > values,
+ Enum(QString name, vector<pair<Glib::VariantBase, QString> > values,
Getter getter, Setter setter);
virtual ~Enum() = default;
void on_current_item_changed(int);
private:
- const std::vector< std::pair<Glib::VariantBase, QString> > values_;
+ const vector< pair<Glib::VariantBase, QString> > values_;
QComboBox *selector_;
};
#include "property.hpp"
+using std::pair;
+
class QSpinBox;
namespace pv {
public:
Int(QString name, QString suffix,
- boost::optional< std::pair<int64_t, int64_t> > range,
+ boost::optional< pair<int64_t, int64_t> > range,
Getter getter, Setter setter);
virtual ~Int() = default;
private:
const QString suffix_;
- const boost::optional< std::pair<int64_t, int64_t> > range_;
+ const boost::optional< pair<int64_t, int64_t> > range_;
Glib::VariantBase value_;
QSpinBox *spin_box_;
#include <QString>
#include <QWidget>
+using std::function;
+
class QWidget;
namespace pv {
Q_OBJECT;
public:
- typedef std::function<Glib::VariantBase ()> Getter;
- typedef std::function<void (Glib::VariantBase)> Setter;
+ typedef function<Glib::VariantBase ()> Getter;
+ typedef function<void (Glib::VariantBase)> Setter;
protected:
Property(QString name, Getter getter, Setter setter);
using boost::shared_mutex;
using boost::unique_lock;
+using std::bad_alloc;
using std::dynamic_pointer_cast;
+using std::find_if;
using std::function;
using std::lock_guard;
using std::list;
+using std::make_pair;
+using std::make_shared;
using std::map;
+using std::max;
+using std::move;
using std::mutex;
using std::pair;
using std::recursive_mutex;
+using std::runtime_error;
using std::set;
using std::shared_ptr;
-using std::make_shared;
using std::string;
using std::unordered_set;
using std::vector;
name_changed();
}
-const std::list< std::shared_ptr<views::ViewBase> > Session::views() const
+const list< shared_ptr<views::ViewBase> > Session::views() const
{
return views_;
}
-std::shared_ptr<views::ViewBase> Session::main_view() const
+shared_ptr<views::ViewBase> Session::main_view() const
{
return main_view_;
}
-void Session::set_main_bar(std::shared_ptr<pv::toolbars::MainBar> main_bar)
+void Session::set_main_bar(shared_ptr<pv::toolbars::MainBar> main_bar)
{
main_bar_ = main_bar;
}
if (base->is_decode_signal()) {
shared_ptr<pv::data::DecoderStack> decoder_stack =
base->decoder_stack();
- std::shared_ptr<data::decode::Decoder> top_decoder =
+ shared_ptr<data::decode::Decoder> top_decoder =
decoder_stack->stack().front();
settings.beginGroup("decoder_stack" + QString::number(stacks++));
const string value = settings.value(k).toString().toStdString();
if (!value.empty())
- dev_info.insert(std::make_pair(key, value));
+ dev_info.insert(make_pair(key, value));
}
if (dev_info.count("model") > 0)
name_changed();
// Remove all stored data
- for (std::shared_ptr<views::ViewBase> view : views_) {
+ for (shared_ptr<views::ViewBase> view : views_) {
view->clear_signals();
#ifdef ENABLE_DECODE
view->clear_decode_signals();
signals_changed();
- device_ = std::move(device);
+ device_ = move(device);
try {
device_->open();
return;
// Try and find the demo device and select that by default
- const auto iter = std::find_if(devices.begin(), devices.end(),
+ const auto iter = find_if(devices.begin(), devices.end(),
[] (const shared_ptr<devices::HardwareDevice> &d) {
- return d->hardware_device()->driver()->name() ==
- "demo"; });
+ return d->hardware_device()->driver()->name() == "demo"; });
set_device((iter == devices.end()) ? devices.front() : *iter);
}
-void Session::load_init_file(const std::string &file_name,
- const std::string &format)
+void Session::load_init_file(const string &file_name, const string &format)
{
shared_ptr<InputFormat> input_format;
}
void Session::load_file(QString file_name,
- std::shared_ptr<sigrok::InputFormat> format,
- const std::map<std::string, Glib::VariantBase> &options)
+ shared_ptr<sigrok::InputFormat> format,
+ const map<string, Glib::VariantBase> &options)
{
const QString errorMessage(
QString("Failed to load file %1").arg(file_name));
const shared_ptr<sigrok::Device> sr_dev = device_->device();
if (sr_dev) {
const auto channels = sr_dev->channels();
- if (!std::any_of(channels.begin(), channels.end(),
+ if (!any_of(channels.begin(), channels.end(),
[](shared_ptr<Channel> channel) {
return channel->enabled(); })) {
error_handler(tr("No channels enabled."));
sampling_thread_.join();
}
-void Session::register_view(std::shared_ptr<views::ViewBase> view)
+void Session::register_view(shared_ptr<views::ViewBase> view)
{
if (views_.empty()) {
main_view_ = view;
update_signals();
}
-void Session::deregister_view(std::shared_ptr<views::ViewBase> view)
+void Session::deregister_view(shared_ptr<views::ViewBase> view)
{
- views_.remove_if([&](std::shared_ptr<views::ViewBase> v) {
- return v == view; });
+ views_.remove_if([&](shared_ptr<views::ViewBase> v) { return v == view; });
if (views_.empty()) {
main_view_.reset();
}
}
-bool Session::has_view(std::shared_ptr<views::ViewBase> view)
+bool Session::has_view(shared_ptr<views::ViewBase> view)
{
- for (std::shared_ptr<views::ViewBase> v : views_)
+ for (shared_ptr<views::ViewBase> v : views_)
if (v == view)
return true;
const vector< shared_ptr<pv::data::Segment> > segments =
d->segments();
for (const shared_ptr<pv::data::Segment> &s : segments)
- samplerate = std::max(samplerate, s->samplerate());
+ samplerate = max(samplerate, s->samplerate());
}
// If there is no sample rate given we use samples as unit
if (samplerate == 0.0)
return samplerate;
}
-const std::unordered_set< std::shared_ptr<data::SignalBase> >
- Session::signalbases() const
+const unordered_set< shared_ptr<data::SignalBase> > Session::signalbases() const
{
return signalbases_;
}
decoder_stack = make_shared<data::DecoderStack>(*this, dec);
// Make a list of all the channels
- std::vector<const srd_channel*> all_channels;
+ vector<const srd_channel*> all_channels;
for (const GSList *i = dec->channels; i; i = i->next)
all_channels.push_back((const srd_channel*)i->data);
for (const GSList *i = dec->opt_channels; i; i = i->next)
signalbase->set_decoder_stack(decoder_stack);
signalbases_.insert(signalbase);
- for (std::shared_ptr<views::ViewBase> view : views_)
+ for (shared_ptr<views::ViewBase> view : views_)
view->add_decode_signal(signalbase);
- } catch (std::runtime_error e) {
+ } catch (runtime_error e) {
return false;
}
{
signalbases_.erase(signalbase);
- for (std::shared_ptr<views::ViewBase> view : views_)
+ for (shared_ptr<views::ViewBase> view : views_)
view->remove_decode_signal(signalbase);
signals_changed();
if (!device_) {
signalbases_.clear();
logic_data_.reset();
- for (std::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 (std::shared_ptr<views::ViewBase> view : views_) {
+ for (shared_ptr<views::ViewBase> view : views_) {
view->clear_signals();
#ifdef ENABLE_DECODE
view->clear_decode_signals();
// Detect what data types we will receive
auto channels = sr_dev->channels();
- unsigned int logic_channel_count = std::count_if(
+ unsigned int logic_channel_count = count_if(
channels.begin(), channels.end(),
[] (shared_ptr<Channel> channel) {
return channel->type() == ChannelType::LOGIC; });
}
// Make the signals list
- for (std::shared_ptr<views::ViewBase> viewbase : views_) {
+ for (shared_ptr<views::ViewBase> viewbase : views_) {
views::TraceView::View *trace_view =
qobject_cast<views::TraceView::View*>(viewbase.get());
shared_ptr<views::TraceView::Signal> signal;
// Find the channel in the old signals
- const auto iter = std::find_if(
+ const auto iter = find_if(
prev_sigs.cbegin(), prev_sigs.cend(),
[&](const shared_ptr<views::TraceView::Signal> &s) {
return s->base()->channel() == channel;
case SR_DF_LOGIC:
try {
feed_in_logic(dynamic_pointer_cast<Logic>(packet->payload()));
- } catch (std::bad_alloc) {
+ } catch (bad_alloc) {
out_of_memory_ = true;
device_->stop();
}
case SR_DF_ANALOG:
try {
feed_in_analog(dynamic_pointer_cast<Analog>(packet->payload()));
- } catch (std::bad_alloc) {
+ } catch (bad_alloc) {
out_of_memory_ = true;
device_->stop();
}
#include "util.hpp"
#include "views/viewbase.hpp"
+using std::function;
+using std::list;
+using std::map;
+using std::mutex;
+using std::recursive_mutex;
+using std::shared_ptr;
+using std::string;
+using std::unordered_set;
+
struct srd_decoder;
struct srd_channel;
const DeviceManager& device_manager() const;
- std::shared_ptr<sigrok::Session> session() const;
+ shared_ptr<sigrok::Session> session() const;
- std::shared_ptr<devices::Device> device() const;
+ shared_ptr<devices::Device> device() const;
QString name() const;
void set_name(QString name);
- const std::list< std::shared_ptr<views::ViewBase> > views() const;
+ const list< shared_ptr<views::ViewBase> > views() const;
- std::shared_ptr<views::ViewBase> main_view() const;
+ shared_ptr<views::ViewBase> main_view() const;
- std::shared_ptr<pv::toolbars::MainBar> main_bar() const;
+ shared_ptr<pv::toolbars::MainBar> main_bar() const;
- void set_main_bar(std::shared_ptr<pv::toolbars::MainBar> main_bar);
+ void set_main_bar(shared_ptr<pv::toolbars::MainBar> main_bar);
/**
* Indicates whether the captured data was saved to disk already or not
/**
* Attempts to set device instance, may fall back to demo if needed
*/
- void select_device(std::shared_ptr<devices::Device> device);
+ void select_device(shared_ptr<devices::Device> device);
/**
* Sets device instance that will be used in the next capture session.
*/
- void set_device(std::shared_ptr<devices::Device> device);
+ void set_device(shared_ptr<devices::Device> device);
void set_default_device();
- void load_init_file(const std::string &file_name,
- const std::string &format);
+ void load_init_file(const string &file_name, const string &format);
void load_file(QString file_name,
- std::shared_ptr<sigrok::InputFormat> format = nullptr,
- const std::map<std::string, Glib::VariantBase> &options =
- std::map<std::string, Glib::VariantBase>());
+ shared_ptr<sigrok::InputFormat> format = nullptr,
+ const map<string, Glib::VariantBase> &options =
+ map<string, Glib::VariantBase>());
capture_state get_capture_state() const;
- void start_capture(std::function<void (const QString)> error_handler);
+ void start_capture(function<void (const QString)> error_handler);
void stop_capture();
double get_samplerate() const;
- void register_view(std::shared_ptr<views::ViewBase> view);
+ void register_view(shared_ptr<views::ViewBase> view);
- void deregister_view(std::shared_ptr<views::ViewBase> view);
+ void deregister_view(shared_ptr<views::ViewBase> view);
- bool has_view(std::shared_ptr<views::ViewBase> view);
+ bool has_view(shared_ptr<views::ViewBase> view);
- const std::unordered_set< std::shared_ptr<data::SignalBase> >
+ const unordered_set< shared_ptr<data::SignalBase> >
signalbases() const;
#ifdef ENABLE_DECODE
bool add_decoder(srd_decoder *const dec);
- void remove_decode_signal(std::shared_ptr<data::SignalBase> signalbase);
+ void remove_decode_signal(shared_ptr<data::SignalBase> signalbase);
#endif
private:
void update_signals();
- std::shared_ptr<data::SignalBase> signalbase_from_channel(
- std::shared_ptr<sigrok::Channel> channel) const;
+ shared_ptr<data::SignalBase> signalbase_from_channel(
+ shared_ptr<sigrok::Channel> channel) const;
private:
- void sample_thread_proc(std::function<void (const QString)> error_handler);
+ void sample_thread_proc(function<void (const QString)> error_handler);
void free_unused_memory();
void feed_in_header();
- void feed_in_meta(std::shared_ptr<sigrok::Meta> meta);
+ void feed_in_meta(shared_ptr<sigrok::Meta> meta);
void feed_in_trigger();
void feed_in_frame_begin();
- void feed_in_logic(std::shared_ptr<sigrok::Logic> logic);
+ void feed_in_logic(shared_ptr<sigrok::Logic> logic);
- void feed_in_analog(std::shared_ptr<sigrok::Analog> analog);
+ void feed_in_analog(shared_ptr<sigrok::Analog> analog);
- void data_feed_in(std::shared_ptr<sigrok::Device> device,
- std::shared_ptr<sigrok::Packet> packet);
+ void data_feed_in(shared_ptr<sigrok::Device> device,
+ shared_ptr<sigrok::Packet> packet);
private:
DeviceManager &device_manager_;
- std::shared_ptr<devices::Device> device_;
+ shared_ptr<devices::Device> device_;
QString default_name_, name_;
- std::list< std::shared_ptr<views::ViewBase> > views_;
- std::shared_ptr<pv::views::ViewBase> main_view_;
+ list< shared_ptr<views::ViewBase> > views_;
+ shared_ptr<pv::views::ViewBase> main_view_;
- std::shared_ptr<pv::toolbars::MainBar> main_bar_;
+ shared_ptr<pv::toolbars::MainBar> main_bar_;
- mutable std::mutex sampling_mutex_; //!< Protects access to capture_state_.
+ mutable mutex sampling_mutex_; //!< Protects access to capture_state_.
capture_state capture_state_;
- std::unordered_set< std::shared_ptr<data::SignalBase> > signalbases_;
- std::unordered_set< std::shared_ptr<data::SignalData> > all_signal_data_;
+ unordered_set< shared_ptr<data::SignalBase> > signalbases_;
+ unordered_set< shared_ptr<data::SignalData> > all_signal_data_;
- mutable std::recursive_mutex data_mutex_;
- std::shared_ptr<data::Logic> logic_data_;
+ mutable recursive_mutex data_mutex_;
+ shared_ptr<data::Logic> logic_data_;
uint64_t cur_samplerate_;
- std::shared_ptr<data::LogicSegment> cur_logic_segment_;
- std::map< std::shared_ptr<sigrok::Channel>, std::shared_ptr<data::AnalogSegment> >
+ shared_ptr<data::LogicSegment> cur_logic_segment_;
+ map< shared_ptr<sigrok::Channel>, shared_ptr<data::AnalogSegment> >
cur_analog_segments_;
std::thread sampling_thread_;
using std::set;
using std::shared_ptr;
using std::string;
-using std::thread;
using std::unordered_set;
using std::vector;
const size_t StoreSession::BlockSize = 10 * 1024 * 1024;
-StoreSession::StoreSession(const std::string &file_name,
+StoreSession::StoreSession(const string &file_name,
const shared_ptr<OutputFormat> &output_format,
const map<string, VariantBase> &options,
- const std::pair<uint64_t, uint64_t> sample_range,
+ const pair<uint64_t, uint64_t> sample_range,
const Session &session) :
file_name_(file_name),
output_format_(output_format),
unit_count_ = sample_count_ >> progress_scale;
const unsigned int samples_per_block =
- std::min(asamples_per_block, lsamples_per_block);
+ min(asamples_per_block, lsamples_per_block);
while (!interrupt_ && sample_count_) {
progress_updated();
const uint64_t packet_len =
- std::min((uint64_t)samples_per_block, sample_count_);
+ min((uint64_t)samples_per_block, sample_count_);
try {
const auto context = session_.device_manager().context();
#include <QObject>
+using std::atomic;
+using std::string;
+using std::shared_ptr;
+using std::pair;
+using std::map;
+using std::vector;
+using std::thread;
+using std::mutex;
+using std::ofstream;
+
namespace sigrok {
class Output;
class OutputFormat;
static const size_t BlockSize;
public:
- StoreSession(const std::string &file_name,
- const std::shared_ptr<sigrok::OutputFormat> &output_format,
- const std::map<std::string, Glib::VariantBase> &options,
- const std::pair<uint64_t, uint64_t> sample_range,
+ StoreSession(const string &file_name,
+ const shared_ptr<sigrok::OutputFormat> &output_format,
+ const map<string, Glib::VariantBase> &options,
+ const pair<uint64_t, uint64_t> sample_range,
const Session &session);
~StoreSession();
- std::pair<int, int> progress() const;
+ pair<int, int> progress() const;
const QString& error() const;
void cancel();
private:
- void store_proc(std::vector< std::shared_ptr<data::SignalBase> > achannel_list,
- std::vector< std::shared_ptr<pv::data::AnalogSegment> > asegment_list,
- std::shared_ptr<pv::data::LogicSegment> lsegment);
+ void store_proc(vector< shared_ptr<data::SignalBase> > achannel_list,
+ vector< shared_ptr<pv::data::AnalogSegment> > asegment_list,
+ shared_ptr<pv::data::LogicSegment> lsegment);
Q_SIGNALS:
void progress_updated();
void store_successful();
private:
- const std::string file_name_;
- const std::shared_ptr<sigrok::OutputFormat> output_format_;
- const std::map<std::string, Glib::VariantBase> options_;
- const std::pair<uint64_t, uint64_t> sample_range_;
+ const string file_name_;
+ const shared_ptr<sigrok::OutputFormat> output_format_;
+ const map<string, Glib::VariantBase> options_;
+ const pair<uint64_t, uint64_t> sample_range_;
const Session &session_;
- std::shared_ptr<sigrok::Output> output_;
- std::ofstream output_stream_;
+ shared_ptr<sigrok::Output> output_;
+ ofstream output_stream_;
std::thread thread_;
- std::atomic<bool> interrupt_;
+ atomic<bool> interrupt_;
- std::atomic<int> units_stored_, unit_count_;
+ atomic<int> units_stored_, unit_count_;
- mutable std::mutex mutex_;
+ mutable mutex mutex_;
QString error_;
uint64_t start_sample_, sample_count_;
using std::copy;
using std::endl;
using std::list;
+using std::make_pair;
using std::map;
using std::max;
using std::min;
+using std::pair;
+using std::set;
using std::shared_ptr;
using std::string;
using std::vector;
session.device_manager().context());
menu_file_export->setTitle(tr("&Export"));
connect(menu_file_export,
- SIGNAL(format_selected(std::shared_ptr<sigrok::OutputFormat>)),
- this, SLOT(export_file(std::shared_ptr<sigrok::OutputFormat>)));
+ SIGNAL(format_selected(shared_ptr<sigrok::OutputFormat>)),
+ this, SLOT(export_file(shared_ptr<sigrok::OutputFormat>)));
widgets::ImportMenu *menu_file_import = new widgets::ImportMenu(this,
session.device_manager().context());
menu_file_import->setTitle(tr("&Import"));
connect(menu_file_import,
- SIGNAL(format_selected(std::shared_ptr<sigrok::InputFormat>)),
- this, SLOT(import_file(std::shared_ptr<sigrok::InputFormat>)));
+ SIGNAL(format_selected(shared_ptr<sigrok::InputFormat>)),
+ this, SLOT(import_file(shared_ptr<sigrok::InputFormat>)));
action_connect_->setText(tr("&Connect to Device..."));
connect(action_connect_, SIGNAL(triggered(bool)),
widgets::ImportMenu *import_menu = new widgets::ImportMenu(this,
session.device_manager().context(), action_open_);
connect(import_menu,
- SIGNAL(format_selected(std::shared_ptr<sigrok::InputFormat>)),
+ SIGNAL(format_selected(shared_ptr<sigrok::InputFormat>)),
this,
- SLOT(import_file(std::shared_ptr<sigrok::InputFormat>)));
+ SLOT(import_file(shared_ptr<sigrok::InputFormat>)));
open_button_->setMenu(import_menu);
open_button_->setDefaultAction(action_open_);
session.device_manager().context(),
open_actions);
connect(export_menu,
- SIGNAL(format_selected(std::shared_ptr<sigrok::OutputFormat>)),
+ SIGNAL(format_selected(shared_ptr<sigrok::OutputFormat>)),
this,
- SLOT(export_file(std::shared_ptr<sigrok::OutputFormat>)));
+ SLOT(export_file(shared_ptr<sigrok::OutputFormat>)));
save_button_->setMenu(export_menu);
save_button_->setDefaultAction(action_save_as_);
update_device_config_widgets();
}
-
void MainBar::set_capture_state(pv::Session::capture_state state)
{
bool ui_enabled = (state == pv::Session::Stopped) ? true : false;
GVariant *gvar_list;
const uint64_t *elements = nullptr;
gsize num_elements;
- map< const ConfigKey*, std::set<Capability> > keys;
+ map< const ConfigKey*, set<Capability> > keys;
if (updating_sample_rate_) {
sample_rate_.show_none();
QSettings settings;
const QString dir = settings.value(SettingSaveDirectory).toString();
- std::pair<uint64_t, uint64_t> sample_range;
+ pair<uint64_t, uint64_t> sample_range;
// Selection only? Verify that the cursors are active and fetch their values
if (selection_only) {
const pv::util::Timestamp& start_time = trace_view->cursors()->first()->time();
const pv::util::Timestamp& end_time = trace_view->cursors()->second()->time();
- const uint64_t start_sample = (uint64_t)std::max(
+ const uint64_t start_sample = (uint64_t)max(
(double)0, start_time.convert_to<double>() * samplerate);
- const uint64_t end_sample = (uint64_t)std::max(
+ const uint64_t end_sample = (uint64_t)max(
(double)0, end_time.convert_to<double>() * samplerate);
- sample_range = std::make_pair(start_sample, end_sample);
+ sample_range = make_pair(start_sample, end_sample);
} else {
- sample_range = std::make_pair(0, 0);
+ sample_range = make_pair(0, 0);
}
// Construct the filter
#include <pv/widgets/popuptoolbutton.hpp>
#include <pv/widgets/sweeptimingwidget.hpp>
+using std::shared_ptr;
+
namespace sigrok {
class Device;
class InputFormat;
class OutputFormat;
}
-Q_DECLARE_METATYPE(std::shared_ptr<sigrok::Device>)
+Q_DECLARE_METATYPE(shared_ptr<sigrok::Device>)
class QAction;
void add_decoder(srd_decoder *decoder);
- void export_file(std::shared_ptr<sigrok::OutputFormat> format,
+ void export_file(shared_ptr<sigrok::OutputFormat> format,
bool selection_only = false);
- void import_file(std::shared_ptr<sigrok::InputFormat> format);
+ void import_file(shared_ptr<sigrok::InputFormat> format);
void on_device_selected();
void on_device_changed();
#include <QTextStream>
#include <QDebug>
+using std::fixed;
+using std::max;
+using std::ostringstream;
+using std::setfill;
+using std::setprecision;
+using std::showpos;
+using std::string;
+
using namespace Qt;
namespace pv {
int precision = stream.realNumberPrecision();
- std::ostringstream ss;
- ss << std::fixed;
+ ostringstream ss;
+ ss << fixed;
if (stream.numberFlags() & QTextStream::ForceSign)
- ss << std::showpos;
+ ss << showpos;
if (0 == precision)
- ss << std::setprecision(1) << round(t);
+ ss << setprecision(1) << round(t);
else
- ss << std::setprecision(precision) << t;
+ ss << setprecision(precision) << t;
- std::string str(ss.str());
+ string str(ss.str());
if (0 == precision) {
// remove the separator and the unwanted decimal place
str.resize(str.size() - 2);
const unsigned int relative_prec =
(prefix >= SIPrefix::none) ? precision :
- std::max((int)(precision - prefix_order), 0);
+ max((int)(precision - prefix_order), 0);
return format_time_si(t, prefix, relative_prec, unit, sign);
}
const Timestamp fraction = fabs(t) - whole_seconds;
- std::ostringstream ss;
- ss
- << std::fixed
- << std::setprecision(precision)
- << std::setfill('0')
- << fraction;
- std::string fs = ss.str();
+ ostringstream ss;
+ ss << fixed << setprecision(precision) << setfill('0') << fraction;
+ string fs = ss.str();
// Copy all digits, inserting spaces as unit separators
for (int i = 1; i <= precision; i++) {
#include <libsigrokcxx/libsigrokcxx.hpp>
+using std::deque;
+using std::div;
+using std::div_t;
using std::max;
using std::make_pair;
using std::min;
+using std::numeric_limits;
+using std::pair;
using std::shared_ptr;
-using std::deque;
namespace pv {
namespace views {
autoranging_ = settings.value("autoranging").toBool();
}
-std::pair<int, int> AnalogSignal::v_extents() const
+pair<int, int> AnalogSignal::v_extents() const
{
const int ph = pos_vdivs_ * div_height_;
const int nh = neg_vdivs_ * div_height_;
{
const float seq[] = {1.0f, 2.0f, 5.0f};
- const int offset = std::numeric_limits<int>::max() / (2 * countof(seq));
- const std::div_t d = std::div(
- (int)(scale_index + countof(seq) * offset),
+ const int offset = numeric_limits<int>::max() / (2 * countof(seq));
+ const div_t d = div((int)(scale_index + countof(seq) * offset),
countof(seq));
return powf(10.0f, d.quot - offset) * seq[d.rem];
double min = 0, max = 0;
for (shared_ptr<pv::data::AnalogSegment> segment : segments) {
- std::pair<double, double> mm = segment->get_min_max();
+ pair<double, double> mm = segment->get_min_max();
min = std::min(min, mm.first);
max = std::max(max, mm.second);
}
#include <QComboBox>
+using std::pair;
+using std::shared_ptr;
+
namespace pv {
namespace data {
static const int InfoTextMarginRight, InfoTextMarginBottom;
public:
- AnalogSignal(pv::Session &session,
- std::shared_ptr<data::SignalBase> base);
+ AnalogSignal(pv::Session &session, shared_ptr<data::SignalBase> base);
virtual ~AnalogSignal() = default;
- std::shared_ptr<pv::data::SignalData> data() const;
+ shared_ptr<pv::data::SignalData> data() const;
virtual void save_settings(QSettings &settings) const;
* Computes the vertical extents of the contents of this row item.
* @return A pair containing the minimum and maximum y-values.
*/
- std::pair<int, int> v_extents() const;
+ pair<int, int> v_extents() const;
/**
* Returns the offset to show the drag handle.
void paint_grid(QPainter &p, int y, int left, int right);
void paint_trace(QPainter &p,
- const std::shared_ptr<pv::data::AnalogSegment> &segment,
+ const shared_ptr<pv::data::AnalogSegment> &segment,
int y, int left, const int64_t start, const int64_t end,
const double pixels_offset, const double samples_per_pixel);
void paint_envelope(QPainter &p,
- const std::shared_ptr<pv::data::AnalogSegment> &segment,
+ const shared_ptr<pv::data::AnalogSegment> &segment,
int y, int left, const int64_t start, const int64_t end,
const double pixels_offset, const double samples_per_pixel);
#include <QSizeF>
+using std::shared_ptr;
+
class QPainter;
namespace pv {
QRectF label_rect(const QRectF &rect) const;
private:
- std::shared_ptr<Cursor> get_other_cursor() const;
+ shared_ptr<Cursor> get_other_cursor() const;
};
} // namespace TraceView
#include <QPainter>
+using std::pair;
+using std::shared_ptr;
+
class QPainter;
namespace pv {
/**
* Returns a pointer to the first cursor.
*/
- std::shared_ptr<Cursor> first() const;
+ shared_ptr<Cursor> first() const;
/**
* Returns a pointer to the second cursor.
*/
- std::shared_ptr<Cursor> second() const;
+ shared_ptr<Cursor> second() const;
/**
* Sets the time of the marker.
void compute_text_size(QPainter &p);
- std::pair<float, float> get_cursor_offsets() const;
+ pair<float, float> get_cursor_offsets() const;
private:
- std::shared_ptr<Cursor> first_, second_;
+ shared_ptr<Cursor> first_, second_;
QSizeF text_size_;
};
using boost::shared_lock;
using boost::shared_mutex;
+
+using std::all_of;
using std::dynamic_pointer_cast;
using std::list;
using std::lock_guard;
using std::make_pair;
using std::map;
using std::min;
+using std::out_of_range;
using std::pair;
using std::shared_ptr;
using std::make_shared;
delete_mapper_(this),
show_hide_mapper_(this)
{
- std::shared_ptr<pv::data::DecoderStack> decoder_stack =
- base_->decoder_stack();
+ shared_ptr<pv::data::DecoderStack> decoder_stack = base_->decoder_stack();
// Determine shortest string we want to see displayed in full
QFontMetrics m(QApplication::font());
return true;
}
-std::shared_ptr<data::SignalBase> DecodeTrace::base() const
+shared_ptr<data::SignalBase> DecodeTrace::base() const
{
return base_;
}
{
using namespace pv::data::decode;
- std::shared_ptr<pv::data::DecoderStack> decoder_stack =
- base_->decoder_stack();
+ shared_ptr<pv::data::DecoderStack> decoder_stack = base_->decoder_stack();
const int text_height = ViewItemPaintParams::text_height();
row_height_ = (text_height * 6) / 4;
int row_title_width;
try {
row_title_width = row_title_widths_.at(row);
- } catch (std::out_of_range) {
+ } catch (out_of_range) {
const int w = p.boundingRect(QRectF(), 0, row.title()).width() +
RowTitleMargin;
row_title_widths_[row] = w;
owner_->extents_changed(false, true);
// Update the maximum row count if needed
- max_visible_rows_ = std::max(max_visible_rows_, (int)visible_rows_.size());
+ max_visible_rows_ = max(max_visible_rows_, (int)visible_rows_.size());
}
void DecodeTrace::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
{
using pv::data::decode::Decoder;
- std::shared_ptr<pv::data::DecoderStack> decoder_stack =
- base_->decoder_stack();
+ shared_ptr<pv::data::DecoderStack> decoder_stack = base_->decoder_stack();
assert(form);
assert(parent);
// Check if all annotations are of the same type (i.e. we can use one color)
// or if we should use a neutral color (i.e. gray)
const int format = annotations.front().format();
- const bool single_format = std::all_of(
+ const bool single_format = all_of(
annotations.begin(), annotations.end(),
[&](const Annotation &a) { return a.format() == format; });
const int ann_start = start + cap_width;
const int ann_end = end - cap_width;
- const int real_start = std::max(ann_start, pp.left() + row_title_width);
- const int real_end = std::min(ann_end, pp.right());
+ const int real_start = max(ann_start, pp.left() + row_title_width);
+ const int real_end = min(ann_end, pp.right());
const int real_width = real_end - real_start;
QRectF rect(real_start, y - h / 2, real_width, h);
double samples_per_pixel, pixels_offset;
- std::shared_ptr<pv::data::DecoderStack> decoder_stack =
- base_->decoder_stack();
+ shared_ptr<pv::data::DecoderStack> decoder_stack = base_->decoder_stack();
assert(decoder_stack);
pair<double, double> DecodeTrace::get_pixels_offset_samples_per_pixel() const
{
- std::shared_ptr<pv::data::DecoderStack> decoder_stack =
- base_->decoder_stack();
+ shared_ptr<pv::data::DecoderStack> decoder_stack = base_->decoder_stack();
assert(owner_);
assert(decoder_stack);
vector<pv::data::decode::Annotation> annotations;
- std::shared_ptr<pv::data::DecoderStack> decoder_stack =
- base_->decoder_stack();
+ shared_ptr<pv::data::DecoderStack> decoder_stack = base_->decoder_stack();
assert(decoder_stack);
decoder_stack->get_annotation_subset(annotations, visible_rows_[row],
channel_selectors_.push_back(s);
}
- std::shared_ptr<pv::data::DecoderStack> decoder_stack =
- base_->decoder_stack();
+ shared_ptr<pv::data::DecoderStack> decoder_stack = base_->decoder_stack();
// Add the options
shared_ptr<binding::Decoder> binding(
const auto sigs(session_.signalbases());
vector< shared_ptr<data::SignalBase> > sig_list(sigs.begin(), sigs.end());
- std::sort(sig_list.begin(), sig_list.end(),
+ sort(sig_list.begin(), sig_list.end(),
[](const shared_ptr<data::SignalBase> &a,
const shared_ptr<data::SignalBase> &b) {
return strnatcasecmp(a->name().toStdString(),
void DecodeTrace::commit_channels()
{
- std::shared_ptr<pv::data::DecoderStack> decoder_stack =
- base_->decoder_stack();
+ shared_ptr<pv::data::DecoderStack> decoder_stack = base_->decoder_stack();
assert(decoder_stack);
for (shared_ptr<data::decode::Decoder> dec : decoder_stack->stack())
void DecodeTrace::on_stack_decoder(srd_decoder *decoder)
{
- std::shared_ptr<pv::data::DecoderStack> decoder_stack =
- base_->decoder_stack();
+ shared_ptr<pv::data::DecoderStack> decoder_stack = base_->decoder_stack();
assert(decoder);
assert(decoder_stack);
void DecodeTrace::on_delete_decoder(int index)
{
- std::shared_ptr<pv::data::DecoderStack> decoder_stack =
- base_->decoder_stack();
+ shared_ptr<pv::data::DecoderStack> decoder_stack = base_->decoder_stack();
decoder_stack->remove(index);
{
using pv::data::decode::Decoder;
- std::shared_ptr<pv::data::DecoderStack> decoder_stack =
- base_->decoder_stack();
+ shared_ptr<pv::data::DecoderStack> decoder_stack = base_->decoder_stack();
const list< shared_ptr<Decoder> > stack(decoder_stack->stack());
#include <pv/data/signalbase.hpp>
#include <pv/data/decode/row.hpp>
+using std::list;
+using std::map;
+using std::pair;
+using std::shared_ptr;
+using std::vector;
+
struct srd_channel;
struct srd_decoder;
struct ChannelSelector
{
const QComboBox *combo_;
- const std::shared_ptr<pv::data::decode::Decoder> decoder_;
+ const shared_ptr<pv::data::decode::Decoder> decoder_;
const srd_channel *pdch_;
};
static const QColor OutlineColours[16];
public:
- DecodeTrace(pv::Session &session, std::shared_ptr<data::SignalBase> signalbase,
+ DecodeTrace(pv::Session &session, shared_ptr<data::SignalBase> signalbase,
int index);
bool enabled() const;
- const std::shared_ptr<pv::data::DecoderStack>& decoder() const;
+ const shared_ptr<pv::data::DecoderStack>& decoder() const;
- std::shared_ptr<data::SignalBase> base() const;
+ shared_ptr<data::SignalBase> base() const;
/**
* Computes the vertical extents of the contents of this row item.
* @return A pair containing the minimum and maximum y-values.
*/
- std::pair<int, int> v_extents() const;
+ pair<int, int> v_extents() const;
/**
* Paints the background layer of the trace with a QPainter
void delete_pressed();
private:
- void draw_annotations(std::vector<pv::data::decode::Annotation> annotations,
+ void draw_annotations(vector<pv::data::decode::Annotation> annotations,
QPainter &p, int h, const ViewItemPaintParams &pp, int y,
size_t base_colour, int row_title_width);
int h, const ViewItemPaintParams &pp, int y,
size_t base_colour, int row_title_width) const;
- void draw_annotation_block(std::vector<pv::data::decode::Annotation> annotations,
+ void draw_annotation_block(vector<pv::data::decode::Annotation> annotations,
QPainter &p, int h, int y, size_t base_colour) const;
void draw_instant(const pv::data::decode::Annotation &a, QPainter &p,
void draw_unresolved_period(QPainter &p, int h, int left,
int right) const;
- std::pair<double, double> get_pixels_offset_samples_per_pixel() const;
+ pair<double, double> get_pixels_offset_samples_per_pixel() const;
/**
* Determines the start and end sample for a given pixel range.
* @return Returns a pair containing the start sample and the end
* sample that correspond to the start and end coordinates.
*/
- std::pair<uint64_t, uint64_t> get_sample_range(int x_start, int x_end) const;
+ pair<uint64_t, uint64_t> get_sample_range(int x_start, int x_end) const;
int get_row_at_point(const QPoint &point);
const QString get_annotation_at_point(const QPoint &point);
void create_decoder_form(int index,
- std::shared_ptr<pv::data::decode::Decoder> &dec,
+ shared_ptr<pv::data::decode::Decoder> &dec,
QWidget *parent, QFormLayout *form);
QComboBox* create_channel_selector(QWidget *parent,
- const std::shared_ptr<pv::data::decode::Decoder> &dec,
+ const shared_ptr<pv::data::decode::Decoder> &dec,
const srd_channel *const pdch);
void commit_decoder_channels(
- std::shared_ptr<data::decode::Decoder> &dec);
+ shared_ptr<data::decode::Decoder> &dec);
void commit_channels();
private:
pv::Session &session_;
- std::vector<data::decode::Row> visible_rows_;
+ vector<data::decode::Row> visible_rows_;
uint64_t decode_start_, decode_end_;
- std::list< std::shared_ptr<pv::binding::Decoder> >
- bindings_;
+ list< shared_ptr<pv::binding::Decoder> > bindings_;
- std::list<ChannelSelector> channel_selectors_;
- std::vector<pv::widgets::DecoderGroupBox*> decoder_forms_;
+ list<ChannelSelector> channel_selectors_;
+ vector<pv::widgets::DecoderGroupBox*> decoder_forms_;
- std::map<data::decode::Row, int> row_title_widths_;
+ map<data::decode::Row, int> row_title_widths_;
int row_height_, max_visible_rows_;
int min_useful_label_width_;
#include <pv/widgets/popup.hpp>
+using std::enable_shared_from_this;
using std::shared_ptr;
namespace pv {
Flag::Flag(const Flag &flag) :
TimeMarker(flag.view_, FillColour, flag.time_),
- std::enable_shared_from_this<Flag>(flag)
+ enable_shared_from_this<Flag>(flag)
{
}
#include "timemarker.hpp"
+using std::enable_shared_from_this;
+
class QMenu;
namespace pv {
namespace views {
namespace TraceView {
-class Flag : public TimeMarker,
- public std::enable_shared_from_this<Flag>
+class Flag : public TimeMarker, public enable_shared_from_this<Flag>
{
Q_OBJECT
#include <pv/widgets/popup.hpp>
using boost::make_filter_iterator;
+
+using std::count_if;
using std::dynamic_pointer_cast;
using std::max;
using std::make_pair;
const vector< shared_ptr<TraceTreeItem> > items(
view_.list_by_type<TraceTreeItem>());
- if (std::count_if(items.begin(), items.end(), item_selected) > 1)
- {
+ if (count_if(items.begin(), items.end(), item_selected) > 1) {
menu->addSeparator();
QAction *const group = new QAction(tr("Group"), this);
shared_ptr<TraceGroup> group(new TraceGroup());
shared_ptr<TraceTreeItem> mouse_down_item(
- std::dynamic_pointer_cast<TraceTreeItem>(mouse_down_item_));
+ dynamic_pointer_cast<TraceTreeItem>(mouse_down_item_));
shared_ptr<TraceTreeItem> focus_item(
mouse_down_item ? mouse_down_item : selected_items.front());
#include "marginwidget.hpp"
+using std::shared_ptr;
+using std::vector;
+
namespace pv {
namespace views {
namespace TraceView {
/**
* Gets the row items.
*/
- std::vector< std::shared_ptr<ViewItem> > items();
+ vector< shared_ptr<ViewItem> > items();
/**
* Gets the first view item which has a label that contains @c pt .
* @return the view item that has been found, or and empty
* @c shared_ptr if no item was found.
*/
- std::shared_ptr<ViewItem> get_mouse_over_item(const QPoint &pt);
+ shared_ptr<ViewItem> get_mouse_over_item(const QPoint &pt);
private:
void paintEvent(QPaintEvent *event);
using std::max;
using std::make_pair;
using std::min;
+using std::none_of;
using std::pair;
using std::shared_ptr;
using std::vector;
return base_->logic_data();
}
-std::pair<int, int> LogicSignal::v_extents() const
+pair<int, int> LogicSignal::v_extents() const
{
const int signal_margin =
QFontMetrics(QApplication::font()).height() / 2;
if (trigger) {
for (auto stage : trigger->stages()) {
const auto &matches = stage->matches();
- if (std::none_of(matches.begin(), matches.end(),
+ if (none_of(matches.begin(), matches.end(),
[&](shared_ptr<TriggerMatch> match) {
return match->channel() != base_->channel(); }))
continue;
#include <memory>
+using std::pair;
+using std::shared_ptr;
+using std::vector;
+
class QIcon;
class QToolBar;
public:
LogicSignal(pv::Session &session,
- std::shared_ptr<devices::Device> device,
- std::shared_ptr<data::SignalBase> base);
+ shared_ptr<devices::Device> device,
+ shared_ptr<data::SignalBase> base);
virtual ~LogicSignal() = default;
- std::shared_ptr<pv::data::SignalData> data() const;
+ shared_ptr<pv::data::SignalData> data() const;
- std::shared_ptr<pv::data::Logic> logic_data() const;
+ shared_ptr<pv::data::Logic> logic_data() const;
/**
* Computes the vertical extents of the contents of this row item.
* @return A pair containing the minimum and maximum y-values.
*/
- std::pair<int, int> v_extents() const;
+ pair<int, int> v_extents() const;
/**
* Returns the offset to show the drag handle.
private:
void paint_caps(QPainter &p, QLineF *const lines,
- std::vector< std::pair<int64_t, bool> > &edges,
+ vector< pair<int64_t, bool> > &edges,
bool level, double samples_per_pixel, double pixels_offset,
float x_offset, float y_offset);
void init_trigger_actions(QWidget *parent);
- const std::vector<int32_t> get_trigger_types() const;
+ const vector<int32_t> get_trigger_types() const;
QAction* action_from_trigger_type(
const sigrok::TriggerMatchType *type);
const sigrok::TriggerMatchType* trigger_type_from_action(
private:
int signal_height_;
- std::shared_ptr<pv::devices::Device> device_;
+ shared_ptr<pv::devices::Device> device_;
const sigrok::TriggerMatchType *trigger_match_;
QToolBar *trigger_bar_;
#include "viewwidget.hpp"
+using std::shared_ptr;
+
namespace pv {
namespace views {
namespace TraceView {
* Indicates the event an a view item has been clicked.
* @param item the view item that has been clicked.
*/
- virtual void item_clicked(
- const std::shared_ptr<ViewItem> &item);
+ virtual void item_clicked(const shared_ptr<ViewItem> &item);
/**
* Shows the popup of a the specified @c ViewItem .
* @param item The item to show the popup for.
*/
- void show_popup(const std::shared_ptr<ViewItem> &item);
+ void show_popup(const shared_ptr<ViewItem> &item);
protected:
virtual void contextMenuEvent(QContextMenuEvent *event);
using namespace Qt;
+using std::function;
using std::shared_ptr;
using std::vector;
QSize Ruler::extended_size_hint() const
{
QRectF max_rect;
- std::vector< std::shared_ptr<TimeItem> > items(view_.time_items());
+ vector< shared_ptr<TimeItem> > items(view_.time_items());
for (auto &i : items)
max_rect = max_rect.united(i->label_rect(QRect()));
return QSize(0, sizeHint().height() - max_rect.top() / 2 +
const pv::util::Timestamp& offset,
const double scale,
const int width,
- std::function<QString(const pv::util::Timestamp&)> format_function)
+ function<QString(const pv::util::Timestamp&)> format_function)
{
TickPositions tp;
#include "marginwidget.hpp"
#include <pv/util.hpp>
+using std::function;
+using std::pair;
+using std::shared_ptr;
+using std::vector;
+
namespace RulerTest {
struct tick_position_test_0;
struct tick_position_test_1;
/**
* Gets the time items.
*/
- std::vector< std::shared_ptr<ViewItem> > items() override;
+ vector< shared_ptr<ViewItem> > items() override;
/**
* Gets the first view item which has a label that contains @c pt .
* @return the view item that has been found, or and empty
* @c shared_ptr if no item was found.
*/
- std::shared_ptr<ViewItem> get_mouse_over_item(
- const QPoint &pt) override;
+ shared_ptr<ViewItem> get_mouse_over_item(const QPoint &pt) override;
void paintEvent(QPaintEvent *event) override;
struct TickPositions
{
- std::vector<std::pair<double, QString>> major;
- std::vector<double> minor;
+ vector<pair<double, QString>> major;
+ vector<double> minor;
};
/**
const pv::util::Timestamp& offset,
const double scale,
const int width,
- std::function<QString(const pv::util::Timestamp&)> format_function);
+ function<QString(const pv::util::Timestamp&)> format_function);
protected:
void resizeEvent(QResizeEvent*) override;
};
Signal::Signal(pv::Session &session,
- std::shared_ptr<data::SignalBase> channel) :
+ shared_ptr<data::SignalBase> channel) :
Trace(channel),
session_(session),
scale_handle_(make_shared<SignalScaleHandle>(*this)),
#include "trace.hpp"
#include "viewitemowner.hpp"
+using std::shared_ptr;
+
namespace pv {
class Session;
Q_OBJECT
protected:
- Signal(pv::Session &session,
- std::shared_ptr<data::SignalBase> channel);
+ Signal(pv::Session &session, shared_ptr<data::SignalBase> channel);
public:
/**
*/
virtual void set_name(QString name);
- virtual std::shared_ptr<pv::data::SignalData> data() const = 0;
+ virtual shared_ptr<pv::data::SignalData> data() const = 0;
/**
* Returns true if the trace is visible and enabled.
*/
bool enabled() const;
- std::shared_ptr<data::SignalBase> base() const;
+ shared_ptr<data::SignalBase> base() const;
virtual void save_settings(QSettings &settings) const;
protected:
pv::Session &session_;
- const std::shared_ptr<SignalScaleHandle> scale_handle_;
+ const shared_ptr<SignalScaleHandle> scale_handle_;
const item_list items_;
QComboBox *name_widget_;
#include "pv/widgets/colourbutton.hpp"
#include "pv/widgets/popup.hpp"
+using std::pair;
+using std::shared_ptr;
+
namespace pv {
namespace views {
namespace TraceView {
const QColor Trace::BrightGrayBGColour = QColor(0, 0, 0, 10*255/100);
const QColor Trace::DarkGrayBGColour = QColor(0, 0, 0, 15*255/100);
-Trace::Trace(std::shared_ptr<data::SignalBase> channel) :
+Trace::Trace(shared_ptr<data::SignalBase> channel) :
base_(channel),
popup_(nullptr),
popup_form_(nullptr)
p.setPen(QPen(Qt::NoPen));
- const std::pair<int, int> extents = v_extents();
+ const pair<int, int> extents = v_extents();
const int x = 0;
const int y = get_visual_y() + extents.first;
#include "pv/data/signalbase.hpp"
+using std::shared_ptr;
+
class QFormLayout;
namespace pv {
static const QColor DarkGrayBGColour;
protected:
- Trace(std::shared_ptr<data::SignalBase> channel);
+ Trace(shared_ptr<data::SignalBase> channel);
public:
/**
void on_colouredit_changed(const QColor &colour);
protected:
- std::shared_ptr<data::SignalBase> base_;
+ shared_ptr<data::SignalBase> base_;
bool coloured_bg_, coloured_bg_state_;
private:
#include "tracegroup.hpp"
+using std::any_of;
using std::pair;
using std::shared_ptr;
using std::vector;
bool TraceGroup::enabled() const
{
- return std::any_of(child_items().begin(), child_items().end(),
+ return any_of(child_items().begin(), child_items().end(),
[](const shared_ptr<ViewItem> &r) { return r->enabled(); });
}
#include "tracetreeitem.hpp"
#include "tracetreeitemowner.hpp"
+using std::pair;
+
namespace pv {
namespace views {
namespace TraceView {
* Computes the vertical extents of the contents of this row item.
* @return A pair containing the minimum and maximum y-values.
*/
- std::pair<int, int> v_extents() const;
+ pair<int, int> v_extents() const;
/**
* Paints the signal label.
#include "rowitem.hpp"
+using std::enable_shared_from_this;
+using std::pair;
+
namespace pv {
namespace views {
namespace TraceView {
class TraceTreeItemOwner;
class TraceTreeItem : public RowItem,
- public std::enable_shared_from_this<TraceTreeItem>
+ public enable_shared_from_this<TraceTreeItem>
{
Q_OBJECT
Q_PROPERTY(int visual_v_offset
* Computes the vertical extents of the contents of this row item.
* @return A pair containing the minimum and maximum y-values.
*/
- virtual std::pair<int, int> v_extents() const = 0;
+ virtual pair<int, int> v_extents() const = 0;
protected:
TraceTreeItemOwner *owner_;
#include "trace.hpp"
using std::dynamic_pointer_cast;
-using std::max;
+using std::find;
using std::make_pair;
+using std::max;
using std::min;
using std::pair;
using std::set;
return items_;
}
-vector< std::shared_ptr<TraceTreeItem> >
+vector< shared_ptr<TraceTreeItem> >
TraceTreeItemOwner::trace_tree_child_items() const
{
vector< shared_ptr<TraceTreeItem> > items;
items_.clear();
}
-void TraceTreeItemOwner::add_child_item(std::shared_ptr<TraceTreeItem> item)
+void TraceTreeItemOwner::add_child_item(shared_ptr<TraceTreeItem> item)
{
assert(!item->owner());
item->set_owner(this);
extents_changed(true, true);
}
-void TraceTreeItemOwner::remove_child_item(std::shared_ptr<TraceTreeItem> item)
+void TraceTreeItemOwner::remove_child_item(shared_ptr<TraceTreeItem> item)
{
assert(item->owner() == this);
item->set_owner(nullptr);
- auto iter = std::find(items_.begin(), items_.end(), item);
+ auto iter = find(items_.begin(), items_.end(), item);
assert(iter != items_.end());
items_.erase(iter);
#include "viewitemowner.hpp"
#include "tracetreeitem.hpp"
+using std::pair;
+using std::shared_ptr;
+using std::vector;
+
namespace pv {
class Session;
/**
* Returns a list of row items owned by this object.
*/
- std::vector< std::shared_ptr<TraceTreeItem> >
+ vector< shared_ptr<TraceTreeItem> >
trace_tree_child_items() const;
/**
/**
* Adds a child item to this object.
*/
- void add_child_item(std::shared_ptr<TraceTreeItem> item);
+ void add_child_item(shared_ptr<TraceTreeItem> item);
/**
* Removes a child item from this object.
*/
- void remove_child_item(std::shared_ptr<TraceTreeItem> item);
+ void remove_child_item(shared_ptr<TraceTreeItem> item);
virtual void restack_items();
* Computes the vertical extents of the contents of this row item owner.
* @return A pair containing the minimum and maximum y-values.
*/
- std::pair<int, int> v_extents() const;
+ pair<int, int> v_extents() const;
/*
* Reassigns background color states to all its children, thereby
using std::back_inserter;
using std::copy_if;
+using std::count_if;
using std::deque;
using std::dynamic_pointer_cast;
using std::inserter;
using std::set;
using std::set_difference;
using std::shared_ptr;
+using std::stringstream;
using std::unordered_map;
using std::unordered_set;
using std::vector;
return session_;
}
-std::unordered_set< std::shared_ptr<Signal> > View::signals() const
+unordered_set< shared_ptr<Signal> > View::signals() const
{
return signals_;
}
settings.setValue("v_offset",
scrollarea_.verticalScrollBar()->sliderPosition());
- std::stringstream ss;
+ stringstream ss;
boost::archive::text_oarchive oa(ss);
oa << boost::serialization::make_nvp("offset", offset_);
settings.setValue("offset", QString::fromStdString(ss.str()));
if (settings.contains("offset")) {
util::Timestamp offset;
- std::stringstream ss;
+ stringstream ss;
ss << settings.value("offset").toString().toStdString();
boost::archive::text_iarchive ia(ss);
viewport_->update();
}
-std::shared_ptr<CursorPair> View::cursors() const
+shared_ptr<CursorPair> View::cursors() const
{
return cursors_;
}
time_item_appearance_changed(true, true);
}
-void View::remove_flag(std::shared_ptr<Flag> flag)
+void View::remove_flag(shared_ptr<Flag> flag)
{
flags_.remove(flag);
time_item_appearance_changed(true, true);
}
-vector< std::shared_ptr<Flag> > View::flags() const
+vector< shared_ptr<Flag> > View::flags() const
{
- vector< std::shared_ptr<Flag> > flags(flags_.begin(), flags_.end());
+ vector< shared_ptr<Flag> > flags(flags_.begin(), flags_.end());
stable_sort(flags.begin(), flags.end(),
[](const shared_ptr<Flag> &a, const shared_ptr<Flag> &b) {
return a->time() < b->time();
// Precision is the number of fractional digits required, not
// taking the prefix into account (and it must never be negative)
- tick_precision = std::max(ceil(log10(1 / tick_period)).convert_to<int>(), 0);
+ tick_precision = max(ceil(log10(1 / tick_period)).convert_to<int>(), 0);
tick_period_width = (tick_period / scale_).convert_to<double>();
size_t max_prevalence = 0;
TraceTreeItemOwner *prevalent_owner = nullptr;
for (TraceTreeItemOwner *owner : owners) {
- const size_t prevalence = std::count_if(
+ const size_t prevalence = count_if(
owner_list.begin(), owner_list.end(),
[&](TraceTreeItemOwner *o) { return o == owner; });
if (prevalence > max_prevalence) {
#include "flag.hpp"
#include "tracetreeitemowner.hpp"
+using std::list;
+using std::unordered_map;
+using std::unordered_set;
+using std::set;
+using std::shared_ptr;
+using std::vector;
+
namespace sigrok {
class ChannelGroup;
}
/**
* Returns the signals contained in this view.
*/
- std::unordered_set< std::shared_ptr<Signal> > signals() const;
+ unordered_set< shared_ptr<Signal> > signals() const;
virtual void clear_signals();
- virtual void add_signal(const std::shared_ptr<Signal> signal);
+ virtual void add_signal(const shared_ptr<Signal> signal);
#ifdef ENABLE_DECODE
virtual void clear_decode_signals();
- virtual void add_decode_signal(std::shared_ptr<data::SignalBase> signalbase);
+ virtual void add_decode_signal(shared_ptr<data::SignalBase> signalbase);
- virtual void remove_decode_signal(std::shared_ptr<data::SignalBase> signalbase);
+ virtual void remove_decode_signal(shared_ptr<data::SignalBase> signalbase);
#endif
/**
/**
* Gets a list of time markers.
*/
- std::vector< std::shared_ptr<TimeItem> > time_items() const;
+ vector< shared_ptr<TimeItem> > time_items() const;
/**
* Returns the view time scale in seconds per pixel.
*/
void set_scale_offset(double scale, const pv::util::Timestamp& offset);
- std::set< std::shared_ptr<pv::data::SignalData> >
- get_visible_data() const;
+ set< shared_ptr<pv::data::SignalData> > get_visible_data() const;
- std::pair<pv::util::Timestamp, pv::util::Timestamp> get_time_extents() const;
+ pair<pv::util::Timestamp, pv::util::Timestamp> get_time_extents() const;
/**
* Enables or disables coloured trace backgrounds. If they're not
/**
* Returns a reference to the pair of cursors.
*/
- std::shared_ptr<CursorPair> cursors() const;
+ shared_ptr<CursorPair> cursors() const;
/**
* Adds a new flag at a specified time.
/**
* Removes a flag from the list.
*/
- void remove_flag(std::shared_ptr<Flag> flag);
+ void remove_flag(shared_ptr<Flag> flag);
/**
* Gets the list of flags.
*/
- std::vector< std::shared_ptr<Flag> > flags() const;
+ vector< shared_ptr<Flag> > flags() const;
const QPoint& hover_point() const;
void update_layout();
TraceTreeItemOwner* find_prevalent_trace_group(
- const std::shared_ptr<sigrok::ChannelGroup> &group,
- const std::unordered_map<std::shared_ptr<data::SignalBase>,
- std::shared_ptr<Signal> > &signal_map);
+ const shared_ptr<sigrok::ChannelGroup> &group,
+ const unordered_map<shared_ptr<data::SignalBase>,
+ shared_ptr<Signal> > &signal_map);
- static std::vector< std::shared_ptr<Trace> >
+ static vector< shared_ptr<Trace> >
extract_new_traces_for_channels(
- const std::vector< std::shared_ptr<sigrok::Channel> > &channels,
- const std::unordered_map<std::shared_ptr<data::SignalBase>,
- std::shared_ptr<Signal> > &signal_map,
- std::set< std::shared_ptr<Trace> > &add_list);
+ const vector< shared_ptr<sigrok::Channel> > &channels,
+ const unordered_map<shared_ptr<data::SignalBase>,
+ shared_ptr<Signal> > &signal_map,
+ set< shared_ptr<Trace> > &add_list);
void determine_time_unit();
Ruler *ruler_;
Header *header_;
- std::unordered_set< std::shared_ptr<Signal> > signals_;
+ unordered_set< shared_ptr<Signal> > signals_;
#ifdef ENABLE_DECODE
- std::vector< std::shared_ptr<DecodeTrace> > decode_traces_;
+ vector< shared_ptr<DecodeTrace> > decode_traces_;
#endif
CustomAbstractScrollArea scrollarea_;
util::TimeUnit time_unit_;
bool show_cursors_;
- std::shared_ptr<CursorPair> cursors_;
+ shared_ptr<CursorPair> cursors_;
- std::list< std::shared_ptr<Flag> > flags_;
+ list< shared_ptr<Flag> > flags_;
char next_flag_text_;
- std::vector< std::shared_ptr<TriggerMarker> > trigger_markers_;
+ vector< shared_ptr<TriggerMarker> > trigger_markers_;
QPoint hover_point_;
#include <pv/session.hpp>
+using std::dynamic_pointer_cast;
+using std::forward_iterator_tag;
+using std::shared_ptr;
+using std::stack;
+
namespace pv {
namespace views {
namespace TraceView {
{
public:
typedef typename Owner::item_list::const_iterator child_iterator;
- typedef std::shared_ptr<Item> value_type;
+ typedef shared_ptr<Item> value_type;
typedef ptrdiff_t difference_type;
typedef value_type pointer;
typedef const value_type& reference;
- typedef std::forward_iterator_tag iterator_category;
+ typedef forward_iterator_tag iterator_category;
public:
ViewItemIterator(Owner *owner) :
}
ViewItemIterator<Owner, Item>& operator++() {
- using std::dynamic_pointer_cast;
- using std::shared_ptr;
-
assert(!owner_stack_.empty());
assert(!iter_stack_.empty());
}
private:
- std::stack<Owner*> owner_stack_;
- std::stack<child_iterator> iter_stack_;
+ stack<Owner*> owner_stack_;
+ stack<child_iterator> iter_stack_;
};
template<class Owner, class Item>
#include "viewitemiterator.hpp"
+using std::dynamic_pointer_cast;
+using std::shared_ptr;
+using std::vector;
+
namespace pv {
class Session;
class ViewItemOwner
{
public:
- typedef std::vector< std::shared_ptr<ViewItem> > item_list;
+ typedef vector< shared_ptr<ViewItem> > item_list;
typedef ViewItemIterator<ViewItemOwner, ViewItem> iterator;
typedef ViewItemIterator<const ViewItemOwner, ViewItem> const_iterator;
* Creates a list of descendant signals filtered by type.
*/
template<class T>
- std::vector< std::shared_ptr<T> > list_by_type() {
- std::vector< std::shared_ptr<T> > items;
+ vector< shared_ptr<T> > list_by_type() {
+ vector< shared_ptr<T> > items;
for (const auto &r : *this) {
- std::shared_ptr<T> p = std::dynamic_pointer_cast<T>(r);
+ shared_ptr<T> p = dynamic_pointer_cast<T>(r);
if (p)
items.push_back(p);
}
vector< shared_ptr<ViewItem> > Viewport::items()
{
vector< shared_ptr<ViewItem> > items;
- const std::vector< shared_ptr<ViewItem> > view_items(
+ const vector< shared_ptr<ViewItem> > view_items(
view_.list_by_type<ViewItem>());
copy(view_items.begin(), view_items.end(), back_inserter(items));
const vector< shared_ptr<TimeItem> > time_items(view_.time_items());
#include "pv/util.hpp"
#include "viewwidget.hpp"
+using std::shared_ptr;
+using std::vector;
+
class QPainter;
class QPaintEvent;
class Session;
* @param item The item that is being hovered over, or @c nullptr
* if no view item is being hovered over.
*/
- void item_hover(const std::shared_ptr<ViewItem> &item);
+ void item_hover(const shared_ptr<ViewItem> &item);
/**
* Gets the first view item which has a hit-box that contains @c pt .
* @return the view item that has been found, or and empty
* @c shared_ptr if no item was found.
*/
- std::shared_ptr<ViewItem> get_mouse_over_item(const QPoint &pt);
+ shared_ptr<ViewItem> get_mouse_over_item(const QPoint &pt);
/**
* Sets this item into the dragged state.
/**
* Gets the items in the view widget.
*/
- std::vector< std::shared_ptr<ViewItem> > items();
+ vector< shared_ptr<ViewItem> > items();
/**
* Handles touch begin update and end events.
#include <QWidget>
+using std::shared_ptr;
+using std::vector;
+
class QTouchEvent;
namespace pv {
* if no view item is being hovered over.
* @remarks the default implementation does nothing.
*/
- virtual void item_hover(
- const std::shared_ptr<ViewItem> &item);
+ virtual void item_hover(const shared_ptr<ViewItem> &item);
/**
* Indicates the event an a view item has been clicked.
* @param item the view item that has been clicked.
* @remarks the default implementation does nothing.
*/
- virtual void item_clicked(
- const std::shared_ptr<ViewItem> &item);
+ virtual void item_clicked(const shared_ptr<ViewItem> &item);
/**
* Returns true if the selection of row items allows dragging.
/**
* Gets the items in the view widget.
*/
- virtual std::vector< std::shared_ptr<ViewItem> > items() = 0;
+ virtual vector< shared_ptr<ViewItem> > items() = 0;
/**
* Gets the first view item which has a hit-box that contains @c pt .
* @return the view item that has been found, or and empty
* @c shared_ptr if no item was found.
*/
- virtual std::shared_ptr<ViewItem> get_mouse_over_item(
- const QPoint &pt) = 0;
+ virtual shared_ptr<ViewItem> get_mouse_over_item(const QPoint &pt) = 0;
/**
* Handles left mouse button press events.
pv::views::TraceView::View &view_;
QPoint mouse_point_;
QPoint mouse_down_point_;
- std::shared_ptr<ViewItem> mouse_down_item_;
+ shared_ptr<ViewItem> mouse_down_item_;
bool item_dragging_;
};
#include <pv/data/signalbase.hpp>
#include <pv/util.hpp>
+using std::shared_ptr;
+
namespace pv {
class Session;
#ifdef ENABLE_DECODE
virtual void clear_decode_signals();
- virtual void add_decode_signal(std::shared_ptr<data::SignalBase> signalbase);
+ virtual void add_decode_signal(shared_ptr<data::SignalBase> signalbase);
- virtual void remove_decode_signal(std::shared_ptr<data::SignalBase> signalbase);
+ virtual void remove_decode_signal(shared_ptr<data::SignalBase> signalbase);
#endif
virtual void save_settings(QSettings &settings) const;
#include <QSignalMapper>
#include <QToolButton>
+using std::list;
+using std::shared_ptr;
+using std::vector;
+using std::weak_ptr;
+
struct srd_decoder;
namespace pv {
/**
* Returns a reference to the selected device.
*/
- std::shared_ptr<devices::Device> selected_device();
+ shared_ptr<devices::Device> selected_device();
/**
* Sets the current list of devices.
* @param selected_device the currently active device.
*/
void set_device_list(
- const std::list< std::shared_ptr<devices::Device> > &devices,
- std::shared_ptr<devices::Device> selected);
+ const list< shared_ptr<devices::Device> > &devices,
+ shared_ptr<devices::Device> selected);
/**
* Sets the current device to "no device". Useful for when a selected
QMenu menu_;
QSignalMapper mapper_;
- std::shared_ptr<devices::Device> selected_device_;
- std::vector< std::weak_ptr<devices::Device> > devices_;
+ shared_ptr<devices::Device> selected_device_;
+ vector< weak_ptr<devices::Device> > devices_;
QString device_tooltip_;
};
using std::pair;
using std::string;
using std::shared_ptr;
+using std::vector;
using sigrok::Context;
using sigrok::OutputFormat;
namespace widgets {
ExportMenu::ExportMenu(QWidget *parent, shared_ptr<Context> context,
- std::vector<QAction *>open_actions) :
+ vector<QAction *>open_actions) :
QMenu(parent),
context_(context),
mapper_(this)
#include <QMenu>
#include <QSignalMapper>
+using std::shared_ptr;
+using std::vector;
+
namespace sigrok {
class Context;
class OutputFormat;
Q_OBJECT;
public:
- ExportMenu(QWidget *parent, std::shared_ptr<sigrok::Context> context,
- std::vector<QAction *>open_actions = std::vector<QAction *>());
+ ExportMenu(QWidget *parent, shared_ptr<sigrok::Context> context,
+ vector<QAction *>open_actions = vector<QAction *>());
private Q_SLOTS:
void on_action(QObject *action);
Q_SIGNALS:
- void format_selected(std::shared_ptr<sigrok::OutputFormat> format);
+ void format_selected(shared_ptr<sigrok::OutputFormat> format);
private:
- std::shared_ptr<sigrok::Context> context_;
+ shared_ptr<sigrok::Context> context_;
QSignalMapper mapper_;
};
#include <QMenu>
#include <QSignalMapper>
+using std::shared_ptr;
+
namespace sigrok {
class Context;
class InputFormat;
Q_OBJECT;
public:
- ImportMenu(QWidget *parent, std::shared_ptr<sigrok::Context> context,
+ ImportMenu(QWidget *parent, shared_ptr<sigrok::Context> context,
QAction *open_action = nullptr);
private Q_SLOTS:
void on_action(QObject *action);
Q_SIGNALS:
- void format_selected(std::shared_ptr<sigrok::InputFormat> format);
+ void format_selected(shared_ptr<sigrok::InputFormat> format);
private:
- std::shared_ptr<sigrok::Context> context_;
+ shared_ptr<sigrok::Context> context_;
QSignalMapper mapper_;
};
#include <boost/test/unit_test.hpp>
#include "test/test.hpp"
-std::ostream& operator<<(std::ostream& stream, const QString& str)
+using std::ostream;
+
+ostream& operator<<(ostream& stream, const QString& str)
{
return stream << str.toUtf8().data();
}
#include <QString>
-std::ostream& operator<<(std::ostream& stream, const QString& str);
+using std::ostream;
+
+ostream& operator<<(ostream& stream, const QString& str);
#endif
using namespace pv::util;
using ts = pv::util::Timestamp;
+using std::bind;
+
namespace {
QChar mu = QChar(0x03BC);
{
using namespace std::placeholders;
- auto fmt = std::bind(format_time_minutes, _1, _2, true);
+ auto fmt = bind(format_time_minutes, _1, _2, true);
BOOST_CHECK_EQUAL(fmt(ts( 0), 0), "+0:00");
BOOST_CHECK_EQUAL(fmt(ts( 1), 0), "+0:01");