[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [libosinfo 02/10] Add DeviceDriverList class



From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>

OsinfoDeviceDriverList is a list specialization that stores only
OsinfoDeviceDriver objects.
---
 osinfo/Makefile.am                |   2 +
 osinfo/libosinfo.syms             |   7 ++
 osinfo/osinfo.h                   |   1 +
 osinfo/osinfo_device_driverlist.c | 171 ++++++++++++++++++++++++++++++++++++++
 osinfo/osinfo_device_driverlist.h |  93 +++++++++++++++++++++
 5 files changed, 274 insertions(+)
 create mode 100644 osinfo/osinfo_device_driverlist.c
 create mode 100644 osinfo/osinfo_device_driverlist.h

diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index 996a498..1cbacea 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -60,6 +60,7 @@ libosinfo_1_0_include_HEADERS = \
   osinfo_loader.h		\
   osinfo_device.h		\
   osinfo_device_driver.h	\
+  osinfo_device_driverlist.h	\
   osinfo_devicelink.h		\
   osinfo_devicelist.h		\
   osinfo_devicelinklist.h	\
@@ -98,6 +99,7 @@ libosinfo_1_0_la_SOURCES =	  \
   osinfo_device.c		  \
   osinfo_device_driver.c	  \
   osinfo_device_driver_private.h  \
+  osinfo_device_driverlist.c	  \
   osinfo_devicelink.c		  \
   osinfo_devicelist.c		  \
   osinfo_devicelinklist.c	  \
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 09c0d3e..0f1d751 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -330,6 +330,13 @@ LIBOSINFO_0.2.2 {
 	osinfo_device_driver_get_files;
 	osinfo_device_driver_get_pre_installable;
 
+	osinfo_device_driverlist_get_type;
+	osinfo_device_driverlist_new;
+	osinfo_device_driverlist_new_copy;
+	osinfo_device_driverlist_new_filtered;
+	osinfo_device_driverlist_new_intersection;
+	osinfo_device_driverlist_new_union;
+
 	osinfo_install_config_param_policy_get_type;
 	osinfo_media_error_get_type;
 	osinfo_product_relationship_get_type;
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index 7acd70a..836baf1 100644
--- a/osinfo/osinfo.h
+++ b/osinfo/osinfo.h
@@ -33,6 +33,7 @@
 #include <osinfo/osinfo_list.h>
 #include <osinfo/osinfo_device.h>
 #include <osinfo/osinfo_device_driver.h>
+#include <osinfo/osinfo_device_driverlist.h>
 #include <osinfo/osinfo_devicelink.h>
 #include <osinfo/osinfo_devicelist.h>
 #include <osinfo/osinfo_devicelinklist.h>
diff --git a/osinfo/osinfo_device_driverlist.c b/osinfo/osinfo_device_driverlist.c
new file mode 100644
index 0000000..fecc124
--- /dev/null
+++ b/osinfo/osinfo_device_driverlist.c
@@ -0,0 +1,171 @@
+/*
+ * libosinfo: Device driver list
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Zeeshan Ali <zeenix redhat com>
+ *   Arjun Roy <arroy redhat com>
+ *   Daniel P. Berrange <berrange redhat com>
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+#include <glib/gi18n-lib.h>
+
+G_DEFINE_TYPE (OsinfoDeviceDriverList, osinfo_device_driverlist, OSINFO_TYPE_LIST);
+
+#define OSINFO_DEVICE_DRIVERLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DEVICE_DRIVERLIST, OsinfoDeviceDriverListPrivate))
+
+/**
+ * SECTION:osinfo_device_driverlist
+ * @short_description: A list of device drivers
+ * @see_also: #OsinfoList, #OsinfoDeviceDriver
+ *
+ * #OsinfoDeviceDriverList is a list specialization that stores only
+ * #OsinfoDeviceDriver objects.
+ */
+
+struct _OsinfoDeviceDriverListPrivate
+{
+    gboolean unused;
+};
+
+static void
+osinfo_device_driverlist_finalize (GObject *object)
+{
+    /* Chain up to the parent class */
+    G_OBJECT_CLASS (osinfo_device_driverlist_parent_class)->finalize (object);
+}
+
+/* Init functions */
+static void
+osinfo_device_driverlist_class_init (OsinfoDeviceDriverListClass *klass)
+{
+    GObjectClass *g_klass = G_OBJECT_CLASS (klass);
+
+    g_klass->finalize = osinfo_device_driverlist_finalize;
+    g_type_class_add_private (klass, sizeof (OsinfoDeviceDriverListPrivate));
+}
+
+static void
+osinfo_device_driverlist_init (OsinfoDeviceDriverList *list)
+{
+    OsinfoDeviceDriverListPrivate *priv;
+    list->priv = priv = OSINFO_DEVICE_DRIVERLIST_GET_PRIVATE(list);
+
+}
+
+/**
+ * osinfo_device_driverlist_new:
+ *
+ * Construct a new device driver list that is initially empty.
+ *
+ * Returns: (transfer full): an empty device driver list
+ */
+OsinfoDeviceDriverList *osinfo_device_driverlist_new(void)
+{
+    return g_object_new(OSINFO_TYPE_DEVICE_DRIVERLIST,
+                        "element-type", OSINFO_TYPE_DEVICE_DRIVER,
+                        NULL);
+}
+
+/**
+ * osinfo_device_driverlist_new_copy:
+ * @source: the device driver list to copy
+ *
+ * Construct a new device driver list that is filled with device drivers
+ * from @source
+ *
+ * Returns: (transfer full): a copy of the device driver list
+ */
+OsinfoDeviceDriverList *osinfo_device_driverlist_new_copy(OsinfoDeviceDriverList *source)
+{
+    OsinfoDeviceDriverList *newList = osinfo_device_driverlist_new();
+    osinfo_list_add_all(OSINFO_LIST(newList),
+                        OSINFO_LIST(source));
+    return newList;
+}
+
+/**
+ * osinfo_device_driverlist_new_filtered:
+ * @source: the device driver list to copy
+ * @filter: the filter to apply
+ *
+ * Construct a new device driver list that is filled with device drivers
+ * from @source that match @filter
+ *
+ * Returns: (transfer full): a filtered copy of the device driver list
+ */
+OsinfoDeviceDriverList *osinfo_device_driverlist_new_filtered(OsinfoDeviceDriverList *source,
+                                                              OsinfoFilter *filter)
+{
+    OsinfoDeviceDriverList *newList = osinfo_device_driverlist_new();
+    osinfo_list_add_filtered(OSINFO_LIST(newList),
+                             OSINFO_LIST(source),
+                             filter);
+    return newList;
+}
+
+/**
+ * osinfo_device_driverlist_new_intersection:
+ * @sourceOne: the first device driver list to copy
+ * @sourceTwo: the second device driver list to copy
+ *
+ * Construct a new device driver list that is filled with only the
+ * device drivers that are present in both @sourceOne and @sourceTwo.
+ *
+ * Returns: (transfer full): an intersection of the two device driver lists
+ */
+OsinfoDeviceDriverList *osinfo_device_driverlist_new_intersection(OsinfoDeviceDriverList *sourceOne,
+                                                                  OsinfoDeviceDriverList *sourceTwo)
+{
+    OsinfoDeviceDriverList *newList = osinfo_device_driverlist_new();
+    osinfo_list_add_intersection(OSINFO_LIST(newList),
+                                 OSINFO_LIST(sourceOne),
+                                 OSINFO_LIST(sourceTwo));
+    return newList;
+}
+
+/**
+ * osinfo_device_driverlist_new_union:
+ * @sourceOne: the first device driver list to copy
+ * @sourceTwo: the second device driver list to copy
+ *
+ * Construct a new device driver list that is filled with all the
+ * device drivers that are present in either @sourceOne and @sourceTwo.
+ *
+ * Returns: (transfer full): a union of the two device driver lists
+ */
+OsinfoDeviceDriverList *osinfo_device_driverlist_new_union(OsinfoDeviceDriverList *sourceOne,
+                                                           OsinfoDeviceDriverList *sourceTwo)
+{
+    OsinfoDeviceDriverList *newList = osinfo_device_driverlist_new();
+    osinfo_list_add_union(OSINFO_LIST(newList),
+                          OSINFO_LIST(sourceOne),
+                          OSINFO_LIST(sourceTwo));
+    return newList;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_device_driverlist.h b/osinfo/osinfo_device_driverlist.h
new file mode 100644
index 0000000..39724a8
--- /dev/null
+++ b/osinfo/osinfo_device_driverlist.h
@@ -0,0 +1,93 @@
+/*
+ * libosinfo: Device driver list
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Zeeshan Ali <zeenix redhat com>
+ *   Arjun Roy <arroy redhat com>
+ *   Daniel P. Berrange <berrange redhat com>
+ */
+
+#include <glib-object.h>
+#include <osinfo/osinfo_list.h>
+
+#ifndef __OSINFO_DEVICE_DRIVERLIST_H__
+#define __OSINFO_DEVICE_DRIVERLIST_H__
+
+/*
+ * Type macros.
+ */
+#define OSINFO_TYPE_DEVICE_DRIVERLIST                  (osinfo_device_driverlist_get_type ())
+#define OSINFO_DEVICE_DRIVERLIST(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+                                                        OSINFO_TYPE_DEVICE_DRIVERLIST,     \
+                                                        OsinfoDeviceDriverList))
+#define OSINFO_IS_DEVICE_DRIVERLIST(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+                                                        OSINFO_TYPE_DEVICE_DRIVERLIST))
+#define OSINFO_DEVICE_DRIVERLIST_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), \
+                                                        OSINFO_TYPE_DEVICE_DRIVERLIST, \
+                                                        OsinfoDeviceDriverListClass))
+#define OSINFO_IS_DEVICE_DRIVERLIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+                                                        OSINFO_TYPE_DEVICE_DRIVERLIST))
+#define OSINFO_DEVICE_DRIVERLIST_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+                                                        OSINFO_TYPE_DEVICE_DRIVERLIST, \
+                                                        OsinfoDeviceDriverListClass))
+
+typedef struct _OsinfoDeviceDriverList        OsinfoDeviceDriverList;
+
+typedef struct _OsinfoDeviceDriverListClass   OsinfoDeviceDriverListClass;
+
+typedef struct _OsinfoDeviceDriverListPrivate OsinfoDeviceDriverListPrivate;
+
+/* object */
+struct _OsinfoDeviceDriverList
+{
+    OsinfoList parent_instance;
+
+    /* public */
+
+    /* private */
+    OsinfoDeviceDriverListPrivate *priv;
+};
+
+/* class */
+struct _OsinfoDeviceDriverListClass
+{
+    OsinfoListClass parent_class;
+
+    /* class members */
+};
+
+GType osinfo_device_driverlist_get_type(void);
+
+OsinfoDeviceDriverList *osinfo_device_driverlist_new(void);
+OsinfoDeviceDriverList *osinfo_device_driverlist_new_copy(OsinfoDeviceDriverList *source);
+OsinfoDeviceDriverList *osinfo_device_driverlist_new_filtered(OsinfoDeviceDriverList *source,
+                                                              OsinfoFilter *filter);
+OsinfoDeviceDriverList *osinfo_device_driverlist_new_intersection(OsinfoDeviceDriverList *sourceOne,
+                                                                  OsinfoDeviceDriverList *sourceTwo);
+OsinfoDeviceDriverList *osinfo_device_driverlist_new_union(OsinfoDeviceDriverList *sourceOne,
+                                                           OsinfoDeviceDriverList *sourceTwo);
+
+#endif /* __OSINFO_DEVICE_DRIVERLIST_H__ */
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
-- 
1.8.0.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]