]> sigrok.org Git - libsigrok.git/blobdiff - bindings/cxx/include/libsigrok/libsigrok.hpp
output/wav: Add 'scale' option.
[libsigrok.git] / bindings / cxx / include / libsigrok / libsigrok.hpp
index c4150904b87fd344146c51aad0aa84a0ae34bfdb..3063e3bdb41671964d44fb8fdff6ac0f54c0c087 100644 (file)
@@ -111,6 +111,7 @@ class SR_API QuantityFlag;
 class SR_API InputFileDevice;
 class SR_API Output;
 class SR_API DataType;
+class SR_API Option;
 
 /** Exception thrown when an error code is returned by any libsigrok call. */
 class SR_API Error: public exception
@@ -258,7 +259,7 @@ public:
        /** Set configuration for the given key to a specified value. */
        void config_set(const ConfigKey *key, Glib::VariantBase value);
        /** Enumerate available values for the given configuration key. */
-       Glib::VariantBase config_list(const ConfigKey *key);
+       Glib::VariantContainerBase config_list(const ConfigKey *key);
 protected:
        Configurable(
                struct sr_dev_driver *driver,
@@ -276,6 +277,8 @@ class SR_API Device :
        public StructureWrapper<Context, struct sr_dev_inst>
 {
 public:
+       /** Description identifying this device. */
+       string get_description();
        /** Vendor name for this device. */
        string get_vendor();
        /** Model name for this device. */
@@ -338,6 +341,8 @@ public:
        bool get_enabled();
        /** Set the enabled status of this channel. */
        void set_enabled(bool value);
+       /** Get the index number of this channel. */
+       unsigned int get_index();
 protected:
        Channel(struct sr_channel *structure);
        ~Channel();
@@ -516,7 +521,9 @@ public:
        /** Begin saving session to a file. */
        void begin_save(string filename);
        /** Append a packet to the session file being saved. */
-       void append(shared_ptr<Device> device, shared_ptr<Packet> packet);
+       void append(shared_ptr<Packet> packet);
+       /** Append raw logic data to the session file being saved. */
+       void append(void *data, size_t length, unsigned int unit_size);
        /** Get current trigger setting. */
        shared_ptr<Trigger> get_trigger();
        /** Set trigger setting. */
@@ -711,19 +718,52 @@ protected:
        friend class InputFormat;
 };
 
+/** An option used by an output format */
+class SR_API Option
+{
+public:
+       /** Short name of this option suitable for command line usage. */
+       string get_id();
+       /** Short name of this option suitable for GUI usage. */
+       string get_name();
+       /** Description of this option in a sentence. */
+       string get_description();
+       /** Default value for this option. */
+       Glib::VariantBase get_default_value();
+       /** Possible values for this option, if a limited set. */
+       vector<Glib::VariantBase> get_values();
+protected:
+       Option(const struct sr_option *structure,
+               shared_ptr<const struct sr_option> structure_array);
+       ~Option();
+       const struct sr_option *structure;
+       shared_ptr<const struct sr_option> structure_array;
+       /** Deleter needed to allow shared_ptr use with protected destructor. */
+       class Deleter
+       {
+       public:
+               void operator()(Option *option) { delete option; }
+       };
+       friend class Deleter;
+       friend class OutputFormat;
+};
+
 /** An output format supported by the library */
 class SR_API OutputFormat :
-       public StructureWrapper<Context, struct sr_output_format>
+       public StructureWrapper<Context, const struct sr_output_module>
 {
 public:
        /** Name of this output format. */
        string get_name();
        /** Description of this output format. */
        string get_description();
+       /** Options supported by this output format. */
+       map<string, shared_ptr<Option> > get_options();
        /** Create an output using this format. */
-       shared_ptr<Output> create_output(shared_ptr<Device> device, map<string, string> options = {});
+       shared_ptr<Output> create_output(shared_ptr<Device> device,
+               map<string, Glib::VariantBase> options = {});
 protected:
-       OutputFormat(struct sr_output_format *structure);
+       OutputFormat(const struct sr_output_module *structure);
        ~OutputFormat();
        friend class Context;
        friend class Output;
@@ -738,12 +778,12 @@ public:
 protected:
        Output(shared_ptr<OutputFormat> format, shared_ptr<Device> device);
        Output(shared_ptr<OutputFormat> format,
-               shared_ptr<Device> device, map<string, string> options);
+               shared_ptr<Device> device, map<string, Glib::VariantBase> options);
        ~Output();
-       struct sr_output *structure;
+       const struct sr_output *structure;
        const shared_ptr<OutputFormat> format;
        const shared_ptr<Device> device;
-       const map<string, string> options;
+       const map<string, Glib::VariantBase> options;
        /** Deleter needed to allow shared_ptr use with protected destructor. */
        class Deleter
        {