[Libosinfo] [libosinfo PATCH v3 04/12] osinfo: Introduce OsinfoFeatureList

Fabiano Fidêncio fidencio at redhat.com
Fri Jan 18 12:30:39 UTC 2019


OsinfoFeatureList is a list of guest OS features.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 osinfo/Makefile.am          |  2 +
 osinfo/libosinfo.syms       |  3 ++
 osinfo/osinfo.h             |  1 +
 osinfo/osinfo_featurelist.c | 88 +++++++++++++++++++++++++++++++++++++
 osinfo/osinfo_featurelist.h | 75 +++++++++++++++++++++++++++++++
 5 files changed, 169 insertions(+)
 create mode 100644 osinfo/osinfo_featurelist.c
 create mode 100644 osinfo/osinfo_featurelist.h

diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index d553ecc..07ea5de 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -81,6 +81,7 @@ libosinfo_impl_include_HEADERS =		\
   osinfo_device_driverlist.h		\
   osinfo_entity.h			\
   osinfo_feature.h			\
+  osinfo_featurelist.h			\
   osinfo_filter.h			\
   osinfo_install_config.h		\
   osinfo_install_config_param.h		\
@@ -129,6 +130,7 @@ libosinfo_c_files =		\
   osinfo_device_driver.c		\
   osinfo_device_driverlist.c		\
   osinfo_feature.c			\
+  osinfo_featurelist.c			\
   osinfo_install_config.c		\
   osinfo_install_config_param.c		\
   osinfo_install_config_paramlist.c	\
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 0162081..30bab43 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -541,6 +541,9 @@ LIBOSINFO_1.3.0 {
 	osinfo_feature_set_state;
 	osinfo_feature_state_get_type;
 
+	osinfo_featurelist_get_type;
+	osinfo_featurelist_new;
+
 	osinfo_image_get_architecture;
 	osinfo_image_get_cloud_init;
 	osinfo_image_get_format;
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index ff7f2e5..00cfed5 100644
--- a/osinfo/osinfo.h
+++ b/osinfo/osinfo.h
@@ -32,6 +32,7 @@
 #include <osinfo/osinfo_enum_types.h>
 #include <osinfo/osinfo_entity.h>
 #include <osinfo/osinfo_feature.h>
+#include <osinfo/osinfo_featurelist.h>
 #include <osinfo/osinfo_filter.h>
 #include <osinfo/osinfo_list.h>
 #include <osinfo/osinfo_device.h>
diff --git a/osinfo/osinfo_featurelist.c b/osinfo/osinfo_featurelist.c
new file mode 100644
index 0000000..080ee80
--- /dev/null
+++ b/osinfo/osinfo_featurelist.c
@@ -0,0 +1,88 @@
+/*
+ * libosinfo:
+ *
+ * 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(OsinfoFeatureList, osinfo_featurelist, OSINFO_TYPE_LIST);
+
+#define OSINFO_FEATURELIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_FEATURELIST, OsinfoFeatureListPrivate))
+
+/**
+ * SECTION:osinfo_featurelist
+ * @short_description: A list of guest features
+ * @see_also: #OsinfoList, #OsinfoFeature
+ *
+ * #OsinfoFeatureList is a list specialization that stores
+ * only #OsinfoFeature objects.
+ */
+
+struct _OsinfoFeatureListPrivate
+{
+    gboolean unused;
+};
+
+static void
+osinfo_featurelist_finalize(GObject *object)
+{
+    /* Chain up to the parent class */
+    G_OBJECT_CLASS(osinfo_featurelist_parent_class)->finalize(object);
+}
+
+/* Init functions */
+static void
+osinfo_featurelist_class_init(OsinfoFeatureListClass *klass)
+{
+    GObjectClass *g_klass = G_OBJECT_CLASS(klass);
+
+    g_klass->finalize = osinfo_featurelist_finalize;
+    g_type_class_add_private(klass, sizeof(OsinfoFeatureListPrivate));
+}
+
+static void
+osinfo_featurelist_init(OsinfoFeatureList *list)
+{
+    list->priv = OSINFO_FEATURELIST_GET_PRIVATE(list);
+}
+
+
+/**
+ * osinfo_featurelist_new:
+ *
+ * Construct a new feature list that is initially empty.
+ *
+ * Returns: (transfer full): an empty feature list
+ */
+OsinfoFeatureList *osinfo_featurelist_new(void)
+{
+    return g_object_new(OSINFO_TYPE_FEATURELIST,
+                        "element-type", OSINFO_TYPE_FEATURE,
+                        NULL);
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_featurelist.h b/osinfo/osinfo_featurelist.h
new file mode 100644
index 0000000..7902ca5
--- /dev/null
+++ b/osinfo/osinfo_featurelist.h
@@ -0,0 +1,75 @@
+/*
+ * libosinfo: a list of features
+ *
+ * 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 <glib-object.h>
+#include <osinfo/osinfo_filter.h>
+#include <osinfo/osinfo_list.h>
+
+#ifndef __OSINFO_FEATURELIST_H__
+#define __OSINFO_FEATURELIST_H__
+
+/*
+ * Type macros.
+ */
+#define OSINFO_TYPE_FEATURELIST                  (osinfo_featurelist_get_type ())
+#define OSINFO_FEATURELIST(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_FEATURELIST, OsinfoFeatureList))
+#define OSINFO_IS_FEATURELIST(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_FEATURELIST))
+#define OSINFO_FEATURELIST_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_FEATURELIST, OsinfoFeatureListClass))
+#define OSINFO_IS_FEATURELIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_FEATURELIST))
+#define OSINFO_FEATURELIST_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_FEATURELIST, OsinfoFeatureListClass))
+
+typedef struct _OsinfoFeatureList        OsinfoFeatureList;
+
+typedef struct _OsinfoFeatureListClass   OsinfoFeatureListClass;
+
+typedef struct _OsinfoFeatureListPrivate OsinfoFeatureListPrivate;
+
+/* object */
+struct _OsinfoFeatureList
+{
+    OsinfoList parent_instance;
+
+    /* public */
+
+    /* private */
+    OsinfoFeatureListPrivate *priv;
+};
+
+/* class */
+struct _OsinfoFeatureListClass
+{
+    /*< private >*/
+    OsinfoListClass parent_class;
+
+    /* class members */
+};
+
+GType osinfo_featurelist_get_type(void);
+
+OsinfoFeatureList *osinfo_featurelist_new(void);
+
+#endif /* __OSINFO_FEATURELIST_H__ */
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
-- 
2.19.2




More information about the Libosinfo mailing list