Re: Casting from a wrapped class to a possible implemented interface



On Sun, 2008-03-02 at 01:57 -0500, José Alburquerque wrote:
> Is it possible to cast a class that in its declaration 
> does not by default implement a certain interface and then cast it's 
> RefPtr to the interface (assuming that the C object implements the 
> interface)?

Generally, no.

> In gstreamer, the GstImplementsInterface 
> <http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstImplementsInterface.html> 
> has functionality to test if an Element implements an interface 
> (gst_element_implements_interface 
> <http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstImplementsInterface.html#gst-element-implements-interface>) 
> and to cast to that interface if necessary 
> (gst_implements_interface_cast() 
> <http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstImplementsInterface.html#gst-implements-interface-cast>) 
> and I thought maybe this functionality can be used to cast from a 
> wrapped Gst::Element to a RefPtr of the interface.  Would this make
> sense?

This would cause us to have two C++ instances with the same underlying C
instance. I wonder if that would have any bad side-effects. You would
probably have to avoid using Glib::wrap(), because it assumes a 1-to-1
mapping.

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]