return Glib::VariantContainerBase(data);
}
-map<const ConfigKey *, set<Capability>> Configurable::config_keys(const ConfigKey *key)
+map<const ConfigKey *, set<const Capability *>> Configurable::config_keys(const ConfigKey *key)
{
GVariant *gvar_opts;
gsize num_opts;
const uint32_t *opts;
- map<const ConfigKey *, set<Capability>> result;
+ map<const ConfigKey *, set<const Capability *>> result;
check(sr_config_list(
config_driver, config_sdi, config_channel_group,
for (gsize i = 0; i < num_opts; i++)
{
auto key = ConfigKey::get(opts[i] & SR_CONF_MASK);
- set<Capability> capabilities;
+ set<const Capability *> capabilities;
if (opts[i] & SR_CONF_GET)
- capabilities.insert(GET);
+ capabilities.insert(Capability::GET);
if (opts[i] & SR_CONF_SET)
- capabilities.insert(SET);
+ capabilities.insert(Capability::SET);
if (opts[i] & SR_CONF_LIST)
- capabilities.insert(LIST);
+ capabilities.insert(Capability::LIST);
result[key] = capabilities;
}
('sr_unit', ('Unit', 'Unit of measurement')),
('sr_mqflag', ('QuantityFlag', 'Flag applied to measured quantity')),
('sr_configkey', ('ConfigKey', 'Configuration key')),
+ ('sr_configcap', ('Capability', 'Configuration capability')),
('sr_datatype', ('DataType', 'Configuration data type')),
('sr_channeltype', ('ChannelType', 'Channel type')),
('sr_trigger_matches', ('TriggerMatchType', 'Trigger match type')),
class SR_API Channel;
class SR_API Session;
class SR_API ConfigKey;
+class SR_API Capability;
class SR_API InputFormat;
class SR_API OutputFormat;
class SR_API OutputFlag;
friend struct std::default_delete<Context>;
};
-enum Capability {
- GET = SR_CONF_GET,
- SET = SR_CONF_SET,
- LIST = SR_CONF_LIST
-};
-
/** An object that can be configured. */
class SR_API Configurable
{
* @param key ConfigKey to enumerate values for. */
Glib::VariantContainerBase config_list(const ConfigKey *key) const;
/** Enumerate available keys, according to a given index key. */
- map<const ConfigKey *, set<enum Capability> > config_keys(const ConfigKey *key);
+ map<const ConfigKey *, set<const 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) const;
protected:
/* Specialisation for ConfigKey->set<Capability> maps */
-MAP_COMMON(const sigrok::ConfigKey *, std::set<enum sigrok::Capability>,
+MAP_COMMON(const sigrok::ConfigKey *, std::set<const sigrok::Capability *>,
ConfigKey, java.util.Set<Capability>)
-%typemap(jni) std::map<const sigrok::ConfigKey *, std::set<enum sigrok::Capability> > "jobject"
-%typemap(jtype) std::map<const sigrok::ConfigKey *, std::set<enum sigrok::Capability> >
+%typemap(jni) std::map<const sigrok::ConfigKey *, std::set<const sigrok::Capability *> > "jobject"
+%typemap(jtype) std::map<const sigrok::ConfigKey *, std::set<const sigrok::Capability *> >
"java.util.Map<ConfigKey,java.util.Set<Capability>>"
-%typemap(out) std::map<const sigrok::ConfigKey *, std::set<enum sigrok::Capability> > {
+%typemap(out) std::map<const sigrok::ConfigKey *, std::set<const sigrok::Capability *> > {
jclass HashMap = jenv->FindClass("java/util/HashMap");
jmethodID HashMap_init = jenv->GetMethodID(HashMap, "<init>", "()V");
jmethodID HashMap_put = jenv->GetMethodID(HashMap, "put",
jclass ConfigKey = jenv->FindClass("org/sigrok/core/classes/ConfigKey");
jmethodID ConfigKey_init = jenv->GetMethodID(ConfigKey, "<init>", "(JZ)V");
jclass Capability = jenv->FindClass("org/sigrok/core/classes/Capability");
- jmethodID Capability_swigToEnum = jenv->GetStaticMethodID(Capability,
- "swigToEnum", "(I)Lorg/sigrok/core/classes/Capability;");
+ jmethodID Capability_init = jenv->GetMethodID(Capability, "<init>", "(JZ)V");
$result = jenv->NewObject(HashMap, HashMap_init);
jlong key = 0;
for (auto map_entry : $1)
jobject value = jenv->NewObject(HashSet, HashSet_init);
for (auto &set_entry : map_entry.second)
jenv->CallObjectMethod(value, HashSet_add,
- jenv->CallStaticObjectMethod(Capability,
- Capability_swigToEnum, set_entry));
+ jenv->NewObject(Capability, Capability_init, set_entry));
jenv->CallObjectMethod($result, HashMap_put,
jenv->NewObject(ConfigKey, ConfigKey_init, key, false), value);
}
%template(ConfigMap)
std::map<const sigrok::ConfigKey *, Glib::VariantBase>;
+/* Currently broken on Python. */
+#ifndef SWIGPYTHON
+
%template(CapabilitySet)
- std::set<enum sigrok::Capability>;
+ std::set<const sigrok::Capability *>;
%template(ConfigKeys)
- std::map<const sigrok::ConfigKey *, std::set<enum sigrok::Capability> >;
+ std::map<const sigrok::ConfigKey *, std::set<const sigrok::Capability *> >;
+
+#endif
%template(OptionVector)
std::vector<std::shared_ptr<sigrok::Option> >;