GNOME Bugzilla – Bug 663798
Add AbstractFieldDetails.value_type
Last modified: 2011-11-10 22:07:06 UTC
This would let us (and our clients) treat our AFD-derived classes in a more generic way. The my search branch for bug #646808 made this usefulness obvious (and I'm cherry-picking it for this bug to get it merged before that branch). For example, one could handle all AFD-derived classes without needing to switch between their specific types as in: if (FOLKS_IS_ABSTRACT_FIELD_DETAILS (fd)) { GType value_type = folks_abstract_field_details_get_value_type (FOLKS_ABSTRACT_FIELD_DETAILS (fd)); if (value_type == G_TYPE_STRING) handle_afd_str (fd); else if (value_type == FOLKS_TYPE_POSTAL_ADDRESS) handle_afd_postal_address (fd); else ... } This is particularly useful for the first case; most AFD-derived types have value_type G_TYPE_STRING, so this saves a bit of repetitive code. It also helps future-proof the code a bit (since it's possible we'll add more AFD<string> classes in the future.
Created attachment 201174 [details] [review] Add AbstractFieldDetails.value_type Patch from branch: http://cgit.collabora.com/git/user/treitter/folks.git/log/?h=bgo663798-add-afd-get-value-type
Review of attachment 201174 [details] [review]: Looks good to me.
commit 0719b657cacd96edfc2a7159c3228b5fc3e7969f Author: Travis Reitter <travis.reitter@collabora.co.uk> Date: Thu Nov 3 14:05:45 2011 -0700 Add AbstractFieldDetails.value_type. This allows generic handling of collections of derived objects of mixed concrete classes. Helps: bgo#663798 - Add AbstractFieldDetails.value_type NEWS | 2 + folks/abstract-field-details.vala | 14 ++++++++++ tests/folks/abstract-field-details.vala | 44 +++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 0 deletions(-)