src/hg/lib/trackDbCustom.c 1.82
1.82 2010/04/01 23:51:09 tdreszer
Added extras hash to the tdb struct and 2 APIs to use it
Index: src/hg/lib/trackDbCustom.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/trackDbCustom.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -b -B -U 4 -r1.81 -r1.82
--- src/hg/lib/trackDbCustom.c 25 Mar 2010 17:27:26 -0000 1.81
+++ src/hg/lib/trackDbCustom.c 1 Apr 2010 23:51:09 -0000 1.82
@@ -799,8 +799,11 @@
}
return tdb;
}
+// TODO: metadata as a trackDb will be obsoleted soon so these routines should be removed.
+// TODO: metadata as a trackDb will be obsoleted soon so these routines should be removed.
+// TODO: metadata as a trackDb will be obsoleted soon so these routines should be removed.
metadata_t *metadataSettingGet(struct trackDb *tdb)
/* Looks for a metadata tag and parses the setting into arrays of tags and values */
{
char *setting = trackDbSetting(tdb, "metadata");
@@ -878,8 +881,35 @@
}
metadataFree(&metadata);
return setting;
}
+// TODO: metadata as a trackDb will be obsoleted soon so these routines should be removed.
+// TODO: metadata as a trackDb will be obsoleted soon so these routines should be removed.
+// TODO: metadata as a trackDb will be obsoleted soon so these routines should be removed.
+
+void tdbExtrasAddOrUpdate(struct trackDb *tdb,char *name,void *value)
+/* Adds some "extra" nformation to the extras hash. Creates hash if necessary. */
+{
+if(tdb->extras == NULL)
+ {
+ tdb->extras = hashNew(0);
+ hashAdd(tdb->extras, name, value);
+ }
+else
+ {
+ hashReplace(tdb->extras, name, value);
+ }
+}
+
+void *tdbExtrasGetOrDefault(struct trackDb *tdb,char *name,void *defaultVal)
+/* Returns a value if it is found in the extras hash. */
+{
+if(tdb->extras == NULL)
+ return defaultVal;
+
+return hashOptionalVal(tdb->extras, name, defaultVal);
+
+}
struct trackDb *trackDbLinkUpGenerations(struct trackDb *tdbList)
/* Convert a list to a forest - filling in parent and subtrack pointers.
* The exact topology of the forest is a little complex due to the