2 * This file is part of the libsigrok project.
4 * Copyright (C) 2013-2014 Martin Ling <martin-sigrok@earth.li>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 @mainpage API Reference
27 The sigrok++ API provides an object-oriented C++ interface to the functionality
28 in libsigrok, including automatic memory and resource management.
30 It is built on top of the public libsigrok C API, and is designed to be used as
31 a standalone alternative API. Programs should not mix usage of the C and C++
32 APIs; the C++ interface code needs to have full control of all C API calls for
33 resources to be managed correctly.
38 All runtime objects created through the C++ API are passed and accessed via
39 shared pointers, using the C++11 std::shared_ptr implementation. This means
40 that a reference count is kept for each object.
42 Shared pointers can be copied and assigned in a user's program, automatically
43 updating their reference count and deleting objects when they are no longer in
44 use. The C++ interface code also keeps track of internal dependencies between
45 libsigrok resources, and ensures that objects are not prematurely deleted when
46 their resources are in use by other objects.
48 This means that management of sigrok++ objects and their underlying libsigrok
49 resources can be treated as fully automatic. As long as all shared pointers to
50 objects are deleted or reassigned when no longer in use, all underlying
51 resources will be released at the right time.
56 Usage of the C++ API needs to begin with a call to sigrok::Context::create().
57 This will create the global libsigrok context and returns a shared pointer to
58 the sigrok::Context object. Methods on this object provide access to the
59 hardware drivers, input and output formats supported by the library, as well
60 as means of creating other objects such as sessions and triggers.
65 When any libsigrok C API call returns an error, a sigrok::Error exception is
66 raised, which provides access to the error code and description.
73 #include "libsigrok/libsigrok.h"
74 #include <glibmm-2.4/glibmm.h>
87 /* Forward declarations */
92 class SR_API HardwareDevice;
94 class SR_API EventSource;
96 class SR_API ConfigKey;
97 class SR_API InputFormat;
98 class SR_API OutputFormat;
99 class SR_API LogLevel;
100 class SR_API ChannelGroup;
101 class SR_API Trigger;
102 class SR_API TriggerStage;
103 class SR_API TriggerMatch;
104 class SR_API TriggerMatchType;
105 class SR_API ChannelType;
107 class SR_API PacketPayload;
108 class SR_API PacketType;
109 class SR_API Quantity;
111 class SR_API QuantityFlag;
113 class SR_API InputDevice;
115 class SR_API DataType;
118 /** Exception thrown when an error code is returned by any libsigrok call. */
119 class SR_API Error: public exception
125 const char *what() const throw();
128 /* Base template for classes whose resources are owned by a parent object. */
129 template <class Class, class Parent, typename Struct>
130 class SR_API ParentOwned
133 /* Parent object which owns this child object's underlying structure.
135 This shared pointer will be null when this child is unused, but
136 will be assigned to point to the parent before any shared pointer
137 to this child is handed out to the user.
139 When the reference count of this child falls to zero, this shared
140 pointer to its parent is reset by a custom deleter on the child's
143 This strategy ensures that the destructors for both the child and
144 the parent are called at the correct time, i.e. only when all
145 references to both the parent and all its children are gone. */
146 shared_ptr<Parent> _parent;
148 /* Weak pointer for shared_from_this() implementation. */
149 weak_ptr<Class> _weak_this;
152 /* Note, this implementation will create a new smart_ptr if none exists. */
153 shared_ptr<Class> shared_from_this()
155 shared_ptr<Class> shared;
157 if (!(shared = _weak_this.lock()))
159 shared = shared_ptr<Class>((Class *) this, reset_parent);
166 shared_ptr<Class> get_shared_pointer(shared_ptr<Parent> parent)
169 throw Error(SR_ERR_BUG);
170 this->_parent = parent;
171 return shared_from_this();
174 shared_ptr<Class> get_shared_pointer(Parent *parent)
177 throw Error(SR_ERR_BUG);
178 return get_shared_pointer(parent->shared_from_this());
181 static void reset_parent(Class *object)
183 if (!object->_parent)
184 throw Error(SR_ERR_BUG);
185 object->_parent.reset();
190 ParentOwned<Class, Parent, Struct>(Struct *structure) :
191 _structure(structure)
196 /* Base template for classes whose resources are owned by the user. */
197 template <class Class, typename Struct>
198 class SR_API UserOwned : public enable_shared_from_this<Class>
201 shared_ptr<Class> shared_from_this()
203 auto shared = enable_shared_from_this<Class>::shared_from_this();
205 throw Error(SR_ERR_BUG);
211 UserOwned<Class, Struct>(Struct *structure) :
212 _structure(structure)
216 /* Deleter needed to allow shared_ptr use with protected destructor. */
220 void operator()(Class *object) { delete object; }
224 /** Type of log callback */
225 typedef function<void(const LogLevel *, string message)> LogCallbackFunction;
227 /** The global libsigrok context */
228 class SR_API Context : public UserOwned<Context, struct sr_context>
231 /** Create new context */
232 static shared_ptr<Context> create();
233 /** libsigrok package version. */
234 string package_version();
235 /** libsigrok library version. */
236 string lib_version();
237 /** Available hardware drivers, indexed by name. */
238 map<string, shared_ptr<Driver> > drivers();
239 /** Available input formats, indexed by name. */
240 map<string, shared_ptr<InputFormat> > input_formats();
241 /** Available output formats, indexed by name. */
242 map<string, shared_ptr<OutputFormat> > output_formats();
243 /** Current log level. */
244 const LogLevel *log_level();
245 /** Set the log level.
246 * @param level LogLevel to use. */
247 void set_log_level(const LogLevel *level);
248 /** Current log domain. */
250 /** Set the log domain.
251 * @param value Log domain prefix string. */
252 void set_log_domain(string value);
253 /** Set the log callback.
254 * @param callback Callback of the form callback(LogLevel, string). */
255 void set_log_callback(LogCallbackFunction callback);
256 /** Set the log callback to the default handler. */
257 void set_log_callback_default();
258 /** Create a new session. */
259 shared_ptr<Session> create_session();
260 /** Load a saved session.
261 * @param filename File name string. */
262 shared_ptr<Session> load_session(string filename);
263 /** Create a new trigger.
264 * @param name Name string for new trigger. */
265 shared_ptr<Trigger> create_trigger(string name);
266 /** Open an input file.
267 * @param filename File name string. */
268 shared_ptr<Input> open_file(string filename);
269 /** Open an input stream based on header data.
270 * @param header Initial data from stream. */
271 shared_ptr<Input> open_stream(string header);
273 map<string, Driver *> _drivers;
274 map<string, InputFormat *> _input_formats;
275 map<string, OutputFormat *> _output_formats;
277 LogCallbackFunction _log_callback;
280 friend class Deleter;
281 friend class Session;
291 /** An object that can be configured. */
292 class SR_API Configurable
295 /** Read configuration for the given key.
296 * @param key ConfigKey to read. */
297 Glib::VariantBase config_get(const ConfigKey *key);
298 /** Set configuration for the given key to a specified value.
299 * @param key ConfigKey to set.
300 * @param value Value to set. */
301 void config_set(const ConfigKey *key, Glib::VariantBase value);
302 /** Enumerate available values for the given configuration key.
303 * @param key ConfigKey to enumerate values for. */
304 Glib::VariantContainerBase config_list(const ConfigKey *key);
305 /** Enumerate available keys, according to a given index key. */
306 map<const ConfigKey *, set<Capability> > config_keys(const ConfigKey *key);
307 /** Check for a key in the list from a given index key. */
308 bool config_check(const ConfigKey *key, const ConfigKey *index_key);
311 struct sr_dev_driver *driver,
312 struct sr_dev_inst *sdi,
313 struct sr_channel_group *channel_group);
314 virtual ~Configurable();
315 struct sr_dev_driver *config_driver;
316 struct sr_dev_inst *config_sdi;
317 struct sr_channel_group *config_channel_group;
320 /** A hardware driver provided by the library */
321 class SR_API Driver :
322 public ParentOwned<Driver, Context, struct sr_dev_driver>,
326 /** Name of this driver. */
328 /** Long name for this driver. */
330 /** Scan for devices and return a list of devices found.
331 * @param options Mapping of (ConfigKey, value) pairs. */
332 vector<shared_ptr<HardwareDevice> > scan(
333 map<const ConfigKey *, Glib::VariantBase> options =
334 map<const ConfigKey *, Glib::VariantBase>());
337 vector<HardwareDevice *> _devices;
338 Driver(struct sr_dev_driver *structure);
340 friend class Context;
341 friend class HardwareDevice;
342 friend class ChannelGroup;
345 /** A generic device, either hardware or virtual */
346 class SR_API Device : public Configurable
349 /** Description identifying this device. */
350 string description();
351 /** Vendor name for this device. */
353 /** Model name for this device. */
355 /** Version string for this device. */
357 /** List of the channels available on this device. */
358 vector<shared_ptr<Channel> > channels();
359 /** Channel groups available on this device, indexed by name. */
360 map<string, shared_ptr<ChannelGroup> > channel_groups();
366 Device(struct sr_dev_inst *structure);
368 virtual shared_ptr<Device> get_shared_from_this() = 0;
369 shared_ptr<Channel> get_channel(struct sr_channel *ptr);
370 struct sr_dev_inst *_structure;
371 map<struct sr_channel *, Channel *> _channels;
372 map<string, ChannelGroup *> _channel_groups;
373 /** Deleter needed to allow shared_ptr use with protected destructor. */
377 void operator()(Device *device) { delete device; }
379 friend class Deleter;
380 friend class Session;
381 friend class Channel;
382 friend class ChannelGroup;
387 /** A real hardware device, connected via a driver */
388 class SR_API HardwareDevice :
389 public UserOwned<HardwareDevice, struct sr_dev_inst>,
393 /** Driver providing this device. */
394 shared_ptr<Driver> driver();
396 HardwareDevice(shared_ptr<Driver> driver, struct sr_dev_inst *structure);
398 shared_ptr<Device> get_shared_from_this();
399 shared_ptr<Driver> _driver;
400 /** Deleter needed to allow shared_ptr use with protected destructor. */
404 void operator()(HardwareDevice *device) { delete device; }
406 friend class Deleter;
408 friend class ChannelGroup;
411 /** A channel on a device */
412 class SR_API Channel :
413 public ParentOwned<Channel, Device, struct sr_channel>
416 /** Current name of this channel. */
418 /** Set the name of this channel. *
419 * @param name Name string to set. */
420 void set_name(string name);
421 /** Type of this channel. */
422 const ChannelType *type();
423 /** Enabled status of this channel. */
425 /** Set the enabled status of this channel.
426 * @param value Boolean value to set. */
427 void set_enabled(bool value);
428 /** Get the index number of this channel. */
429 unsigned int index();
431 Channel(struct sr_channel *structure);
433 const ChannelType * const _type;
435 friend class ChannelGroup;
436 friend class Session;
437 friend class TriggerStage;
440 /** A group of channels on a device, which share some configuration */
441 class SR_API ChannelGroup :
442 public ParentOwned<ChannelGroup, Device, struct sr_channel_group>,
446 /** Name of this channel group. */
448 /** List of the channels in this group. */
449 vector<shared_ptr<Channel> > channels();
451 ChannelGroup(Device *device, struct sr_channel_group *structure);
453 vector<Channel *> _channels;
457 /** A trigger configuration */
458 class SR_API Trigger : public UserOwned<Trigger, struct sr_trigger>
461 /** Name of this trigger configuration. */
463 /** List of the stages in this trigger. */
464 vector<shared_ptr<TriggerStage> > stages();
465 /** Add a new stage to this trigger. */
466 shared_ptr<TriggerStage> add_stage();
468 Trigger(shared_ptr<Context> context, string name);
470 shared_ptr<Context> _context;
471 vector<TriggerStage *> _stages;
472 friend class Deleter;
473 friend class Context;
474 friend class Session;
477 /** A stage in a trigger configuration */
478 class SR_API TriggerStage :
479 public ParentOwned<TriggerStage, Trigger, struct sr_trigger_stage>
482 /** Index number of this stage. */
484 /** List of match conditions on this stage. */
485 vector<shared_ptr<TriggerMatch> > matches();
486 /** Add a new match condition to this stage.
487 * @param channel Channel to match on.
488 * @param type TriggerMatchType to apply. */
489 void add_match(shared_ptr<Channel> channel, const TriggerMatchType *type);
490 /** Add a new match condition to this stage.
491 * @param channel Channel to match on.
492 * @param type TriggerMatchType to apply.
493 * @param value Threshold value. */
494 void add_match(shared_ptr<Channel> channel, const TriggerMatchType *type, float value);
496 vector<TriggerMatch *> _matches;
497 TriggerStage(struct sr_trigger_stage *structure);
499 friend class Trigger;
502 /** A match condition in a trigger configuration */
503 class SR_API TriggerMatch :
504 public ParentOwned<TriggerMatch, TriggerStage, struct sr_trigger_match>
507 /** Channel this condition matches on. */
508 shared_ptr<Channel> channel();
509 /** Type of match. */
510 const TriggerMatchType *type();
511 /** Threshold value. */
514 TriggerMatch(struct sr_trigger_match *structure, shared_ptr<Channel> channel);
516 shared_ptr<Channel> _channel;
517 friend class TriggerStage;
520 /** Type of datafeed callback */
521 typedef function<void(shared_ptr<Device>, shared_ptr<Packet>)>
522 DatafeedCallbackFunction;
524 /* Data required for C callback function to call a C++ datafeed callback */
525 class SR_PRIV DatafeedCallbackData
528 void run(const struct sr_dev_inst *sdi,
529 const struct sr_datafeed_packet *pkt);
531 DatafeedCallbackFunction _callback;
532 DatafeedCallbackData(Session *session,
533 DatafeedCallbackFunction callback);
535 friend class Session;
538 /** Type of source callback */
539 typedef function<bool(Glib::IOCondition)>
540 SourceCallbackFunction;
542 /* Data required for C callback function to call a C++ source callback */
543 class SR_PRIV SourceCallbackData
546 bool run(int revents);
548 SourceCallbackData(shared_ptr<EventSource> source);
549 shared_ptr<EventSource> _source;
550 friend class Session;
553 /** An I/O event source */
554 class SR_API EventSource
557 /** Create an event source from a file descriptor.
558 * @param fd File descriptor.
559 * @param events GLib IOCondition event mask.
560 * @param timeout Timeout in milliseconds.
561 * @param callback Callback of the form callback(events) */
562 static shared_ptr<EventSource> create(int fd, Glib::IOCondition events,
563 int timeout, SourceCallbackFunction callback);
564 /** Create an event source from a GLib PollFD
565 * @param pollfd GLib PollFD
566 * @param timeout Timeout in milliseconds.
567 * @param callback Callback of the form callback(events) */
568 static shared_ptr<EventSource> create(Glib::PollFD pollfd, int timeout,
569 SourceCallbackFunction callback);
570 /** Create an event source from a GLib IOChannel
571 * @param channel GLib IOChannel.
572 * @param events GLib IOCondition event mask.
573 * @param timeout Timeout in milliseconds.
574 * @param callback Callback of the form callback(events) */
575 static shared_ptr<EventSource> create(
576 Glib::RefPtr<Glib::IOChannel> channel, Glib::IOCondition events,
577 int timeout, SourceCallbackFunction callback);
579 EventSource(int timeout, SourceCallbackFunction callback);
587 Glib::PollFD _pollfd;
588 Glib::RefPtr<Glib::IOChannel> _channel;
589 Glib::IOCondition _events;
591 SourceCallbackFunction _callback;
592 /** Deleter needed to allow shared_ptr use with protected destructor. */
596 void operator()(EventSource *source) { delete source; }
598 friend class Deleter;
599 friend class Session;
600 friend class SourceCallbackData;
603 /** A virtual device associated with a stored session */
604 class SR_API SessionDevice :
605 public ParentOwned<SessionDevice, Session, struct sr_dev_inst>,
609 SessionDevice(struct sr_dev_inst *sdi);
611 shared_ptr<Device> get_shared_from_this();
612 /** Deleter needed to allow shared_ptr use with protected destructor. */
616 void operator()(SessionDevice *device) { delete device; }
618 friend class Deleter;
619 friend class Session;
622 /** A sigrok session */
623 class SR_API Session : public UserOwned<Session, struct sr_session>
626 /** Add a device to this session.
627 * @param device Device to add. */
628 void add_device(shared_ptr<Device> device);
629 /** List devices attached to this session. */
630 vector<shared_ptr<Device> > devices();
631 /** Remove all devices from this session. */
632 void remove_devices();
633 /** Add a datafeed callback to this session.
634 * @param callback Callback of the form callback(Device, Packet). */
635 void add_datafeed_callback(DatafeedCallbackFunction callback);
636 /** Remove all datafeed callbacks from this session. */
637 void remove_datafeed_callbacks();
638 /** Add an I/O event source.
639 * @param source EventSource to add. */
640 void add_source(shared_ptr<EventSource> source);
641 /** Remove an event source.
642 * @param source EventSource to remove. */
643 void remove_source(shared_ptr<EventSource> source);
644 /** Start the session. */
646 /** Run the session event loop. */
648 /** Stop the session. */
650 /** Begin saving session to a file.
651 * @param filename File name string. */
652 void begin_save(string filename);
653 /** Append a packet to the session file being saved.
654 * @param packet Packet to append. */
655 void append(shared_ptr<Packet> packet);
656 /** Append raw logic data to the session file being saved. */
657 void append(void *data, size_t length, unsigned int unit_size);
658 /** Get current trigger setting. */
659 shared_ptr<Trigger> trigger();
660 /** Set trigger setting.
661 * @param trigger Trigger object to use. */
662 void set_trigger(shared_ptr<Trigger> trigger);
664 Session(shared_ptr<Context> context);
665 Session(shared_ptr<Context> context, string filename);
667 const shared_ptr<Context> _context;
668 map<const struct sr_dev_inst *, shared_ptr<Device> > _devices;
669 vector<DatafeedCallbackData *> _datafeed_callbacks;
670 map<shared_ptr<EventSource>, SourceCallbackData *> _source_callbacks;
672 bool _save_initialized;
673 string _save_filename;
674 uint64_t _save_samplerate;
675 shared_ptr<Trigger> _trigger;
676 friend class Deleter;
677 friend class Context;
678 friend class DatafeedCallbackData;
681 /** A packet on the session datafeed */
682 class SR_API Packet : public UserOwned<Packet, const struct sr_datafeed_packet>
685 /** Type of this packet. */
686 const PacketType *type();
687 /** Payload of this packet. */
688 shared_ptr<PacketPayload> payload();
690 Packet(shared_ptr<Device> device,
691 const struct sr_datafeed_packet *structure);
693 shared_ptr<Device> _device;
694 PacketPayload *_payload;
695 friend class Deleter;
696 friend class Session;
698 friend class DatafeedCallbackData;
705 /** Abstract base class for datafeed packet payloads */
706 class SR_API PacketPayload
710 virtual ~PacketPayload() = 0;
711 virtual shared_ptr<PacketPayload> get_shared_pointer(Packet *parent) = 0;
712 /** Deleter needed to allow shared_ptr use with protected destructor. */
716 void operator()(PacketPayload *payload) { delete payload; }
718 friend class Deleter;
723 /** Payload of a datafeed header packet */
724 class SR_API Header :
725 public ParentOwned<Header, Packet, const struct sr_datafeed_header>,
729 /* Feed version number. */
731 /* Start time of this session. */
732 Glib::TimeVal start_time();
734 Header(const struct sr_datafeed_header *structure);
736 shared_ptr<PacketPayload> get_shared_pointer(Packet *parent);
740 /** Payload of a datafeed metadata packet */
742 public ParentOwned<Meta, Packet, const struct sr_datafeed_meta>,
746 /* Mapping of (ConfigKey, value) pairs. */
747 map<const ConfigKey *, Glib::VariantBase> config();
749 Meta(const struct sr_datafeed_meta *structure);
751 shared_ptr<PacketPayload> get_shared_pointer(Packet *parent);
752 map<const ConfigKey *, Glib::VariantBase> _config;
756 /** Payload of a datafeed packet with logic data */
758 public ParentOwned<Logic, Packet, const struct sr_datafeed_logic>,
762 /* Pointer to data. */
763 void *data_pointer();
764 /* Data length in bytes. */
765 size_t data_length();
766 /* Size of each sample in bytes. */
767 unsigned int unit_size();
769 Logic(const struct sr_datafeed_logic *structure);
771 shared_ptr<PacketPayload> get_shared_pointer(Packet *parent);
775 /** Payload of a datafeed packet with analog data */
776 class SR_API Analog :
777 public ParentOwned<Analog, Packet, const struct sr_datafeed_analog>,
781 /** Pointer to data. */
782 float *data_pointer();
783 /** Number of samples in this packet. */
784 unsigned int num_samples();
785 /** Channels for which this packet contains data. */
786 vector<shared_ptr<Channel> > channels();
787 /** Measured quantity of the samples in this packet. */
788 const Quantity *mq();
789 /** Unit of the samples in this packet. */
791 /** Measurement flags associated with the samples in this packet. */
792 vector<const QuantityFlag *> mq_flags();
794 Analog(const struct sr_datafeed_analog *structure);
796 shared_ptr<PacketPayload> get_shared_pointer(Packet *parent);
800 /** An input format supported by the library */
801 class SR_API InputFormat :
802 public ParentOwned<InputFormat, Context, const struct sr_input_module>
805 /** Name of this input format. */
807 /** Description of this input format. */
808 string description();
809 /** Options supported by this input format. */
810 map<string, shared_ptr<Option> > options();
811 /** Create an input using this input format.
812 * @param options Mapping of (option name, value) pairs. */
813 shared_ptr<Input> create_input(map<string, Glib::VariantBase> options =
814 map<string, Glib::VariantBase>());
816 InputFormat(const struct sr_input_module *structure);
818 friend class Context;
819 friend class InputDevice;
822 /** An input instance (an input format applied to a file or stream) */
823 class SR_API Input : public UserOwned<Input, const struct sr_input>
826 /** Virtual device associated with this input. */
827 shared_ptr<InputDevice> device();
828 /** Send next stream data.
829 * @param data Next stream data. */
830 void send(string data);
831 /** Signal end of input data. */
834 Input(shared_ptr<Context> context, const struct sr_input *structure);
836 shared_ptr<Context> _context;
837 InputDevice *_device;
838 friend class Deleter;
839 friend class Context;
840 friend class InputFormat;
843 /** A virtual device associated with an input */
844 class SR_API InputDevice :
845 public ParentOwned<InputDevice, Input, struct sr_dev_inst>,
849 InputDevice(shared_ptr<Input> input, struct sr_dev_inst *sdi);
851 shared_ptr<Device> get_shared_from_this();
852 shared_ptr<Input> _input;
856 /** An option used by an output format */
857 class SR_API Option : public UserOwned<Option, const struct sr_option>
860 /** Short name of this option suitable for command line usage. */
862 /** Short name of this option suitable for GUI usage. */
864 /** Description of this option in a sentence. */
865 string description();
866 /** Default value for this option. */
867 Glib::VariantBase default_value();
868 /** Possible values for this option, if a limited set. */
869 vector<Glib::VariantBase> values();
871 Option(const struct sr_option *structure,
872 shared_ptr<const struct sr_option *> structure_array);
874 shared_ptr<const struct sr_option *> _structure_array;
875 friend class Deleter;
876 friend class InputFormat;
877 friend class OutputFormat;
880 /** An output format supported by the library */
881 class SR_API OutputFormat :
882 public ParentOwned<OutputFormat, Context, const struct sr_output_module>
885 /** Name of this output format. */
887 /** Description of this output format. */
888 string description();
889 /** Options supported by this output format. */
890 map<string, shared_ptr<Option> > options();
891 /** Create an output using this format.
892 * @param device Device to output for.
893 * @param options Mapping of (option name, value) pairs. */
894 shared_ptr<Output> create_output(shared_ptr<Device> device,
895 map<string, Glib::VariantBase> options =
896 map<string, Glib::VariantBase>());
898 OutputFormat(const struct sr_output_module *structure);
900 friend class Context;
904 /** An output instance (an output format applied to a device) */
905 class SR_API Output : public UserOwned<Output, const struct sr_output>
908 /** Update output with data from the given packet.
909 * @param packet Packet to handle. */
910 string receive(shared_ptr<Packet> packet);
912 Output(shared_ptr<OutputFormat> format, shared_ptr<Device> device);
913 Output(shared_ptr<OutputFormat> format,
914 shared_ptr<Device> device, map<string, Glib::VariantBase> options);
916 const shared_ptr<OutputFormat> _format;
917 const shared_ptr<Device> _device;
918 const map<string, Glib::VariantBase> _options;
919 friend class Deleter;
920 friend class OutputFormat;
923 /** Base class for objects which wrap an enumeration value from libsigrok */
924 template <typename T> class SR_API EnumValue
927 /** The enum constant associated with this value. */
928 T id() const { return _id; }
929 /** The name associated with this value. */
930 string name() const { return _name; }
932 EnumValue(T id, const char name[]) : _id(id), _name(name) {}
942 #endif // LIBSIGROK_HPP