X-Git-Url: http://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdevice%2Fdevinst.cpp;fp=pv%2Fdevice%2Fdevinst.cpp;h=adbf8968595e80cc66441dcd48985fc18d25df5b;hp=5fe2951756e4b602fca4da0fa4b379f3cfc19ef0;hb=996b7c9da9b5cb56413e829217e1e7d7d7d520da;hpb=85843b14c48affe67820ec8c9e357cd26e0ed943 diff --git a/pv/device/devinst.cpp b/pv/device/devinst.cpp index 5fe29517..adbf8968 100644 --- a/pv/device/devinst.cpp +++ b/pv/device/devinst.cpp @@ -26,11 +26,14 @@ #include "devinst.h" +#include + namespace pv { namespace device { DevInst::DevInst(sr_dev_inst *sdi) : - _sdi(sdi) + _sdi(sdi), + _owner(NULL) { assert(_sdi); } @@ -40,6 +43,28 @@ sr_dev_inst* DevInst::dev_inst() const return _sdi; } +void DevInst::use(SigSession *owner) +{ + assert(owner); + assert(!_owner); + _owner = owner; + sr_dev_open(_sdi); +} + +void DevInst::release() +{ + if (_owner) { + _owner->release_device(this); + _owner = NULL; + sr_dev_close(_sdi); + } +} + +SigSession* DevInst::owner() const +{ + return _owner; +} + GVariant* DevInst::get_config(const sr_probe_group *group, int key) { GVariant *data = NULL;