GUPnPResourceFactory

As soon as I started to write gupnp-av-cp, I realized that I need to subclass resource (device and service) proxy classes but the resource proxies are created by the control point object on discovery and there was no way of telling control point to create objects of your subclass instead. The obvious solution that comes to mind is to add an API to control point for registering your subclass' gtype against a UPnP resource type. Unfortunately, that won't work since device proxies also create device proxies for embedded proxies and services.

So the final solution, which is already implemented and committed to svn is a separate class, GUPnPResourceFactory whose sole responsibility is to create resource and resource proxy objects and to provide an API for registering and unregistering UPnP resource type to gtype assignments. Each GUPnPControlPoint and GUPnPDeviceInfo-derived object is assigned a GUPnPResourceFactory object on creation. You can get a pointer to the factory used by the control point or root device by using the appropriate getter function. Once you have the factory, you can simply register and unregister your subclasses to it.

Comments

Popular posts from this blog

Welcome to the virtual world!

clutter-gst

Shame Ubuntu shame