]> sigrok.org Git - libsigrok.git/blobdiff - bindings/cxx/classes.cpp
C++: Whitespace fix.
[libsigrok.git] / bindings / cxx / classes.cpp
index dc8eded7b4aac6e010702cf5e49a41d92947e2cb..8ecffd720677cb4abff40610f3d37512adf5c655 100644 (file)
@@ -229,7 +229,7 @@ shared_ptr<Input> Context::open_file(string filename)
 {
        const struct sr_input *input;
 
-       check( sr_input_scan_file(filename.c_str(), &input));
+       check(sr_input_scan_file(filename.c_str(), &input));
        return shared_ptr<Input>(
                new Input(shared_from_this(), input), Input::Deleter());
 }
@@ -465,8 +465,10 @@ string Device::get_version()
 vector<shared_ptr<Channel>> Device::get_channels()
 {
        vector<shared_ptr<Channel>> result;
-       for (auto entry : channels)
-               result.push_back(entry.second->get_shared_pointer(get_shared_from_this()));
+       for (auto channel = structure->channels; channel; channel = channel->next)
+               result.push_back(
+                       channels[(struct sr_channel *) channel->data]->get_shared_pointer(
+                               get_shared_from_this()));
        return result;
 }
 
@@ -743,6 +745,21 @@ EventSource::~EventSource()
 {
 }
 
+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)
@@ -756,6 +773,15 @@ Session::Session(shared_ptr<Context> context, string filename) :
        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;
 }