X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=bindings%2Fcxx%2Finclude%2Flibsigrok%2Flibsigrok.hpp;h=0fcc59d0f682c3f0150cd0de4071170ee3efd640;hb=ae431bc8d607ee381052eed1727f644fbc1fd89d;hp=7b8c76d48a70549d9e6a38417f65f27086542713;hpb=db560903d196c39bceeaa543317fa602a02b51ac;p=libsigrok.git diff --git a/bindings/cxx/include/libsigrok/libsigrok.hpp b/bindings/cxx/include/libsigrok/libsigrok.hpp index 7b8c76d4..0fcc59d0 100644 --- a/bindings/cxx/include/libsigrok/libsigrok.hpp +++ b/bindings/cxx/include/libsigrok/libsigrok.hpp @@ -77,6 +77,7 @@ raised, which provides access to the error code and description. #include #include #include +#include namespace sigrok { @@ -148,6 +149,12 @@ protected: weak_ptr _weak_this; public: + /* Get parent object that owns this object. */ + shared_ptr parent() + { + return _parent; + } + /* Note, this implementation will create a new smart_ptr if none exists. */ shared_ptr shared_from_this() { @@ -281,6 +288,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 +309,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 config_keys(const ConfigKey *key); + map > 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: @@ -339,14 +352,16 @@ protected: class SR_API Device : public Configurable { public: - /** Description identifying this device. */ - string description(); /** Vendor name for this device. */ string vendor(); /** Model name for this device. */ 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 > channels(); /** Channel groups available on this device, indexed by name. */ @@ -379,17 +394,24 @@ protected: /** A real hardware device, connected via a driver */ class SR_API HardwareDevice : - public ParentOwned, + public UserOwned, public Device { public: /** Driver providing this device. */ shared_ptr driver(); protected: - HardwareDevice(Driver *driver, struct sr_dev_inst *structure); + HardwareDevice(shared_ptr driver, struct sr_dev_inst *structure); ~HardwareDevice(); shared_ptr get_shared_from_this(); - Driver *_driver; + shared_ptr _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; }; @@ -646,14 +668,19 @@ public: /** Set trigger setting. * @param trigger Trigger object to use. */ void set_trigger(shared_ptr trigger); + /** Get filename this session was loaded from. */ + string filename(); protected: Session(shared_ptr context); Session(shared_ptr context, string filename); ~Session(); + shared_ptr get_device(const struct sr_dev_inst *sdi); const shared_ptr _context; - map > _devices; + map _owned_devices; + map > _other_devices; vector _datafeed_callbacks; map, SourceCallbackData *> _source_callbacks; + string _filename; bool _saving; bool _save_initialized; string _save_filename; @@ -662,6 +689,7 @@ protected: friend class Deleter; friend class Context; friend class DatafeedCallbackData; + friend class SessionDevice; }; /** A packet on the session datafeed */ @@ -814,6 +842,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, const struct sr_input *structure); ~Input();