[gt-users] Attach user data to GtGenomeNodes

Gordon Gremme gremme at gmail.com
Thu Feb 19 17:50:45 CET 2009


>> Since the memory consumption of GenomeNodes is very critical, I would
>> add a single pointer to it. The pointer then holds the ``dictionary''
>> (whatever is used) on demand. I.e., the object to store the user data
>> objects would be created when the first user data is added and removed
>> when the last user data is removed.
>> What do you think?
>
> Sounds about as economical as it could get.
> I propose the following interface (e.g. wrapping a hash map):
>
> void gt_genome_node_add_user_data(GtGenomeNode *node,
>                                   void *key,
>                                   void *data,
>                                   GtFree free_func);
> void *gt_genome_node_get_user_data(const GtGenomeNode *node,
>                                    void *key);
> void gt_genome_node_release_user_data(GtGenomeNode *node,
>                                       void *key);

Looks good to me. Would gt_genome_node_release_user_data() also free
the user data object?


> Do you think we should introduce a free-function for the key as well,
> like in the generic hashmap class?

I don't think so. We should agree upon a convention on what is used as
key. My suggestion would be the constructor method of the user data
object.

Gordon


More information about the gt-users mailing list