From: Martin Ling Date: Tue, 30 Sep 2014 16:32:09 +0000 (+0100) Subject: Return sensible Device::description() for session and input devices. X-Git-Tag: libsigrok-0.4.0~910 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=98d39b919abff9412c5de9d02a926680d572fb83;p=libsigrok.git Return sensible Device::description() for session and input devices. --- diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index 86d0865e..9013e41a 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -789,6 +789,11 @@ SessionDevice::~SessionDevice() { } +string SessionDevice::description() +{ + return _parent->_filename; +} + shared_ptr SessionDevice::get_shared_from_this() { return static_pointer_cast(shared_from_this()); @@ -806,6 +811,7 @@ Session::Session(shared_ptr context) : Session::Session(shared_ptr context, string filename) : UserOwned(_structure), _context(context), + _filename(filename), _saving(false) { check(sr_session_load(filename.c_str(), &_structure)); @@ -1364,6 +1370,11 @@ InputDevice::~InputDevice() { } +string InputDevice::description() +{ + return ""; +} + shared_ptr InputDevice::get_shared_from_this() { return static_pointer_cast(shared_from_this()); diff --git a/bindings/cxx/include/libsigrok/libsigrok.hpp b/bindings/cxx/include/libsigrok/libsigrok.hpp index 0bf19015..0bd27f3a 100644 --- a/bindings/cxx/include/libsigrok/libsigrok.hpp +++ b/bindings/cxx/include/libsigrok/libsigrok.hpp @@ -347,7 +347,7 @@ class SR_API Device : public Configurable { public: /** Description identifying this device. */ - string description(); + virtual string description(); /** Vendor name for this device. */ string vendor(); /** Model name for this device. */ @@ -609,6 +609,8 @@ class SR_API SessionDevice : public ParentOwned, public Device { + /** Description identifying this device. */ + string description(); protected: SessionDevice(struct sr_dev_inst *sdi); ~SessionDevice(); @@ -674,6 +676,7 @@ protected: map > _other_devices; vector _datafeed_callbacks; map, SourceCallbackData *> _source_callbacks; + string _filename; bool _saving; bool _save_initialized; string _save_filename; @@ -682,6 +685,7 @@ protected: friend class Deleter; friend class Context; friend class DatafeedCallbackData; + friend class SessionDevice; }; /** A packet on the session datafeed */ @@ -851,6 +855,9 @@ class SR_API InputDevice : public ParentOwned, public Device { +public: + /** Description identifying this device. */ + string description(); protected: InputDevice(shared_ptr input, struct sr_dev_inst *sdi); ~InputDevice();