Return sensible Device::description() for session and input devices.

This commit is contained in:
Martin Ling 2014-09-30 17:32:09 +01:00
parent ca4e307a93
commit 98d39b919a
2 changed files with 19 additions and 1 deletions

View File

@ -789,6 +789,11 @@ SessionDevice::~SessionDevice()
{ {
} }
string SessionDevice::description()
{
return _parent->_filename;
}
shared_ptr<Device> SessionDevice::get_shared_from_this() shared_ptr<Device> SessionDevice::get_shared_from_this()
{ {
return static_pointer_cast<Device>(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) : Session::Session(shared_ptr<Context> context, string filename) :
UserOwned(_structure), UserOwned(_structure),
_context(context), _context(context),
_filename(filename),
_saving(false) _saving(false)
{ {
check(sr_session_load(filename.c_str(), &_structure)); 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() shared_ptr<Device> InputDevice::get_shared_from_this()
{ {
return static_pointer_cast<Device>(shared_from_this()); return static_pointer_cast<Device>(shared_from_this());

View File

@ -347,7 +347,7 @@ class SR_API Device : public Configurable
{ {
public: public:
/** Description identifying this device. */ /** Description identifying this device. */
string description(); virtual string description();
/** Vendor name for this device. */ /** Vendor name for this device. */
string vendor(); string vendor();
/** Model name for this device. */ /** Model name for this device. */
@ -609,6 +609,8 @@ class SR_API SessionDevice :
public ParentOwned<SessionDevice, Session, struct sr_dev_inst>, public ParentOwned<SessionDevice, Session, struct sr_dev_inst>,
public Device public Device
{ {
/** Description identifying this device. */
string description();
protected: protected:
SessionDevice(struct sr_dev_inst *sdi); SessionDevice(struct sr_dev_inst *sdi);
~SessionDevice(); ~SessionDevice();
@ -674,6 +676,7 @@ protected:
map<const struct sr_dev_inst *, shared_ptr<Device> > _other_devices; map<const struct sr_dev_inst *, shared_ptr<Device> > _other_devices;
vector<DatafeedCallbackData *> _datafeed_callbacks; vector<DatafeedCallbackData *> _datafeed_callbacks;
map<shared_ptr<EventSource>, SourceCallbackData *> _source_callbacks; map<shared_ptr<EventSource>, SourceCallbackData *> _source_callbacks;
string _filename;
bool _saving; bool _saving;
bool _save_initialized; bool _save_initialized;
string _save_filename; string _save_filename;
@ -682,6 +685,7 @@ protected:
friend class Deleter; friend class Deleter;
friend class Context; friend class Context;
friend class DatafeedCallbackData; friend class DatafeedCallbackData;
friend class SessionDevice;
}; };
/** A packet on the session datafeed */ /** A packet on the session datafeed */
@ -851,6 +855,9 @@ class SR_API InputDevice :
public ParentOwned<InputDevice, Input, struct sr_dev_inst>, public ParentOwned<InputDevice, Input, struct sr_dev_inst>,
public Device public Device
{ {
public:
/** Description identifying this device. */
string description();
protected: protected:
InputDevice(shared_ptr<Input> input, struct sr_dev_inst *sdi); InputDevice(shared_ptr<Input> input, struct sr_dev_inst *sdi);
~InputDevice(); ~InputDevice();