[virt-tools-list] [libosinfo 4/6] API to add/list resources to/from Os
Zeeshan Ali (Khattak)
zeeshanak at gnome.org
Sat Sep 10 00:05:02 UTC 2011
From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
Add API to add/list minimum and recommended resources to/from Os.
---
docs/reference/Libosinfo-sections.txt | 4 ++
osinfo/libosinfo.syms | 4 ++
osinfo/osinfo_os.c | 75 +++++++++++++++++++++++++++++++++
osinfo/osinfo_os.h | 6 +++
4 files changed, 89 insertions(+), 0 deletions(-)
diff --git a/docs/reference/Libosinfo-sections.txt b/docs/reference/Libosinfo-sections.txt
index 81dfb2a..3135460 100644
--- a/docs/reference/Libosinfo-sections.txt
+++ b/docs/reference/Libosinfo-sections.txt
@@ -114,6 +114,10 @@ osinfo_os_add_device
osinfo_os_get_family
osinfo_os_get_media_list
osinfo_os_add_media
+osinfo_os_get_minimum_resources
+osinfo_os_get_recommended_resources
+osinfo_os_set_minimum_resources
+osinfo_os_set_recommended_resources
<SUBSECTION Standard>
OSINFO_OS
OSINFO_IS_OS
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 30df286..fbd9559 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -113,6 +113,10 @@ LIBOSINFO_0.0.1 {
osinfo_os_get_family;
osinfo_os_get_media_list;
osinfo_os_add_media;
+ osinfo_os_get_minimum_resources;
+ osinfo_os_get_recommended_resources;
+ osinfo_os_set_minimum_resources;
+ osinfo_os_set_recommended_resources;
osinfo_oslist_get_type;
osinfo_oslist_new;
osinfo_oslist_new_copy;
diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
index 117e000..bc013aa 100644
--- a/osinfo/osinfo_os.c
+++ b/osinfo/osinfo_os.c
@@ -46,6 +46,8 @@ struct _OsinfoOsPrivate
GList *deviceLinks;
OsinfoMediaList *medias;
+ OsinfoResourcesList *minimum;
+ OsinfoResourcesList *recommended;
};
struct _OsinfoOsDeviceLink {
@@ -139,6 +141,8 @@ osinfo_os_init (OsinfoOs *os)
os->priv->deviceLinks = NULL;
os->priv->medias = osinfo_medialist_new ();
+ os->priv->minimum = osinfo_resourceslist_new ();
+ os->priv->recommended = osinfo_resourceslist_new ();
}
/**
@@ -296,6 +300,77 @@ void osinfo_os_add_media(OsinfoOs *os, OsinfoMedia *media)
osinfo_list_add(OSINFO_LIST(os->priv->medias), OSINFO_ENTITY(media));
}
+/**
+ * osinfo_os_get_minimum_resources:
+ * @os: an operating system
+ *
+ * Get the list of minimum required resources for the operating system @os.
+ *
+ * Returns: (transfer full): A list of resources
+ */
+OsinfoResourcesList *osinfo_os_get_minimum_resources(OsinfoOs *os)
+{
+ g_return_val_if_fail(OSINFO_IS_OS(os), NULL);
+
+ OsinfoResourcesList *newList = osinfo_resourceslist_new();
+
+ osinfo_list_add_all(OSINFO_LIST(newList), OSINFO_LIST(os->priv->minimum));
+
+ return newList;
+}
+
+/**
+ * osinfo_os_get_recommended_resources:
+ * @os: an operating system
+ *
+ * Get the list of recommended resources for the operating system @os.
+ *
+ * Returns: (transfer full): A list of resources
+ */
+OsinfoResourcesList *osinfo_os_get_recommended_resources(OsinfoOs *os)
+{
+ g_return_val_if_fail(OSINFO_IS_OS(os), NULL);
+
+ OsinfoResourcesList *newList = osinfo_resourceslist_new();
+
+ osinfo_list_add_all(OSINFO_LIST(newList),
+ OSINFO_LIST(os->priv->recommended));
+
+ return newList;
+}
+
+/**
+ * osinfo_os_add_minimum_resources:
+ * @os: an operating system
+ * @resources: (transfer none): the resources to add
+ *
+ * Adds @resources to list of minimum resources of operating system @os.
+ */
+void osinfo_os_add_minimum_resources(OsinfoOs *os, OsinfoResources *resources)
+{
+ g_return_if_fail(OSINFO_IS_OS(os));
+ g_return_if_fail(OSINFO_IS_RESOURCES(resources));
+
+ osinfo_list_add(OSINFO_LIST(os->priv->minimum), OSINFO_ENTITY(resources));
+}
+
+/**
+ * osinfo_os_add_recommended_resources:
+ * @os: an operating system
+ * @resources: (transfer none): the resources to add
+ *
+ * Adds @resources to list of recommended resources of operating system @os.
+ */
+void osinfo_os_add_recommended_resources(OsinfoOs *os,
+ OsinfoResources *resources)
+{
+ g_return_if_fail(OSINFO_IS_OS(os));
+ g_return_if_fail(OSINFO_IS_RESOURCES(resources));
+
+ osinfo_list_add(OSINFO_LIST(os->priv->recommended),
+ OSINFO_ENTITY(resources));
+}
+
/*
* Local variables:
* indent-tabs-mode: nil
diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h
index d1a0f9b..db39594 100644
--- a/osinfo/osinfo_os.h
+++ b/osinfo/osinfo_os.h
@@ -28,6 +28,8 @@
#include <osinfo/osinfo_devicelist.h>
#include <osinfo/osinfo_medialist.h>
#include <osinfo/osinfo_media.h>
+#include <osinfo/osinfo_resources.h>
+#include <osinfo/osinfo_resourceslist.h>
#ifndef __OSINFO_OS_H__
#define __OSINFO_OS_H__
@@ -80,6 +82,10 @@ OsinfoDeviceLink *osinfo_os_add_device(OsinfoOs *os, OsinfoDevice *dev);
const gchar *osinfo_os_get_family(OsinfoOs *os);
OsinfoMediaList *osinfo_os_get_media_list(OsinfoOs *os);
void osinfo_os_add_media(OsinfoOs *os, OsinfoMedia *media);
+OsinfoResourcesList *osinfo_os_get_minimum_resources(OsinfoOs *os);
+OsinfoResourcesList *osinfo_os_get_recommended_resources(OsinfoOs *os);
+void osinfo_os_add_minimum_resources(OsinfoOs *os, OsinfoResources *resources);
+void osinfo_os_add_recommended_resources(OsinfoOs *os, OsinfoResources *resources);
#endif /* __OSINFO_OS_H__ */
/*
--
1.7.6
More information about the virt-tools-list
mailing list