[virt-tools-list] [libosinfo] Utility function to retrieve OS devices by property
Zeeshan Ali (Khattak)
zeeshanak at gnome.org
Tue Jan 24 03:36:57 UTC 2012
From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
---
osinfo/libosinfo.syms | 1 +
osinfo/osinfo_os.c | 33 +++++++++++++++++++++++++++++++++
osinfo/osinfo_os.h | 4 ++++
3 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index de1ff18..0817185 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -109,6 +109,7 @@ LIBOSINFO_0.0.6 {
osinfo_os_new;
osinfo_os_get_devices;
osinfo_os_get_all_devices;
+ osinfo_os_get_devices_by_property;
osinfo_os_get_device_links;
osinfo_os_add_device;
osinfo_os_get_family;
diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
index 0facb08..39806d9 100644
--- a/osinfo/osinfo_os.c
+++ b/osinfo/osinfo_os.c
@@ -238,6 +238,39 @@ OsinfoDeviceList *osinfo_os_get_all_devices(OsinfoOs *os, OsinfoFilter *filter)
}
/**
+ * osinfo_os_get_devices_by_property:
+ * @os: an operating system
+ * @property: the property of interest
+ * @value: the required value of property @property
+ * @inherited: Should devices from inherited and cloned OSs be included in the
+ * search.
+ *
+ * A utility function that gets devices found from the list of devices
+ * @os supports, for which the value of @property is @value.
+ *
+ * Returns: (transfer full): The found devices
+ */
+OsinfoDeviceList *osinfo_os_get_devices_by_property(OsinfoOs *os,
+ const gchar *property,
+ const gchar *value,
+ gboolean inherited)
+{
+ OsinfoDeviceList *devices;
+ OsinfoFilter *filter;
+
+ filter = osinfo_filter_new();
+ osinfo_filter_add_constraint(filter, property, value);
+
+ if (inherited)
+ devices = osinfo_os_get_all_devices(os, filter);
+ else
+ devices = osinfo_os_get_devices(os, filter);
+ g_object_unref (filter);
+
+ return devices;
+}
+
+/**
* osinfo_os_get_device_links:
* @os: an operating system
* @filter: (allow-none)(transfer none): an optional device property filter
diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h
index e1daff1..13c1aba 100644
--- a/osinfo/osinfo_os.h
+++ b/osinfo/osinfo_os.h
@@ -77,6 +77,10 @@ OsinfoOs *osinfo_os_new(const gchar *id);
OsinfoDeviceList *osinfo_os_get_devices(OsinfoOs *os, OsinfoFilter *filter);
OsinfoDeviceList *osinfo_os_get_all_devices(OsinfoOs *os, OsinfoFilter *filter);
+OsinfoDeviceList *osinfo_os_get_devices_by_property(OsinfoOs *os,
+ const char *property,
+ const char *value,
+ gboolean inherited);
OsinfoDeviceLinkList *osinfo_os_get_device_links(OsinfoOs *os, OsinfoFilter *filter);
OsinfoDeviceLink *osinfo_os_add_device(OsinfoOs *os, OsinfoDevice *dev);
--
1.7.7.5
More information about the virt-tools-list
mailing list