API redesign progress

Jef Driesen jefdriesen at telenet.be
Fri Jun 22 04:51:59 PDT 2012


Hi,

I have committed some several backwards incompatible changes to the 
libdivecomputer api. To keep the inconvenience to a minimum, a stable 
"release-0.1" branch has been created, which will only receive pure 
bugfixes. Applications are recommended to stick to this stable branch 
for now. Especially because these changes are only the first in a 
series, and backwards compatibility will be broken again in the master 
branch.

In a nutshell, the most important changes are:

  * Introduce a namespace prefix for the high-level public api.
  * Use common status codes and backend type.

All functions, structs and enums in the device.h and parser.h headers 
have been renamed. The {device,parser}_status_t enums have been merged 
into a single dc_status_t enum. Similarly, the {device,parser}_type_t 
enums have been merged into a single dc_family_t enum. Although there is 
no functional change, this has a significant impact on the entire api 
and breaks backward compatibility.

  * Add device enumeration support.

With the new device enumeration support, applications can now enumerate 
all the supported devices at runtime, and don't have to maintain their 
own list anymore. The api uses an iterator style interface. See 
universal.c for some example code.

  * Add dc_device_open() and dc_parser_new() convenience functions.

With these new convenience functions, most applications won't need to 
use the device specific xxx_device_open() and xxx_parser_create() 
functions anymore. This has the advantage that you don't have add or 
change any code to support new models and/or backends. Again, see 
universal.c for example code.

As usual, feedback is always welcome!

Jef


More information about the subsurface mailing list