]> sigrok.org Git - libsigrok.git/blobdiff - bindings/cxx/include/libsigrok/libsigrok.hpp
C++: Fix management of SessionDevice objects.
[libsigrok.git] / bindings / cxx / include / libsigrok / libsigrok.hpp
index 7b8c76d48a70549d9e6a38417f65f27086542713..0bf19015b22bee0d0068983d7fcfacd0d9b86504 100644 (file)
@@ -77,6 +77,7 @@ raised, which provides access to the error code and description.
 #include <memory>
 #include <vector>
 #include <map>
+#include <set>
 
 namespace sigrok
 {
@@ -281,6 +282,12 @@ protected:
        friend class Driver;
 };
 
+enum Capability {
+       GET = SR_CONF_GET,
+       SET = SR_CONF_SET,
+       LIST = SR_CONF_LIST
+};
+
 /** An object that can be configured. */
 class SR_API Configurable
 {
@@ -296,7 +303,7 @@ public:
         * @param key ConfigKey to enumerate values for. */
        Glib::VariantContainerBase config_list(const ConfigKey *key);
        /** Enumerate available keys, according to a given index key. */
-       vector<const ConfigKey *> config_keys(const ConfigKey *key);
+       map<const ConfigKey *, set<Capability> > config_keys(const ConfigKey *key);
        /** Check for a key in the list from a given index key. */
        bool config_check(const ConfigKey *key, const ConfigKey *index_key);
 protected:
@@ -347,6 +354,10 @@ public:
        string model();
        /** Version string for this device. */
        string version();
+       /** Serial number for this device. */
+       string serial_number();
+       /** Connection ID for this device. */
+       string connection_id();
        /** List of the channels available on this device. */
        vector<shared_ptr<Channel> > channels();
        /** Channel groups available on this device, indexed by name. */
@@ -379,17 +390,24 @@ protected:
 
 /** A real hardware device, connected via a driver */
 class SR_API HardwareDevice :
-       public ParentOwned<HardwareDevice, Context, struct sr_dev_inst>,
+       public UserOwned<HardwareDevice, struct sr_dev_inst>,
        public Device
 {
 public:
        /** Driver providing this device. */
        shared_ptr<Driver> driver();
 protected:
-       HardwareDevice(Driver *driver, struct sr_dev_inst *structure);
+       HardwareDevice(shared_ptr<Driver> driver, struct sr_dev_inst *structure);
        ~HardwareDevice();
        shared_ptr<Device> get_shared_from_this();
-       Driver *_driver;
+       shared_ptr<Driver> _driver;
+       /** Deleter needed to allow shared_ptr use with protected destructor. */
+       class Deleter
+       {
+       public:
+               void operator()(HardwareDevice *device) { delete device; }
+       };
+       friend class Deleter;
        friend class Driver;
        friend class ChannelGroup;
 };
@@ -650,8 +668,10 @@ protected:
        Session(shared_ptr<Context> context);
        Session(shared_ptr<Context> context, string filename);
        ~Session();
+       shared_ptr<Device> get_device(const struct sr_dev_inst *sdi);
        const shared_ptr<Context> _context;
-       map<const struct sr_dev_inst *, shared_ptr<Device> > _devices;
+       map<const struct sr_dev_inst *, SessionDevice *> _owned_devices;
+       map<const struct sr_dev_inst *, shared_ptr<Device> > _other_devices;
        vector<DatafeedCallbackData *> _datafeed_callbacks;
        map<shared_ptr<EventSource>, SourceCallbackData *> _source_callbacks;
        bool _saving;
@@ -814,6 +834,8 @@ public:
        /** Send next stream data.
         * @param data Next stream data. */
        void send(string data);
+       /** Signal end of input data. */
+       void end();
 protected:
        Input(shared_ptr<Context> context, const struct sr_input *structure);
        ~Input();