summaryrefslogtreecommitdiff
path: root/osinfo/osinfo_db.c
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2012-12-07 13:01:26 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2012-12-13 17:18:47 +0100
commitc983335d82cb3b9915be7bc28c784d9526679b77 (patch)
tree5751ecda80d3c090175dc382823318b12b8498ee /osinfo/osinfo_db.c
parente8ac9735b1f41a3325c61cd851af3b7b32f02373 (diff)
downloadlibosinfo-c983335d82cb3b9915be7bc28c784d9526679b77.tar.gz
loader: Load datamaps
Install scripts can add a 'datamap' attribute when they declare their config parameters. The value of this attribute is the ID of a datamap, which is an XML file containing key/value pairs: <?xml version="1.0" encoding="UTF-8"?> <libosinfo version="0.0.1"> <datamap id="http://example.com/osinfo/test"> <entry inval="generic-val1" outval="foo"/> <entry> inval="generic-val2" outval="bar"/> </datamap> </libosinfo> This commit adds support for loading these datamaps. The next patches will then make use of these datamaps when the libosinfo user set a value for the corresponding config parameter.
Diffstat (limited to 'osinfo/osinfo_db.c')
-rw-r--r--osinfo/osinfo_db.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
index c17c512..dcda2fe 100644
--- a/osinfo/osinfo_db.c
+++ b/osinfo/osinfo_db.c
@@ -53,6 +53,7 @@ struct _OsinfoDbPrivate
OsinfoPlatformList *platforms;
OsinfoOsList *oses;
OsinfoDeploymentList *deployments;
+ OsinfoDatamapList *datamaps;
OsinfoInstallScriptList *scripts;
};
@@ -67,6 +68,7 @@ osinfo_db_finalize (GObject *object)
g_object_unref(db->priv->platforms);
g_object_unref(db->priv->oses);
g_object_unref(db->priv->deployments);
+ g_object_unref(db->priv->datamaps);
g_object_unref(db->priv->scripts);
/* Chain up to the parent class */
@@ -96,6 +98,7 @@ osinfo_db_init (OsinfoDb *db)
db->priv->platforms = osinfo_platformlist_new();
db->priv->oses = osinfo_oslist_new();
db->priv->deployments = osinfo_deploymentlist_new();
+ db->priv->datamaps = osinfo_datamaplist_new();
db->priv->scripts = osinfo_install_scriptlist_new();
}
@@ -173,6 +176,22 @@ OsinfoDeployment *osinfo_db_get_deployment(OsinfoDb *db, const gchar *id)
}
/**
+ * osinfo_db_get_datamap:
+ * @db: the database
+ * @id: the unique operating system identifier
+ *
+ * Returns: (transfer none): the install datamap, or NULL if none is found
+ */
+OsinfoDatamap *osinfo_db_get_datamap(OsinfoDb *db, const gchar *id)
+{
+ g_return_val_if_fail(OSINFO_IS_DB(db), NULL);
+ g_return_val_if_fail(id != NULL, NULL);
+
+ return OSINFO_DATAMAP(osinfo_list_find_by_id(OSINFO_LIST(db->priv->datamaps), id));
+}
+
+
+/**
* osinfo_db_get_install_script:
* @db: the database
* @id: the unique operating system identifier
@@ -297,6 +316,23 @@ OsinfoDeploymentList *osinfo_db_get_deployment_list(OsinfoDb *db)
/**
+ * osinfo_db_get_install_datamap_list:
+ * @db: the database
+ *
+ * Returns: (transfer full): the list of install datamaps
+ */
+OsinfoDatamapList *osinfo_db_get_datamap_list(OsinfoDb *db)
+{
+ OsinfoList *new_list;
+
+ g_return_val_if_fail(OSINFO_IS_DB(db), NULL);
+ new_list = osinfo_list_new_copy(OSINFO_LIST(db->priv->datamaps));
+
+ return OSINFO_DATAMAPLIST(new_list);
+}
+
+
+/**
* osinfo_db_get_install_script_list:
* @db: the database
*
@@ -374,6 +410,21 @@ void osinfo_db_add_deployment(OsinfoDb *db, OsinfoDeployment *deployment)
/**
+ * osinfo_db_add_datamap:
+ * @db: the database
+ * @datamap: (transfer none): a install datamap
+ *
+ */
+void osinfo_db_add_datamap(OsinfoDb *db, OsinfoDatamap *datamap)
+{
+ g_return_if_fail(OSINFO_IS_DB(db));
+ g_return_if_fail(OSINFO_IS_DATAMAP(datamap));
+
+ osinfo_list_add(OSINFO_LIST(db->priv->datamaps), OSINFO_ENTITY(datamap));
+}
+
+
+/**
* osinfo_db_add_install_script:
* @db: the database
* @script: (transfer none): a install script