[Libosinfo] [libosinfo PATCH 3/6] Introduce OsinfoImageList object
Fabiano Fidêncio
fidencio at redhat.com
Wed Oct 31 21:45:35 UTC 2018
OsinfoImageList object represents has been created to easily deal with
OsinfoImage objects.
https://gitlab.com/libosinfo/osinfo-db/issues/10
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
osinfo/Makefile.am | 2 +
osinfo/libosinfo.syms | 3 ++
osinfo/osinfo.h | 1 +
osinfo/osinfo_imagelist.c | 90 +++++++++++++++++++++++++++++++++++++++
osinfo/osinfo_imagelist.h | 77 +++++++++++++++++++++++++++++++++
5 files changed, 173 insertions(+)
create mode 100644 osinfo/osinfo_imagelist.c
create mode 100644 osinfo/osinfo_imagelist.h
diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index b53acd1..f0ba7a7 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -101,6 +101,7 @@ libosinfo_1_0_include_HEADERS = \
osinfo_tree.h \
osinfo_treelist.h \
osinfo_image.h \
+ osinfo_imagelist.h \
$(NULL)
nodist_libosinfo_1_0_include_HEADERS = \
@@ -145,6 +146,7 @@ libosinfo_c_files = \
osinfo_tree.c \
osinfo_treelist.c \
osinfo_image.c \
+ osinfo_imagelist.c \
osinfo_db.c \
osinfo_loader.c \
$(NULL)
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index fdbaaf3..9f37411 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -540,6 +540,9 @@ LIBOSINFO_1.3.0 {
osinfo_image_get_type;
osinfo_image_get_url;
osinfo_image_new;
+
+ osinfo_imagelist_get_type;
+ osinfo_imagelist_new;
} LIBOSINFO_0.2.13;
/* Symbols in next release...
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index 9e8e604..81c0daf 100644
--- a/osinfo/osinfo.h
+++ b/osinfo/osinfo.h
@@ -66,6 +66,7 @@
#include <osinfo/osinfo_os_variant.h>
#include <osinfo/osinfo_os_variantlist.h>
#include <osinfo/osinfo_image.h>
+#include <osinfo/osinfo_imagelist.h>
#include <osinfo/osinfo_version.h>
#endif
diff --git a/osinfo/osinfo_imagelist.c b/osinfo/osinfo_imagelist.c
new file mode 100644
index 0000000..9e91546
--- /dev/null
+++ b/osinfo/osinfo_imagelist.c
@@ -0,0 +1,90 @@
+/*
+ * libosinfo: a list of installed images
+ *
+ * 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/>.
+ *
+ * Authors:
+ * Fabiano Fidêncio <fidencio at redhat.com>
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+#include <glib/gi18n-lib.h>
+
+G_DEFINE_TYPE(OsinfoImageList, osinfo_imagelist, OSINFO_TYPE_LIST);
+
+#define OSINFO_IMAGELIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_IMAGELIST, OsinfoImageListPrivate))
+
+/**
+ * SECTION:osinfo_imagelist
+ * @short_description: A list of installation image
+ * @see_also: #OsinfoList, #OsinfoImage
+ *
+ * #OsinfoImageList is a list specialization that stores
+ * only #OsinfoImage objects.
+ */
+
+struct _OsinfoImageListPrivate
+{
+ gboolean unused;
+};
+
+static void
+osinfo_imagelist_finalize(GObject *object)
+{
+ /* Chain up to the parent class */
+ G_OBJECT_CLASS(osinfo_imagelist_parent_class)->finalize(object);
+}
+
+/* Init functions */
+static void
+osinfo_imagelist_class_init(OsinfoImageListClass *klass)
+{
+ GObjectClass *g_klass = G_OBJECT_CLASS(klass);
+
+ g_klass->finalize = osinfo_imagelist_finalize;
+ g_type_class_add_private(klass, sizeof(OsinfoImageListPrivate));
+}
+
+static void
+osinfo_imagelist_init(OsinfoImageList *list)
+{
+ list->priv = OSINFO_IMAGELIST_GET_PRIVATE(list);
+}
+
+/**
+ * osinfo_imagelist_new:
+ *
+ * Construct a new image list that is initially empty.
+ *
+ * Returns: (transfer full): an empty image list
+ */
+OsinfoImageList *osinfo_imagelist_new(void)
+{
+ return g_object_new(OSINFO_TYPE_IMAGELIST,
+ "element-type", OSINFO_TYPE_IMAGE,
+ NULL);
+}
+
+/*
+ * Local variables:
+ * indent-tabs-mode: nil
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_imagelist.h b/osinfo/osinfo_imagelist.h
new file mode 100644
index 0000000..2a7a386
--- /dev/null
+++ b/osinfo/osinfo_imagelist.h
@@ -0,0 +1,77 @@
+/*
+ * libosinfo: a list of installed images
+ *
+ * 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/>.
+ *
+ * Authors:
+ * Fabiano Fidêncio <fidencio at redhat.com>
+ */
+
+#include <glib-object.h>
+#include <osinfo/osinfo_list.h>
+
+#ifndef __OSINFO_IMAGELIST_H__
+#define __OSINFO_IMAGELIST_H__
+
+/*
+ * Type macros.
+ */
+#define OSINFO_TYPE_IMAGELIST (osinfo_imagelist_get_type ())
+#define OSINFO_IMAGELIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_IMAGELIST, OsinfoImageList))
+#define OSINFO_IS_IMAGELIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_IMAGELIST))
+#define OSINFO_IMAGELIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_IMAGELIST, OsinfoImageListClass))
+#define OSINFO_IS_IMAGELIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_IMAGELIST))
+#define OSINFO_IMAGELIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_IMAGELIST, OsinfoImageListClass))
+
+typedef struct _OsinfoImageList OsinfoImageList;
+
+typedef struct _OsinfoImageListClass OsinfoImageListClass;
+
+typedef struct _OsinfoImageListPrivate OsinfoImageListPrivate;
+
+/* object */
+struct _OsinfoImageList
+{
+ OsinfoList parent_instance;
+
+ /* public */
+
+ /* private */
+ OsinfoImageListPrivate *priv;
+};
+
+/* class */
+struct _OsinfoImageListClass
+{
+ /*< private >*/
+ OsinfoListClass parent_class;
+
+ /* class members */
+};
+
+GType osinfo_imagelist_get_type(void);
+
+OsinfoImageList *osinfo_imagelist_new(void);
+
+#endif /* __OSINFO_IMAGELIST_H__ */
+/*
+ * Local variables:
+ * indent-tabs-mode: nil
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ */
--
2.19.1
More information about the Libosinfo
mailing list