Hi Everyone<br><br>I'd like to announce that i've begun work on a libhal C++ wrapper, first starting with the core libhal, and next will be libhal-storage. The API is very similar to e.g. cairomm or glibmm, using RefPtrs, etc.
<br><br>So far we have 2 basic first-class objects, HAL::Context and HAL::Device, HAL::Device being a "virtual" class in the sense that it has no direct representation in the C API (rather the context can be used to acquire information about devices); HAL::Device is basically just a convenience class to bundle methods and manage state related to a device.
<br><br>(I'd also like to put attention onto the fact that the API is mostly/solely geared towards applications, and hence does not implement, for now at least, things that e.g. hald-addon daemons would use, since these are likely to be just written in C anyway).
<br><br>The PS/PSI system is also wrapped in an STL like fashion and can be quite well integrated with standard C++ code.<br><br><br>Here's an usage example, it is included in the halcc-0.1.tar.gz tarball:<br><br><br><span style="font-family: courier new,monospace;">
</span><span style="font-family: courier new,monospace;">#include <iostream></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">
#include <dbus/dbus.h></span><br><span style="font-family: courier new,monospace;">#include <hal++/hal++-types.hh></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
#include <hal++/hal++-context.hh></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#include <hal++/hal++-device.hh></span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">int main (int argc, char** argv)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> DBusError error;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> dbus_error_init (&error);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> DBusConnection * c = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> HAL::RefPtr<HAL::Context> context = HAL::Context::create (c);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><br> HAL::StrV list (context->find_device_by_capability ("volume"));</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
for (HAL::StrV::const_iterator i = list.begin (); i != list.end (); ++i)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> HAL::RefPtr<HAL::Device> device = HAL::Device::create (context, *i);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
if (device->get_property <bool> ("volume.is_mounted"))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> std::cerr << "Volume with UDI '" <br> << *i << "' is mounted on '"
<br> << </span><span style="font-family: courier new,monospace;">device->get_property <std::string> ("volume.mount_point")</span><br><span style="font-family: courier new,monospace;">
<< "'" << std::endl;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<br>I've set up a small website on our project wiki here: <br><a href="http://projects.beep-media-player.org/index.php/Main/HAL">http://projects.beep-media-player.org/index.php/Main/HAL</a><br><br>Regards,<br>Milosz<br><br>