After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 771782 - Overload get_property(), so it can return value
Overload get_property(), so it can return value
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: object
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2016-09-21 18:48 UTC by Marcin Kolny (IRC: loganek)
Modified: 2016-11-24 14:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed solution (1.66 KB, patch)
2016-09-21 18:50 UTC, Marcin Kolny (IRC: loganek)
committed Details | Review

Description Marcin Kolny (IRC: loganek) 2016-09-21 18:48:59 UTC
Currently, to get a property from the object, you have to do the following:

T property_value; // declare object of property value type
obj->get_property("name", property_value); // get property value

However, it's very inconvenient, especially when you want to pass the value as an argument to a function.

I'm proposing the following API:

template<typename T>
T get_property(const Glib::ustring &property_name);

So we can easily get and use the property directly:

foo(obj->get_property<int>("name"));

I know that usually people should use property_*() API, but it's not a case in gstreamermm, where we can operate with dynamic elements.

If you don't want to add one more method to the Glib::ObjectBase, I'll do it only for Gst* classes, however, I think it's nice-to-have API in general.
Comment 1 Marcin Kolny (IRC: loganek) 2016-09-21 18:50:40 UTC
Created attachment 336026 [details] [review]
proposed solution
Comment 2 Kjell Ahlstedt 2016-09-23 15:19:20 UTC
I agree that your patch fits well in ObjectBase. Murray, do you agree?

We should just wait with pushing it to the git repository until a glibmm-2-50
branch has been created. It's not included in glibmm 2.50.0, and no new API
shall be added in any glibmm 2.50.x, x > 0.
Comment 3 Kjell Ahlstedt 2016-11-24 14:19:57 UTC
There is a gtkmm-2-50 branch now. I have pushed the patch to the master branch.