Base class design and properties

Carlos Rafael Giani dv at pseudoterminal.org
Sat Jun 22 11:18:37 PDT 2013


Okay, after further digging, it seems that the can-foo property idea is 
indeed the only possible one.
Just leaving this in case anybody else has a similar problem.

> Hello,
>
> I am currently designing a base class, and noticed that some subclasses
> may not require some properties, while others might.
>
> Looking at the existing GStreamer base classes, it turned out that the 
> same issue exists,
> and is handled by simply letting the subclass ignore these properties. 
> An example is the
> GstAudioDecoder class and its plc property. This property is always 
> present, even if the
> subclass does not support any packet loss concealment.
>
> I could do that if a property is simply a boolean. It becomes more 
> problematic if it is
> for example an enum, and some subclasses only support a subset of the 
> enum values.
>
> Perhaps the subclass could add a second, read-only property, 
> indicating the range of valid
> values? For example, if there is an enum property "foo", with the 
> possible values being
> "a", "b", "c", then there could be function the subclass can use to 
> install a "can-foo" property,
> and define which one of a/b/c it supports. Applications then know what 
> the subclass can do.
> So, if the subclass supported only "b" and "c", it could call in its 
> class_init function something
> like baseclass_set_foo_property_valid_values(baseclass, B, C);
> of course, this means the base class would have to define this 
> function for property foo.
>
> Any thoughts?
>
> cheers
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list