Enumeration and flag support for DBus
Havoc Pennington
hp at redhat.com
Thu Nov 24 17:14:58 PST 2005
On Thu, 2005-11-24 at 18:00 +0000, Jamie McCracken wrote:
> I was wondering if there will be any support for flags/enums as I have a
> method that can take eight input options.
>
> I can easily have eight input boolean values to represent these flags
> (or even worse have an int and leave it to the apps to XOR) but it does
> not feel as nice or as clean as having one parameter that takes a number
> of flags/enums.
>
> As Corba already supports this, would I be asking too much for similiar
> support?
The "dbus way" to do this would be like dbus structs; on the wire it's
just raw data (like an int32 or uint32), and then the introspection data
and/or language binding may have a special interpretation for it.
i.e. in dbus there is no difference between
struct Foo (int a; int b; }
and
struct Bar (int x; int y; }
on the wire protocol level, only at the level of introspection or
bindings.
Similarly, if you have:
enum Foo { A, B, C }
and
enum Bar { X, Y, Z }
those will be the same (probably just an int with three allowed values)
If you're using libdbus directly then there's your problem; use a
binding, and improve that binding as required. libdbus is not intended
to be convenient, it's intended to be small(ish) and
least-common-denominator.
Havoc
More information about the dbus
mailing list