[Libosinfo] [libosinfo PATCH 3/7] firmwarelist: Add OsinfoFirmwareList

Fabiano Fidêncio fidencio at redhat.com
Tue May 7 13:16:49 UTC 2019


OsinfoFirmwareList has been created in order to represent a list of
firmwares supported by an OS, as an OS may support various firmwares
without any issue.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 docs/reference/Libosinfo-docs.xml |  1 +
 osinfo/Makefile.am                |  2 +
 osinfo/libosinfo.syms             |  3 ++
 osinfo/osinfo.h                   |  1 +
 osinfo/osinfo_firmwarelist.c      | 79 +++++++++++++++++++++++++++++++
 osinfo/osinfo_firmwarelist.h      | 67 ++++++++++++++++++++++++++
 6 files changed, 153 insertions(+)
 create mode 100644 osinfo/osinfo_firmwarelist.c
 create mode 100644 osinfo/osinfo_firmwarelist.h

diff --git a/docs/reference/Libosinfo-docs.xml b/docs/reference/Libosinfo-docs.xml
index df8dd36..8e503e1 100644
--- a/docs/reference/Libosinfo-docs.xml
+++ b/docs/reference/Libosinfo-docs.xml
@@ -32,6 +32,7 @@
     <xi:include href="xml/osinfo_enum_types.xml"/>
     <xi:include href="xml/osinfo_filter.xml"/>
     <xi:include href="xml/osinfo_firmware.xml"/>
+    <xi:include href="xml/osinfo_firmwarelist.xml"/>
     <xi:include href="xml/osinfo_image.xml"/>
     <xi:include href="xml/osinfo_imagelist.xml"/>
     <xi:include href="xml/osinfo_install_config.xml"/>
diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index c722757..67a972e 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -82,6 +82,7 @@ libosinfo_impl_include_HEADERS =		\
   osinfo_entity.h			\
   osinfo_filter.h			\
   osinfo_firmware.h			\
+  osinfo_firmwarelist.h			\
   osinfo_install_config.h		\
   osinfo_install_config_param.h		\
   osinfo_install_config_paramlist.h	\
@@ -121,6 +122,7 @@ libosinfo_c_files =		\
   osinfo_entity.c			\
   osinfo_filter.c			\
   osinfo_firmware.c			\
