X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdevice%2Fdevinst.cpp;h=adbf8968595e80cc66441dcd48985fc18d25df5b;hp=a5f96808e55d14161050b5d3e966ca0e847b3c62;hb=996b7c9da9b5cb56413e829217e1e7d7d7d520da;hpb=945745012eb57cefa1ef457daf48cfffa99f9ec2 diff --git a/pv/device/devinst.cpp b/pv/device/devinst.cpp index a5f96808..adbf8968 100644 --- a/pv/device/devinst.cpp +++ b/pv/device/devinst.cpp @@ -19,7 +19,6 @@ */ #include -#include #include @@ -27,14 +26,14 @@ #include "devinst.h" -using std::ostringstream; -using std::string; +#include namespace pv { namespace device { DevInst::DevInst(sr_dev_inst *sdi) : - _sdi(sdi) + _sdi(sdi), + _owner(NULL) { assert(_sdi); } @@ -44,29 +43,26 @@ sr_dev_inst* DevInst::dev_inst() const return _sdi; } -string DevInst::format_device_title() const +void DevInst::use(SigSession *owner) { - ostringstream s; - - assert(_sdi); - - if (_sdi->vendor && _sdi->vendor[0]) { - s << _sdi->vendor; - if ((_sdi->model && _sdi->model[0]) || - (_sdi->version && _sdi->version[0])) - s << ' '; - } + assert(owner); + assert(!_owner); + _owner = owner; + sr_dev_open(_sdi); +} - if (_sdi->model && _sdi->model[0]) { - s << _sdi->model; - if (_sdi->version && _sdi->version[0]) - s << ' '; +void DevInst::release() +{ + if (_owner) { + _owner->release_device(this); + _owner = NULL; + sr_dev_close(_sdi); } +} - if (_sdi->version && _sdi->version[0]) - s << _sdi->version; - - return s.str(); +SigSession* DevInst::owner() const +{ + return _owner; } GVariant* DevInst::get_config(const sr_probe_group *group, int key)