- /** Create virtual device. */
- return shared_ptr<InputFileDevice>(new InputFileDevice(
- static_pointer_cast<InputFormat>(shared_from_this()), input, filename),
- InputFileDevice::Deleter());
+shared_ptr<InputDevice> Input::get_device()
+{
+ if (!device)
+ {
+ auto sdi = sr_input_dev_inst_get(structure);
+ if (!sdi)
+ throw Error(SR_ERR_NA);
+ device = new InputDevice(shared_from_this(), sdi);
+ }
+
+ return static_pointer_cast<InputDevice>(
+ device->get_shared_pointer(shared_from_this()));
+}
+
+void Input::send(string data)
+{
+ auto gstr = g_string_new(data.c_str());
+ auto ret = sr_input_send(structure, gstr);
+ g_string_free(gstr, false);
+ check(ret);
+}
+
+Input::~Input()
+{
+ if (device)
+ delete device;
+ check(sr_input_free(structure));
+}
+
+InputDevice::InputDevice(shared_ptr<Input> input,
+ struct sr_dev_inst *structure) :
+ StructureWrapper(structure),
+ Device(structure),
+ input(input)
+{
+}
+
+InputDevice::~InputDevice()
+{