+private:
+ /* Weak pointer for shared_from_this() implementation. */
+ weak_ptr<Class> _weak_this;
+
+ static void reset_parent(Class *object)
+ {
+ if (!object->_parent)
+ throw Error(SR_ERR_BUG);
+ object->_parent.reset();
+ }
+
/* Note, this implementation will create a new smart_ptr if none exists. */
shared_ptr<Class> shared_from_this()
{
/* Note, this implementation will create a new smart_ptr if none exists. */
shared_ptr<Class> shared_from_this()
{
- shared_ptr<Class> get_shared_pointer(Parent *parent)
- {
- if (!parent)
- throw Error(SR_ERR_BUG);
- return get_shared_pointer(parent->shared_from_this());
- }
-protected:
- static void reset_parent(Class *object)
- {
- if (!object->_parent)
- throw Error(SR_ERR_BUG);
- object->_parent.reset();
- }
-
- Struct *_structure;
-
- explicit ParentOwned(Struct *structure) :
- _structure(structure)
+public:
+ /* Get parent object that owns this object. */
+ shared_ptr<Parent> parent()
shared_ptr<Class> shared_from_this()
{
auto shared = enable_shared_from_this<Class>::shared_from_this();
shared_ptr<Class> shared_from_this()
{
auto shared = enable_shared_from_this<Class>::shared_from_this();
{
public:
/** Create new context */
static shared_ptr<Context> create();
/** libsigrok package version. */
{
public:
/** Create new context */
static shared_ptr<Context> create();
/** libsigrok package version. */
/** Available hardware drivers, indexed by name. */
map<string, shared_ptr<Driver> > drivers();
/** Available input formats, indexed by name. */
/** Available hardware drivers, indexed by name. */
map<string, shared_ptr<Driver> > drivers();
/** Available input formats, indexed by name. */
/** Available output formats, indexed by name. */
map<string, shared_ptr<OutputFormat> > output_formats();
/** Current log level. */
/** Available output formats, indexed by name. */
map<string, shared_ptr<OutputFormat> > output_formats();
/** Current log level. */
/** Open an input stream based on header data.
* @param header Initial data from stream. */
shared_ptr<Input> open_stream(string header);
/** Open an input stream based on header data.
* @param header Initial data from stream. */
shared_ptr<Input> open_stream(string header);
map<string, Driver *> _drivers;
map<string, InputFormat *> _input_formats;
map<string, OutputFormat *> _output_formats;
map<string, Driver *> _drivers;
map<string, InputFormat *> _input_formats;
map<string, OutputFormat *> _output_formats;
/** Set configuration for the given key to a specified value.
* @param key ConfigKey to set.
* @param value Value to set. */
void config_set(const ConfigKey *key, const Glib::VariantBase &value);
/** Enumerate available values for the given configuration key.
* @param key ConfigKey to enumerate values for. */
/** Set configuration for the given key to a specified value.
* @param key ConfigKey to set.
* @param value Value to set. */
void config_set(const ConfigKey *key, const Glib::VariantBase &value);
/** Enumerate available values for the given configuration key.
* @param key ConfigKey to enumerate values for. */
/** Enumerate available keys, according to a given index key. */
map<const ConfigKey *, set<Capability> > config_keys(const ConfigKey *key);
/** Check for a key in the list from a given index key. */
/** Enumerate available keys, according to a given index key. */
map<const ConfigKey *, set<Capability> > config_keys(const ConfigKey *key);
/** Check for a key in the list from a given index key. */
/** Scan for devices and return a list of devices found.
* @param options Mapping of (ConfigKey, value) pairs. */
vector<shared_ptr<HardwareDevice> > scan(
const map<const ConfigKey *, Glib::VariantBase> &options = {});
/** Scan for devices and return a list of devices found.
* @param options Mapping of (ConfigKey, value) pairs. */
vector<shared_ptr<HardwareDevice> > scan(
const map<const ConfigKey *, Glib::VariantBase> &options = {});
/** List of the channels available on this device. */
vector<shared_ptr<Channel> > channels();
/** Channel groups available on this device, indexed by name. */
/** List of the channels available on this device. */
vector<shared_ptr<Channel> > channels();
/** Channel groups available on this device, indexed by name. */
~Device();
virtual shared_ptr<Device> get_shared_from_this() = 0;
shared_ptr<Channel> get_channel(struct sr_channel *ptr);
~Device();
virtual shared_ptr<Device> get_shared_from_this() = 0;
shared_ptr<Channel> get_channel(struct sr_channel *ptr);
struct sr_dev_inst *_structure;
map<struct sr_channel *, Channel *> _channels;
struct sr_dev_inst *_structure;
map<struct sr_channel *, Channel *> _channels;
map<string, ChannelGroup *> _channel_groups;
/** Deleter needed to allow shared_ptr use with protected destructor. */
class Deleter
map<string, ChannelGroup *> _channel_groups;
/** Deleter needed to allow shared_ptr use with protected destructor. */
class Deleter
/** A real hardware device, connected via a driver */
class SR_API HardwareDevice :
/** A real hardware device, connected via a driver */
class SR_API HardwareDevice :
HardwareDevice(shared_ptr<Driver> driver, struct sr_dev_inst *structure);
~HardwareDevice();
shared_ptr<Device> get_shared_from_this();
HardwareDevice(shared_ptr<Driver> driver, struct sr_dev_inst *structure);
~HardwareDevice();
shared_ptr<Device> get_shared_from_this();
/** A virtual device, created by the user */
class SR_API UserDevice :
/** A virtual device, created by the user */
class SR_API UserDevice :
public Device
{
public:
/** Add a new channel to this device. */
shared_ptr<Channel> add_channel(unsigned int index, const ChannelType *type, string name);
public Device
{
public:
/** Add a new channel to this device. */
shared_ptr<Channel> add_channel(unsigned int index, const ChannelType *type, string name);
UserDevice(string vendor, string model, string version);
~UserDevice();
shared_ptr<Device> get_shared_from_this();
UserDevice(string vendor, string model, string version);
~UserDevice();
shared_ptr<Device> get_shared_from_this();
/** Set the name of this channel. *
* @param name Name string to set. */
void set_name(string name);
/** Type of this channel. */
/** Set the name of this channel. *
* @param name Name string to set. */
void set_name(string name);
/** Type of this channel. */
/** Set the enabled status of this channel.
* @param value Boolean value to set. */
void set_enabled(bool value);
/** Get the index number of this channel. */
/** Set the enabled status of this channel.
* @param value Boolean value to set. */
void set_enabled(bool value);
/** Get the index number of this channel. */
/** A group of channels on a device, which share some configuration */
class SR_API ChannelGroup :
/** A group of channels on a device, which share some configuration */
class SR_API ChannelGroup :
- public ParentOwned<ChannelGroup, Device, struct sr_channel_group>,
+ public ParentOwned<ChannelGroup, Device>,
ChannelGroup(Device *device, struct sr_channel_group *structure);
~ChannelGroup();
vector<Channel *> _channels;
ChannelGroup(Device *device, struct sr_channel_group *structure);
~ChannelGroup();
vector<Channel *> _channels;
/** List of the stages in this trigger. */
vector<shared_ptr<TriggerStage> > stages();
/** Add a new stage to this trigger. */
shared_ptr<TriggerStage> add_stage();
/** List of the stages in this trigger. */
vector<shared_ptr<TriggerStage> > stages();
/** Add a new stage to this trigger. */
shared_ptr<TriggerStage> add_stage();
/** List of match conditions on this stage. */
vector<shared_ptr<TriggerMatch> > matches();
/** Add a new match condition to this stage.
/** List of match conditions on this stage. */
vector<shared_ptr<TriggerMatch> > matches();
/** Add a new match condition to this stage.
* @param type TriggerMatchType to apply.
* @param value Threshold value. */
void add_match(shared_ptr<Channel> channel, const TriggerMatchType *type, float value);
* @param type TriggerMatchType to apply.
* @param value Threshold value. */
void add_match(shared_ptr<Channel> channel, const TriggerMatchType *type, float value);
public:
void run(const struct sr_dev_inst *sdi,
const struct sr_datafeed_packet *pkt);
public:
void run(const struct sr_dev_inst *sdi,
const struct sr_datafeed_packet *pkt);
DatafeedCallbackFunction _callback;
DatafeedCallbackData(Session *session,
DatafeedCallbackFunction callback);
DatafeedCallbackFunction _callback;
DatafeedCallbackData(Session *session,
DatafeedCallbackFunction callback);
- public ParentOwned<SessionDevice, Session, struct sr_dev_inst>,
+ public ParentOwned<SessionDevice, Session>,
* @param trigger Trigger object to use. */
void set_trigger(shared_ptr<Trigger> trigger);
/** Get filename this session was loaded from. */
* @param trigger Trigger object to use. */
void set_trigger(shared_ptr<Trigger> trigger);
/** Get filename this session was loaded from. */
explicit Session(shared_ptr<Context> context);
Session(shared_ptr<Context> context, string filename);
~Session();
shared_ptr<Device> get_device(const struct sr_dev_inst *sdi);
explicit Session(shared_ptr<Context> context);
Session(shared_ptr<Context> context, string filename);
~Session();
shared_ptr<Device> get_device(const struct sr_dev_inst *sdi);
const shared_ptr<Context> _context;
map<const struct sr_dev_inst *, SessionDevice *> _owned_devices;
map<const struct sr_dev_inst *, shared_ptr<Device> > _other_devices;
const shared_ptr<Context> _context;
map<const struct sr_dev_inst *, SessionDevice *> _owned_devices;
map<const struct sr_dev_inst *, shared_ptr<Device> > _other_devices;
Packet(shared_ptr<Device> device,
const struct sr_datafeed_packet *structure);
~Packet();
Packet(shared_ptr<Device> device,
const struct sr_datafeed_packet *structure);
~Packet();
- public ParentOwned<Header, Packet, const struct sr_datafeed_header>,
+ public ParentOwned<Header, Packet>,
- public ParentOwned<Meta, Packet, const struct sr_datafeed_meta>,
+ public ParentOwned<Meta, Packet>,
- public ParentOwned<Logic, Packet, const struct sr_datafeed_logic>,
+ public ParentOwned<Logic, Packet>,
- public ParentOwned<Analog, Packet, const struct sr_datafeed_analog>,
+ public ParentOwned<Analog, Packet>,
/** Channels for which this packet contains data. */
vector<shared_ptr<Channel> > channels();
/** Measured quantity of the samples in this packet. */
/** Channels for which this packet contains data. */
vector<shared_ptr<Channel> > channels();
/** Measured quantity of the samples in this packet. */
/** A list of preferred file name extensions for this file format.
* @note This list is a recommendation only. */
/** A list of preferred file name extensions for this file format.
* @note This list is a recommendation only. */
/** Options supported by this input format. */
map<string, shared_ptr<Option> > options();
/** Create an input using this input format.
* @param options Mapping of (option name, value) pairs. */
shared_ptr<Input> create_input(const map<string, Glib::VariantBase> &options = {});
/** Options supported by this input format. */
map<string, shared_ptr<Option> > options();
/** Create an input using this input format.
* @param options Mapping of (option name, value) pairs. */
shared_ptr<Input> create_input(const map<string, Glib::VariantBase> &options = {});
void send(void *data, size_t length);
/** Signal end of input data. */
void end();
void send(void *data, size_t length);
/** Signal end of input data. */
void end();
- public ParentOwned<InputDevice, Input, struct sr_dev_inst>,
+ public ParentOwned<InputDevice, Input>,
InputDevice(shared_ptr<Input> input, struct sr_dev_inst *sdi);
~InputDevice();
shared_ptr<Device> get_shared_from_this();
InputDevice(shared_ptr<Input> input, struct sr_dev_inst *sdi);
~InputDevice();
shared_ptr<Device> get_shared_from_this();
Option(const struct sr_option *structure,
shared_ptr<const struct sr_option *> structure_array);
~Option();
Option(const struct sr_option *structure,
shared_ptr<const struct sr_option *> structure_array);
~Option();
/** A list of preferred file name extensions for this file format.
* @note This list is a recommendation only. */
/** A list of preferred file name extensions for this file format.
* @note This list is a recommendation only. */
/** Options supported by this output format. */
map<string, shared_ptr<Option> > options();
/** Create an output using this format.
/** Options supported by this output format. */
map<string, shared_ptr<Option> > options();
/** Create an output using this format.
{
public:
/** Update output with data from the given packet.
* @param packet Packet to handle. */
string receive(shared_ptr<Packet> packet);
{
public:
/** Update output with data from the given packet.
* @param packet Packet to handle. */
string receive(shared_ptr<Packet> packet);
Output(shared_ptr<OutputFormat> format, shared_ptr<Device> device);
Output(shared_ptr<OutputFormat> format,
shared_ptr<Device> device, const map<string, Glib::VariantBase> &options);
Output(string filename, shared_ptr<OutputFormat> format,
shared_ptr<Device> device, const map<string, Glib::VariantBase> &options);
~Output();
Output(shared_ptr<OutputFormat> format, shared_ptr<Device> device);
Output(shared_ptr<OutputFormat> format,
shared_ptr<Device> device, const map<string, Glib::VariantBase> &options);
Output(string filename, shared_ptr<OutputFormat> format,
shared_ptr<Device> device, const map<string, Glib::VariantBase> &options);
~Output();
const shared_ptr<OutputFormat> _format;
const shared_ptr<Device> _device;
const map<string, Glib::VariantBase> _options;
const shared_ptr<OutputFormat> _format;
const shared_ptr<Device> _device;
const map<string, Glib::VariantBase> _options;