]> sigrok.org Git - libsigrok.git/commitdiff
Return sensible Device::description() for session and input devices.
authorMartin Ling <redacted>
Tue, 30 Sep 2014 16:32:09 +0000 (17:32 +0100)
committerMartin Ling <redacted>
Tue, 30 Sep 2014 16:32:09 +0000 (17:32 +0100)
bindings/cxx/classes.cpp
bindings/cxx/include/libsigrok/libsigrok.hpp

index 86d0865e30b59460365def90bb72160bc90f91dc..9013e41ae9d44ad004cfe2a9b218e742a719432e 100644 (file)
@@ -789,6 +789,11 @@ SessionDevice::~SessionDevice()
 {
 }
 
+string SessionDevice::description()
+{
+       return _parent->_filename;
+}
+
 shared_ptr<Device> SessionDevice::get_shared_from_this()
 {
        return static_pointer_cast<Device>(shared_from_this());
@@ -806,6 +811,7 @@ Session::Session(shared_ptr<Context> context) :
 Session::Session(shared_ptr<Context> 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 "<input data>";
+}
+
 shared_ptr<Device> InputDevice::get_shared_from_this()
 {
        return static_pointer_cast<Device>(shared_from_this());
index 0bf19015b22bee0d0068983d7fcfacd0d9b86504..0bd27f3adffe7c3a7d0a965c0ba73b47962fa035 100644 (file)
@@ -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<SessionDevice, Session, struct sr_dev_inst>,
        public Device
 {
+       /** Description identifying this device. */
+       string description();
 protected:
        SessionDevice(struct sr_dev_inst *sdi);
        ~SessionDevice();
@@ -674,6 +676,7 @@ protected:
        map<const struct sr_dev_inst *, shared_ptr<Device> > _other_devices;
        vector<DatafeedCallbackData *> _datafeed_callbacks;
        map<shared_ptr<EventSource>, 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<InputDevice, Input, struct sr_dev_inst>,
        public Device
 {
+public:
+       /** Description identifying this device. */
+       string description();
 protected:
        InputDevice(shared_ptr<Input> input, struct sr_dev_inst *sdi);
        ~InputDevice();