]> sigrok.org Git - libsigrok.git/blobdiff - bindings/cxx/classes.cpp
C++: Update InputFormat::get_options for latest version of input API.
[libsigrok.git] / bindings / cxx / classes.cpp
index 986b2c1e1da3fe60daa96ffbb0b15f9d71434f6d..ce458eeb6c61255b1904d4824b10cc491ddb4bd9 100644 (file)
@@ -361,7 +361,7 @@ Glib::VariantContainerBase Configurable::config_list(const ConfigKey *key)
 
 Device::Device(struct sr_dev_inst *structure) :
        Configurable(structure->driver, structure, NULL),
-       StructureWrapper<Context, struct sr_dev_inst>(structure)
+       structure(structure)
 {
        for (GSList *entry = structure->channels; entry; entry = entry->next)
        {
@@ -453,6 +453,7 @@ void Device::close()
 }
 
 HardwareDevice::HardwareDevice(Driver *driver, struct sr_dev_inst *structure) :
+       StructureWrapper(structure),
        Device(structure),
        driver(driver)
 {
@@ -1127,6 +1128,18 @@ string InputFormat::get_description()
        return valid_string(sr_input_description_get(structure));
 }
 
+map<string, shared_ptr<Option>> InputFormat::get_options()
+{
+       const struct sr_option **options = sr_input_options_get(structure);
+       auto option_array = shared_ptr<const struct sr_option *>(
+               options, sr_input_options_free);
+       map<string, shared_ptr<Option>> result;
+       for (int i = 0; options[i]; i++)
+               result[options[i]->id] = shared_ptr<Option>(
+                       new Option(options[i], option_array), Option::Deleter());
+       return result;
+}
+
 shared_ptr<Input> InputFormat::create_input(
        map<string, Glib::VariantBase> options)
 {
@@ -1155,7 +1168,7 @@ shared_ptr<InputDevice> Input::get_device()
        }
 
        return static_pointer_cast<InputDevice>(
-               device->get_shared_pointer(context->shared_from_this()));
+               device->get_shared_pointer(shared_from_this()));
 }
 
 void Input::send(string data)
@@ -1173,8 +1186,10 @@ Input::~Input()
        check(sr_input_free(structure));
 }
 
-InputDevice::InputDevice(shared_ptr<Input> input, struct sr_dev_inst *sdi) :
-       Device(sdi),
+InputDevice::InputDevice(shared_ptr<Input> input,
+               struct sr_dev_inst *structure) :
+       StructureWrapper(structure),
+       Device(structure),
        input(input)
 {
 }