The public api is changed to require a context object for all
operations. Because other library objects store the context pointer
internally, only the constructor functions need an explicit context
object as a parameter.
An application can now register an application defined callback
function, which will perform the actual logging. This provides
additional flexibility compared to logging to stderr with a hardcoded
format. Applications can now easily display the messages in their user
interface, customize the format, etc.
Although the internal logging function is a printf like function, the
arguments are converted into a plain string before being passed to the
callback function. This greatly improves interoperability with
programming languages which don't support C style variadic functions
(e.g. Python, C#, etc).
With the introduction of a context object, library initialization and
shutdown can be performed without requiring any global state. A single
process can use multiple independent contexts without any problems. The
lack of a global state also improves the thread-safety of the library.
At the moment, the new context object is primary used to implement an
improved logging system.
The devinfo and clock event data is now cached internally at the device layer.
This allows the new dc_parser_new() convenience function to retrieve the event
data directly from the device handle, and applications don't have to deal with
the events anymore to create a parser.
With the introduction of the device descriptors, the new dc_device_open()
convenience function can take care of the mapping from a particular model to
the corresponding backend internally, without needing any device specific
knowledge in the application. An application can simply query the list of
supported devices, and the library will automatically do the right thing.
Applications can now enumerate all the supported devices at runtime,
and don't have to maintain their own list anymore. The internal list
does include only those devices that have been confirmed to work at
least once without any major problems.
As the name already indicates, a device descriptor is lightweight
object which describes a single device. Currently, the api supports
getting the device name (vendor and product) and model number. But
this can extended with other features when necessary.
Adding the "dc_" namespace prefix (which is of course an abbreviation
for libdivecomputer) should avoid conflicts with other libraries. For
the time being, only the high-level device and parser layers are
changed.
The public header files are moved to a new subdirectory, to separate
the definition of the public interface from the actual implementation.
Using an identical directory layout as the final installation has the
advantage that the example code can be build outside the project tree
without any modifications to the #include statements.