Non-libdivecomputer events

Dirk Hohndel dirk at hohndel.org
Thu Mar 7 07:52:53 PST 2013


On Mar 7, 2013, at 4:58 AM, Jef Driesen wrote:

> On 2013-03-07 09:17, Robert C. Helling wrote:
>> I was thinking about making subsurface aware of pictures taken during
>> the dive (basically by matching EXIF timestamps to the time during the
>> dive). My idea was to do this by adding extra events to a dive that
>> indicate the time at which a picture was taken and for example the
>> path to the image.
>> 
>> This opens the question of how to add events that do not come from
>> libdivecomputer.  Of course I could just make up a high number as
>> event type and hope we will never get a conflict but maybe you could
>> set aside some events in you include/libdivecomputer/parser.h as
>> reserved (or maybe even SAMPLE_EVENT_IMAGE) even when libdivecomputer
>> does not use them.
> 
> I'm absolutely not convinced that's the right way to approach the problem. Adding a special constant to libdivecomputer for a feature in subsurface is just wrong. Imagine the mess if every application requests their own set of constants...
> 
> The right way to achieve this, is to define your own enum in subsurface, and then map the libdivecomputer values into the subsurface ones. Then you can have as many as you wish, without any concerns of conflicting with the libdivecomputer ones.
> 
> For a short time solution, you can just start with a reasonably high number like 0xFF or 0xFFFF for the subsurface specific values. The number of libdivecomputer events is unlikely to grow that high in the near future (or ever if you pick 0xFFFF).

I guess libdivecomputer could pick ONE value that it defines as "SAMPLE_EVENT_NOTUSED". But even that isn't really necessary. All we need to do is add another member to our structure and if that member is non-NULL ignore the libdc event number and use that number instead.

But all this is pretty moot as well as we actually don't USE the number anywhere in Subsurface as far as I remember. I believe all of the code we have so far triggers on the event names instead.


/D
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4130 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130307/4c1ab82f/attachment.bin>


More information about the subsurface mailing list