From: Martin Ling Date: Tue, 30 Sep 2014 10:07:55 +0000 (+0100) Subject: C++: Expose config key capabilities. X-Git-Tag: libsigrok-0.4.0~914 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=4c7c4194cbd1d172a8ea37206d6aff9a09c1fb91 C++: Expose config key capabilities. --- diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index 986d4a73..549e07b0 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -352,12 +352,12 @@ Glib::VariantContainerBase Configurable::config_list(const ConfigKey *key) return Glib::VariantContainerBase(data); } -vector Configurable::config_keys(const ConfigKey *key) +map> Configurable::config_keys(const ConfigKey *key) { GVariant *gvar_opts; gsize num_opts; const uint32_t *opts; - vector result; + map> result; check(sr_config_list( config_driver, config_sdi, config_channel_group, @@ -367,7 +367,17 @@ vector Configurable::config_keys(const ConfigKey *key) gvar_opts, &num_opts, sizeof(uint32_t)); for (gsize i = 0; i < num_opts; i++) - result.push_back(ConfigKey::get(opts[i] & SR_CONF_MASK)); + { + auto key = ConfigKey::get(opts[i] & SR_CONF_MASK); + set capabilities; + if (opts[i] & SR_CONF_GET) + capabilities.insert(GET); + if (opts[i] & SR_CONF_SET) + capabilities.insert(SET); + if (opts[i] & SR_CONF_LIST) + capabilities.insert(LIST); + result[key] = capabilities; + } g_variant_unref(gvar_opts); diff --git a/bindings/cxx/include/libsigrok/libsigrok.hpp b/bindings/cxx/include/libsigrok/libsigrok.hpp index 9c211837..2deb6175 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 { @@ -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 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: