[Kde-hardware-devel] Using a bitmask for device types

Christopher Blauvelt cblauvelt at gmail.com
Wed Jan 11 12:03:31 CET 2006


What would you all think of using a bitmask for device class identification
rather than using strings.  This would have the advantage of using bit
comparison (usually about 1-4 cpu cycles or O(1)) rather than using string
comparison (many cpu cycles per letter or O(x)).  If using an unsigned
integer this would allow us to have 16 different device classes but more
importantly have multiple device contexts such as storage and camera in the
same device.  The code would look something like:

FakeDevice *dev;

    // Initialise a fake system
    dev = fakeManager->newDevice( "/fake/doeseverything2000" );
    dev->addCapability(STORAGE_DEVICE | CAMERA_DEVICE | FLYING_MACHINE);

Any thoughts?
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kde-hardware-devel/attachments/20060111/ae7e896c/attachment.html 


More information about the Kde-hardware-devel mailing list