+  osinfo_firmwarelist.c			\
   osinfo_list.c				\
   osinfo_device.c			\
   osinfo_devicelink.c			\
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index cacaf71..7f6dd65 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -574,6 +574,9 @@ LIBOSINFO_1.5.0 {
 	osinfo_firmware_get_firmware_type;
 	osinfo_firmware_get_type;
 
+	osinfo_firmwarelist_get_type;
+	osinfo_firmwarelist_new;
+
 	osinfo_image_get_os;
 	osinfo_image_get_os_variants;
 	osinfo_image_set_os;
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index 2063c73..36c4986 100644
--- a/osinfo/osinfo.h
+++ b/osinfo/osinfo.h
@@ -41,6 +41,7 @@
 #include <osinfo/osinfo_devicelinklist.h>
 #include <osinfo/osinfo_devicelinkfilter.h>
 #include <osinfo/osinfo_firmware.h>
+#include <osinfo/osinfo_firmwarelist.h>
 #include <osinfo/osinfo_install_config.h>
 #include <osinfo/osinfo_install_config_param.h>
 #include <osinfo/osinfo_install_config_paramlist.h>
diff --git a/osinfo/osinfo_firmwarelist.c b/osinfo/osinfo_firmwarelist.c
new file mode 100644
index 0000000..e29222a
--- /dev/null
+++ b/osinfo/osinfo_firmwarelist.c
@@ -0,0 +1,79 @@
+/*
+ * libosinfo: a list of firmwares
+ *
+ * Copyright (C) 2018 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, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+#include <glib/gi18n-lib.h>
+
+G_DEFINE_TYPE(OsinfoFirmwareList, osinfo_firmwarelist, OSINFO_TYPE_LIST);
+
+#define OSINFO_FIRMWARELIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_FIRMWARELIST, OsinfoFirmwareListPrivate))
+
+/**
+ * SECTION:osinfo_firmwarelist
+ * @short_description: A list of firmwares
+ * @see_also: #OsinfoList, #OsinfoFirmware
+ *
+ * #OsinfoFirmwareList is a list specialization that stores
+ * only #OsinfoFirmware objects.
+ */
+
+struct _OsinfoFirmwareListPrivate
+{
+    gboolean unused;
+};
+
+static void
+osinfo_firmwarelist_finalize(GObject *object)
+{
+    /* Chain up to the parent class */
+    G_OBJECT_CLASS(osinfo_firmwarelist_parent_class)->finalize(object);
+}
+
+/* Init functions */
+static void
+osinfo_firmwarelist_class_init(OsinfoFirmwareListClass *klass)
+{
+    GObjectClass *g_klass = G_OBJECT_CLASS(klass);
+
+    g_klass->finalize = osinfo_firmwarelist_finalize;
+    g_type_class_add_private(klass, sizeof(OsinfoFirmwareListPrivate));
+}
+
+static void
+osinfo_firmwarelist_init(OsinfoFirmwareList *list)
+{
+    list->priv = OSINFO_FIRMWARELIST_GET_PRIVATE(list);
+}
+
+/**
+ * osinfo_firmwarelist_new:
+ *
+ * Construct a new firmware list that is initially empty.
+ *
+ * Returns: (transfer full): an empty firmware list
+ */
+OsinfoFirmwareList *osinfo_firmwarelist_new(void)
+{
+    return g_object_new(OSINFO_TYPE_FIRMWARELIST,
+                        "element-type", OSINFO_TYPE_FIRMWARE,
+                        NULL);
+}
diff --git a/osinfo/osinfo_firmwarelist.h b/osinfo/osinfo_firmwarelist.h
new file mode 100644
index 0000000..6355398
--- /dev/null
+++ b/osinfo/osinfo_firmwarelist.h
@@ -0,0 +1,67 @@
+/*
+ * libosinfo: a list of firmwares
+ *
+ * Copyright (C) 2019 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, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib-object.h>
+#include <osinfo/osinfo_list.h>
+
+#ifndef __OSINFO_FIRMWARELIST_H__
+#define __OSINFO_FIRMWARELIST_H__
+
+/*
+ * Type macros.
+ */
+#define OSINFO_TYPE_FIRMWARELIST                  (osinfo_firmwarelist_get_type ())
+#define OSINFO_FIRMWARELIST(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_FIRMWARELIST, OsinfoFirmwareList))
+#define OSINFO_IS_FIRMWARELIST(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_FIRMWARELIST))
+#define OSINFO_FIRMWARELIST_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_FIRMWARELIST, OsinfoFirmwareListClass))
+#define OSINFO_IS_FIRMWARELIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_FIRMWARELIST))
+#define OSINFO_FIRMWARELIST_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_FIRMWARELIST, OsinfoFirmwareListClass))
+
+typedef struct _OsinfoFirmwareList        OsinfoFirmwareList;
+
+typedef struct _OsinfoFirmwareListClass   OsinfoFirmwareListClass;
+
+typedef struct _OsinfoFirmwareListPrivate OsinfoFirmwareListPrivate;
+
+/* object */
+struct _OsinfoFirmwareList
+{
+    OsinfoList parent_instance;
+
+    /* public */
+
+    /* private */
+    OsinfoFirmwareListPrivate *priv;
+};
+
+/* class */
+struct _OsinfoFirmwareListClass
+{
+    /*< private >*/
+    OsinfoListClass parent_class;
+
+    /* class members */
+};
+
+GType osinfo_firmwarelist_get_type(void);
+
+OsinfoFirmwareList *osinfo_firmwarelist_new(void);
+
+#endif /* __OSINFO_FIRMWARELIST_H__ */
-- 
2.21.0




More information about the Libosinfo mailing list