{
}
+SessionDevice::SessionDevice(struct sr_dev_inst *structure) :
+ ParentOwned(structure),
+ Device(structure)
+{
+}
+
+SessionDevice::~SessionDevice()
+{
+}
+
+shared_ptr<Device> SessionDevice::get_shared_from_this()
+{
+ return static_pointer_cast<Device>(shared_from_this());
+}
+
Session::Session(shared_ptr<Context> context) :
UserOwned(structure),
context(context), saving(false)
context(context), saving(false)
{
check(sr_session_load(filename.c_str(), &structure));
+ GSList *dev_list;
+ check(sr_session_dev_list(structure, &dev_list));
+ for (GSList *dev = dev_list; dev; dev = dev->next)
+ {
+ auto sdi = (struct sr_dev_inst *) dev->data;
+ auto device = new SessionDevice(sdi);
+ devices[sdi] = shared_ptr<SessionDevice>(device,
+ SessionDevice::Deleter());
+ }
context->session = this;
}
friend class SourceCallbackData;
};
+/** A virtual device associated with a stored session */
+class SR_API SessionDevice :
+ public ParentOwned<SessionDevice, Session, struct sr_dev_inst>,
+ public Device
+{
+protected:
+ SessionDevice(struct sr_dev_inst *sdi);
+ ~SessionDevice();
+ shared_ptr<Device> get_shared_from_this();
+ /** Deleter needed to allow shared_ptr use with protected destructor. */
+ class Deleter
+ {
+ public:
+ void operator()(SessionDevice *device) { delete device; }
+ };
+ friend class Deleter;
+ friend class Session;
+};
+
/** A sigrok session */
class SR_API Session : public UserOwned<Session, struct sr_session>
{
%shared_ptr(sigrok::ChannelGroup);
%shared_ptr(sigrok::EventSource);
%shared_ptr(sigrok::Session);
+%shared_ptr(sigrok::SessionDevice);
%shared_ptr(sigrok::Packet);
%shared_ptr(sigrok::PacketPayload);
%shared_ptr(sigrok::Header);