[Libosinfo] [libosinfo PATCH 13/31] osinfo: Introduce FeatureLink

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


FeatureLink will be used in exactly the same way DeviceLink is, being a
"container" for a Feature where we can store more specialized
information (like, whether the feature is supported or not for a
specific OS) than we could store in the Feature itself.

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

diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index 000ca90..8781244 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_featurelink.h			\
   osinfo_featurelist.h			\
   osinfo_filter.h			\
   osinfo_install_config.h		\
@@ -130,6 +131,7 @@ libosinfo_c_files =		\
   osinfo_device_driver.c		\
   osinfo_device_driverlist.c		\
   osinfo_feature.c			\
+  osinfo_featurelink.c			\
   osinfo_featurelist.c			\
   osinfo_install_config.c		\
   osinfo_install_config_param.c		\
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index cb1079b..0c51768 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_featurelink_get_type;
+	osinfo_featurelink_new;
+
 	osinfo_featurelist_get_type;
 	osinfo_featurelist_new;
 
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index 9840d73..da4a9b5 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_featurelink.h>
 #include <osinfo/osinfo_featurelist.h>
 #include <osinfo/osinfo_filter.h>
 #include <osinfo/osinfo_link.h>
diff --git a/osinfo/osinfo_featurelink.c b/osinfo/osinfo_featurelink.c
new file mode 100644
index 0000000..903344a
--- /dev/null
+++ b/osinfo/osinfo_featurelink.c
@@ -0,0 +1,95 @@
+/*
+ * libosinfo: A reference to a guest feature
+ *
+ * Copyright (C) 2009-2012, 2014 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(OsinfoFeatureLink, osinfo_featurelink, OSINFO_TYPE_LINK);
+
+#define OSINFO_FEATURELINK_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_FEATURELINK, OsinfoFeatureLinkPrivate))
+
+/**
+ * SECTION:osinfo_featurelink
+ * @short_description: A hardware featurelink
+ * @see_also: #OsinfoOs, #OsinfoPlatform
+ *
+ * #OsinfoFeatureLink is an entity representing some kind of hardware
+ * featurelink. FeatureLinks can be associated with operating systems
+ * and platforms.
+ */
+
+struct _OsinfoFeatureLinkPrivate
+{
+    OsinfoFeature *target;
+};
+
+static void
+osinfo_featurelink_finalize(GObject *object)
+{
+    /* Chain up to the parent class */
+    G_OBJECT_CLASS(osinfo_featurelink_parent_class)->finalize(object);
+}
+
+/* Init functions */
+static void
+osinfo_featurelink_class_init(OsinfoFeatureLinkClass *klass)
+{
+    GObjectClass *g_klass = G_OBJECT_CLASS(klass);
+
+    g_klass->finalize = osinfo_featurelink_finalize;
+    g_type_class_add_private(klass, sizeof(OsinfoFeatureLinkPrivate));
+}
+
+static void
+osinfo_featurelink_init(OsinfoFeatureLink *featurelink)
+{
+    featurelink->priv = OSINFO_FEATURELINK_GET_PRIVATE(featurelink);
+}
+
+
+/**
+ * osinfo_featurelink_new:
+ * @target: the target feature
+ *
+ * Construct a new link for an #OsinfoFeature. The unique ID
+ * of the link is set to match the ID of the target feature.
+ *
+ * Returns: (transfer full): the new feature link
+ */
+OsinfoFeatureLink *osinfo_featurelink_new(OsinfoFeature *target)
+{
+    return g_object_new(OSINFO_TYPE_FEATURELINK,
+                        "id", osinfo_entity_get_id(OSINFO_ENTITY(target)),
+                        "target", target,
+                        NULL);
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_featurelink.h b/osinfo/osinfo_featurelink.h
new file mode 100644
index 0000000..5e7896c
--- /dev/null
+++ b/osinfo/osinfo_featurelink.h
@@ -0,0 +1,77 @@
+/*
+ * libosinfo: A reference to a guest feature
+ *
+ * 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_link.h>
+
+#ifndef __OSINFO_FEATURELINK_H__
+#define __OSINFO_FEATURELINK_H__
+
+/*
+ * Type macros.
+ */
+#define OSINFO_TYPE_FEATURELINK                  (osinfo_featurelink_get_type ())
+#define OSINFO_FEATURELINK(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_FEATURELINK, OsinfoFeatureLink))
+#define OSINFO_IS_FEATURELINK(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_FEATURELINK))
+#define OSINFO_FEATURELINK_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_FEATURELINK, OsinfoFeatureLinkClass))
+#define OSINFO_IS_FEATURELINK_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_FEATURELINK))
+#define OSINFO_FEATURELINK_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_FEATURELINK, OsinfoFeatureLinkClass))
+
+typedef struct _OsinfoFeatureLink        OsinfoFeatureLink;
+
+typedef struct _OsinfoFeatureLinkClass   OsinfoFeatureLinkClass;
+
+typedef struct _OsinfoFeatureLinkPrivate OsinfoFeatureLinkPrivate;
+
+/* object */
+struct _OsinfoFeatureLink
+{
+    OsinfoLink parent_instance;
+
+    /* public */
+
+    /* private */
+    OsinfoFeatureLinkPrivate *priv;
+};
+
+/* class */
+struct _OsinfoFeatureLinkClass
+{
+    /*< private >*/
+    OsinfoLinkClass parent_class;
+
+    /* class members */
+};
+
+GType osinfo_featurelink_get_type(void);
+
+OsinfoFeatureLink *osinfo_featurelink_new(OsinfoFeature *target);
+
+#endif /* __OSINFO_FEATURELINK_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