Yet another API evolution: multi-valued GrlData
- From: Guillaume Emont <gemont igalia com>
- To: grilo-list gnome org
- Subject: Yet another API evolution: multi-valued GrlData
- Date: Mon, 24 Jan 2011 19:02:32 +0100
Rationale: some fields might need to have several values, such as
thumbnails that can be provided in several resolutions, or description
provided in several languages, also, there could be more than one author
to a media.
The idea would be to have key-(value list) pairs instead of key-value
pairs. That idea can also be seen in ocaml's Hashtbl:
The present API would work by only addressing the first value of the list.
Then, we would need:
GList * grl_data_get_all (GrlData *data, GrlKeyID key);
Return a GList of all the GValue that have been set for key. The list
should be freed by the caller, but its content remain owned by the
GrlData object and should not be modified
The methods grl_data_set*() would change meaning, in that they will
prepend a value to the list of value. The "old" getters will get the
first value of the list.
Some "options" would probably make sense, like a _remove_all() and a
Then, for instance for the thumbnail case, a user that only want the
default thumbnail would do a simple:
thumbnail = grl_media_get_thumbnail (media);
But the use who want to chose among all those available would access two
keys: thumbnail and thumbnail-size, here is a very basic (and maybe
unpractical) example of use:
GList *thumbnails = grl_data_get_all (GRL_DATA (media),
GList *sizes = grl_data_get_all (GRL_DATA (media),
gchar *thumbnail_url = g_list_nth_data (thumbnails, g_list_index
Thoughts? Ideas? Alternatives?
] [Thread Prev