On Tue, Jan 13, 2015 at 10:57 AM, Dmitriy Purgin <dpur...@gmail.com> wrote:
> Hello all, > > I'm developing a small Qt project for SailfishOS (a Linux distribution, > Meego descendant, Qt 5 based) and had to use some of PulseAudio (a sound > server for POSIX OSes) API functions which are pure C. I've wrapped them in > a couple of classes but it's evolving to something bigger now and I'm > trying to detach these into a shared library which seems to become a basic > PulseAudio binding. It's my first facading of a C library and I'm kind of > stuck on the architecture now and hope that someone can share ideas on > that. > Have you looked at the code generation done by QtGstreamer for glib stuff? Not sure if it's any good, just want to make sure you know of it: http://cgit.freedesktop.org/gstreamer/qt-gstreamer/tree/ > So with the problem stated, my question is: does anyone know any "good > practices" in designing this kind of relationships between classes or can > share similar designs to look at? There's no technical problem for me to > expose the inner parts of some classes to some other classes, I just > wondered if there's a subtle way of doing this. > I wrap a C library and had a similar situation. My solution in this case would be to give QtPulseAudioSource a new base class named something like PulseAudioInterface. That class defines pa_context, it could possibly just be a void pointer. It has a member variable for it and a setPulseAudioContext method. Then QtPulseAudioContext would have a class called something likeblessPulseAudioInterface. QtPulseAudioSource could call it in its constructor. In this way it is pretty hidden from users of the library, and QtPulseAudioContext has zero deps on AudioSource. Ian
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest