[gst-devel] GstStructure mutability question

José Alburquerque jaalburquerque at cox.net
Mon Feb 11 22:07:14 CET 2008

David Schleef wrote:
> On Sun, Feb 10, 2008 at 09:41:20AM -0500, José Alburquerque wrote:
>> In trying to provide C++ bindings, I'm encountering a few difficulties 
>> with GstStructure immutability because in C++, inadvertently, an object 
>> such as a GstCaps may be referenced more than once by a simple C++ 
>> statement (by our design, of course) such as:
>> caps->set_simple("field1", value1)->set_simple("field2", 
>> value2)->set_simple("field3", val3);
> Could you come up with a better example?  You've changed the return
> value of set_simple, which seems like a dangerous path to follow for
> a language wrapper.
> dave...
A better example would be what happens with our RefPtr wrapper class 
(which wraps objects and automatically increments/decrements their 
references) and when it is "cast" (see this bug report I filed hoping 
for some possible solution: 

The reason we want  to design our Caps::set_simple() method to return a 
"pointer" (in fact it is our RefPtr wrapper class) to the caps is to 
allow the "chain of sets" you see above.  Your gst_caps_set_simple() 
returns void, so I don't really see where the danger would be.  There is 
a difference, of course, and that would be in the usage syntax.  We're 
debating whether to use this format or something else, but right now, we 
would really like to use it because due to our effort to be type safe, 
we are not implementing methods with variable arguments and this would 
make it easier for developers to "set" a series of values in 
GstStructure fields of the GstCaps (in C++).


More information about the gstreamer-devel mailing list