[Ekiga-devel-list] [PWLIB] PNoCollisionDictionary



Hi,

working on fixing the following bug :
http://bugzilla.gnome.org/show_bug.cgi?id=332442

I created a class to store device information a little differently ; the
basic idea was to make collisions impossible, but in fact it allows more
freedom on what a device description is.

It's a sort of dictionary where when you add : "/device/foo" under the
key "My device", then you add "/device/bar" under the same key, it
really stores it under the "My device [2]" key. This means
duplicate-named devices don't collide anymore.

The added bonus is that you can associate any PObject type to the keys,
so you can have :
class GSTDevice: public PObject
{
  /* very specific description involving several strings
   * and/or integers */

  /* remember to implement a simple PrintOn method */
};

then do :
static PNoCollisionDictionary<GSTDevice> playerDevices;
static PNoCollisionDictionary<GSTDevice> recorderDevices;

the GetDeviceNames method then initializes those dictionary, and Open does :
device = playerDevices[_device];
where _device is the PString and device a GSTDevice.

I made a patch so the ALSA plugin uses it, and the experimental
gstreamer plugins use it already.

I find it quite convenient (apart from the awful name), so I think it
could be worth putting in pwlib.

Snark



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]