shared_ptr<Input> Context::open_file(string filename)
{
- auto input = sr_input_scan_file(filename.c_str());
- if (!input)
- throw Error(SR_ERR_NA);
+ const struct sr_input *input;
+
+ check( sr_input_scan_file(filename.c_str(), &input));
return shared_ptr<Input>(
new Input(shared_from_this(), input), Input::Deleter());
}
shared_ptr<Input> Context::open_stream(string header)
{
+ const struct sr_input *input;
+
auto gstr = g_string_new(header.c_str());
- auto input = sr_input_scan_buffer(gstr);
- g_string_free(gstr, false);
- if (!input)
- throw Error(SR_ERR_NA);
+ auto ret = sr_input_scan_buffer(gstr, &input);
+ g_string_free(gstr, true);
+ check(ret);
return shared_ptr<Input>(
new Input(shared_from_this(), input), Input::Deleter());
}
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)
{
}
HardwareDevice::HardwareDevice(Driver *driver, struct sr_dev_inst *structure) :
+ StructureWrapper(structure),
Device(structure),
driver(driver)
{
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)
{
}
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)
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)
{
}