[Libosinfo] [libosinfo PATCH 04/31] osinfo: Introduce OsinfoFeatureList

Fabiano Fidêncio fidencio at redhat.com
Fri Nov 23 10:14:53 UTC 2018


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 | 91 +++++++++++++++++++++++++++++++++++++
 osinfo/osinfo_featurelist.h | 78 +++++++++++++++++++++++++++++++
 5 files changed, 175 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 f03e02c..318c61d 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		\
@@ -127,6 +128,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 48dbd44..f49cd93 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -537,6 +537,9 @@ LIBOSINFO_1.3.0 {
 	osinfo_feature_get_type;
 	osinfo_feature_new;
 
+	osinfo_featurelist_get_type;
+	osinfo_featurelist_new;
+
 	osinfo_os_add_maximum_resources;
 	osinfo_os_get_all_device_links;
 	osinfo_os_get_maximum_resources;
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index d4a06a2..d90f72b 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..76c6201
--- /dev/null
+++ b/osinfo/osinfo_featurelist.c
@@ -0,0 +1,91 @@
+/*
+ * 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/>.
+ *
+ * Authors:
+ *   Fabiano Fidêncio <fidencio at redhat.com>
+ */
+
+#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..34384ba
--- /dev/null
+++ b/osinfo/osinfo_featurelist.h
@@ -0,0 +1,78 @@
+/*
+ * 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/>.
+ *
+ * Authors:
+ *   Fabiano Fidêncio <fidencio at redhat.com>
+ */
+
+#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.1




More information about the Libosinfo mailing list