Non-libdivecomputer events

Jef Driesen jefdriesen at telenet.be
Thu Mar 7 04:58:36 PST 2013


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).

Jef


More information about the subsurface mailing list