[virt-tools-list] [PATCH 36/47] Remove osinfo common module

Daniel P. Berrange berrange at redhat.com
Wed Aug 25 19:37:31 UTC 2010


Finally all objects are fully private and the common
code module can be banished.

* osinfo/osinfo_common.c, osinfo/osinfo_common.h: Delete
* osinfo/Makefile.am, osinfo/osinfo.h: Remove osinfo_common.h
* configure.ac: Use osinfo/osinfo_db.c in CONFIG_SRCDIR
* osinfo/osinfo_dataread.c, osinfo/osinfo_db.c,
  osinfo/osinfo_db.h, osinfo/osinfo_device.h,
  osinfo/osinfo_devicelist.h, osinfo/osinfo_entity.c,
  osinfo/osinfo_entity.h, osinfo/osinfo_filter.c,
  osinfo/osinfo_hypervisor.h, osinfo/osinfo_hypervisorlist.h,
  osinfo/osinfo_list.h, osinfo/osinfo_os.c,
  osinfo/osinfo_os.h, osinfo/osinfo_oslist.h: Add the
  main object typedefs, previously in the common module.
  Rename osinfoRelationship to OsinfoOsRelationship.
---
 configure.ac                   |    2 +-
 osinfo/Makefile.am             |    2 --
 osinfo/osinfo.h                |    3 +--
 osinfo/osinfo_common.c         |    2 --
 osinfo/osinfo_common.h         |   34 ----------------------------------
 osinfo/osinfo_dataread.c       |    2 +-
 osinfo/osinfo_db.c             |    4 ++--
 osinfo/osinfo_db.h             |    5 ++---
 osinfo/osinfo_device.h         |    3 +--
 osinfo/osinfo_devicelist.h     |    2 +-
 osinfo/osinfo_entity.c         |    2 +-
 osinfo/osinfo_entity.h         |    4 +++-
 osinfo/osinfo_filter.c         |    6 +++---
 osinfo/osinfo_filter.h         |   11 ++++-------
 osinfo/osinfo_hypervisor.h     |    3 +--
 osinfo/osinfo_hypervisorlist.h |    2 +-
 osinfo/osinfo_list.h           |    2 ++
 osinfo/osinfo_os.c             |    6 +++---
 osinfo/osinfo_os.h             |   14 ++++++++++----
 osinfo/osinfo_oslist.h         |    2 +-
 20 files changed, 38 insertions(+), 73 deletions(-)
 delete mode 100644 osinfo/osinfo_common.c
 delete mode 100644 osinfo/osinfo_common.h

diff --git a/configure.ac b/configure.ac
index 6fa0986..692328c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([1.11.1 foreign color-tests])
 AC_PREREQ([2.61])
-AC_CONFIG_SRCDIR([osinfo/osinfo_common.c])
+AC_CONFIG_SRCDIR([osinfo/osinfo_db.c])
 AC_CONFIG_HEADERS([config.h])
 AC_PROG_LIBTOOL
 AC_PROG_CC
diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index 9a6d79d..5d61779 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -25,8 +25,6 @@ libosinfo_include_HEADERS = 		\
   osinfo_oslist.h
 
 libosinfo_la_SOURCES =		\
-  osinfo_common.h		\
-  osinfo_common.c		\
   osinfo_dataread.c		\
   osinfo_device.c		\
   osinfo_devicelist.c		\
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index dc64722..e652a32 100644
--- a/osinfo/osinfo.h
+++ b/osinfo/osinfo.h
@@ -2,15 +2,14 @@
 #define __OSINFO_H__
 
 #include <glib-object.h>
-#include <osinfo/osinfo_common.h>
 #include <osinfo/osinfo_entity.h>
 #include <osinfo/osinfo_list.h>
 #include <osinfo/osinfo_devicelist.h>
 #include <osinfo/osinfo_oslist.h>
 #include <osinfo/osinfo_hypervisorlist.h>
 #include <osinfo/osinfo_device.h>
-#include <osinfo/osinfo_os.h>
 #include <osinfo/osinfo_hypervisor.h>
+#include <osinfo/osinfo_os.h>
 #include <osinfo/osinfo_filter.h>
 #include <osinfo/osinfo_db.h>
 
diff --git a/osinfo/osinfo_common.c b/osinfo/osinfo_common.c
deleted file mode 100644
index aaec1fd..0000000
--- a/osinfo/osinfo_common.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <osinfo/osinfo.h>
-
diff --git a/osinfo/osinfo_common.h b/osinfo/osinfo_common.h
deleted file mode 100644
index 80ed830..0000000
--- a/osinfo/osinfo_common.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * libosinfo
- *
- * osinfo_objects.h
- * Contains forward declarations of our main object types, and definitions
- * of our internal data structures not exposed in the API as libosinfo objects.
- */
-
-#ifndef __OSINFO_OBJECTS_H__
-#define __OSINFO_OBJECTS_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib-object.h>
-#include <errno.h>
-
-typedef struct _OsinfoEntity     OsinfoEntity;
-typedef struct _OsinfoDb         OsinfoDb;
-typedef struct _OsinfoDevice     OsinfoDevice;
-typedef struct _OsinfoHypervisor OsinfoHypervisor;
-typedef struct _OsinfoOs         OsinfoOs;
-typedef struct _OsinfoFilter     OsinfoFilter;
-typedef struct _OsinfoList       OsinfoList;
-typedef struct _OsinfoDeviceList       OsinfoDeviceList;
-typedef struct _OsinfoHypervisorList       OsinfoHypervisorList;
-typedef struct _OsinfoOsList       OsinfoOsList;
-
-typedef enum OSI_RELATIONSHIP {
-    DERIVES_FROM,
-    UPGRADES,
-    CLONES,
-} osinfoRelationship;
-
-#endif /* __OSINFO_OBJECTS_H__ */
diff --git a/osinfo/osinfo_dataread.c b/osinfo/osinfo_dataread.c
index 8a9e423..a6dbc32 100644
--- a/osinfo/osinfo_dataread.c
+++ b/osinfo/osinfo_dataread.c
@@ -205,7 +205,7 @@ error:
 static int __osinfoProcessOsRelationship(xmlTextReaderPtr reader,
 					 OsinfoDb *db,
                                          OsinfoOs *os,
-                                         osinfoRelationship relationship)
+                                         OsinfoOsRelationship relationship)
 {
     int empty;
     gchar *id;
diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
index eb547dd..4540688 100644
--- a/osinfo/osinfo_db.c
+++ b/osinfo/osinfo_db.c
@@ -281,7 +281,7 @@ GList *osinfo_db_unique_values_for_property_in_dev(OsinfoDb *self, gchar *propNa
 
 struct __osinfoOsCheckRelationshipArgs {
     OsinfoList *list;
-    osinfoRelationship relshp;
+    OsinfoOsRelationship relshp;
 };
 
 
@@ -302,7 +302,7 @@ static gboolean __osinfoAddOsIfRelationship(OsinfoList *list, OsinfoEntity *enti
 }
 
 // Get me all OSes that 'upgrade' another OS (or whatever relationship is specified)
-OsinfoOsList *osinfo_db_unique_values_for_os_relationship(OsinfoDb *self, osinfoRelationship relshp)
+OsinfoOsList *osinfo_db_unique_values_for_os_relationship(OsinfoDb *self, OsinfoOsRelationship relshp)
 {
     g_return_val_if_fail(OSINFO_IS_DB(self), NULL);
 
diff --git a/osinfo/osinfo_db.h b/osinfo/osinfo_db.h
index 28d9265..af77e96 100644
--- a/osinfo/osinfo_db.h
+++ b/osinfo/osinfo_db.h
@@ -18,8 +18,7 @@
 #define OSINFO_IS_DB_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_DB))
 #define OSINFO_DB_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_DB, OsinfoDbClass))
 
-//typedef struct _OsinfoDb        OsinfoDb;
-// (defined in osinfo_objects.h)
+typedef struct _OsinfoDb        OsinfoDb;
 
 typedef struct _OsinfoDbClass   OsinfoDbClass;
 
@@ -82,7 +81,7 @@ GList *osinfo_db_unique_values_for_property_in_hv(OsinfoDb *self, gchar *propNam
 GList *osinfo_db_unique_values_for_property_in_dev(OsinfoDb *self, gchar *propName);
 
 // Get me all OSes that 'upgrade' another OS (or whatever relationship is specified)
-OsinfoOsList *osinfo_db_unique_values_for_os_relationship(OsinfoDb *self, osinfoRelationship relshp);
+OsinfoOsList *osinfo_db_unique_values_for_os_relationship(OsinfoDb *self, OsinfoOsRelationship relshp);
 
 
 #endif /* __OSINFO_DB_H__ */
diff --git a/osinfo/osinfo_device.h b/osinfo/osinfo_device.h
index 555950a..ad88557 100644
--- a/osinfo/osinfo_device.h
+++ b/osinfo/osinfo_device.h
@@ -18,8 +18,7 @@
 #define OSINFO_IS_DEVICE_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_DEVICE))
 #define OSINFO_DEVICE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_DEVICE, OsinfoDeviceClass))
 
-//typedef struct _OsinfoDevice        OsinfoDevice;
-// (defined in osinfo_objects.h)
+typedef struct _OsinfoDevice        OsinfoDevice;
 
 typedef struct _OsinfoDeviceClass   OsinfoDeviceClass;
 
diff --git a/osinfo/osinfo_devicelist.h b/osinfo/osinfo_devicelist.h
index 9245620..e5cb25d 100644
--- a/osinfo/osinfo_devicelist.h
+++ b/osinfo/osinfo_devicelist.h
@@ -17,7 +17,7 @@
 #define OSINFO_IS_DEVICELIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_DEVICELIST))
 #define OSINFO_DEVICELIST_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_DEVICELIST, OsinfoDeviceListClass))
 
-//typedef struct _OsinfoDeviceList        OsinfoDeviceList;
+typedef struct _OsinfoDeviceList        OsinfoDeviceList;
 
 typedef struct _OsinfoDeviceListClass   OsinfoDeviceListClass;
 
diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c
index 15d4ab4..a938bce 100644
--- a/osinfo/osinfo_entity.c
+++ b/osinfo/osinfo_entity.c
@@ -222,7 +222,7 @@ static gboolean osinfo_entity_matcher(OsinfoFilter *self,
 
 
 static gboolean osinfo_entity_relation_matcher(OsinfoFilter *self,
-					       osinfoRelationship relshp,
+					       OsinfoOsRelationship relshp,
 					       GList *relOses,
 					       gpointer data)
 {
diff --git a/osinfo/osinfo_entity.h b/osinfo/osinfo_entity.h
index 188d93d..cf3dc61 100644
--- a/osinfo/osinfo_entity.h
+++ b/osinfo/osinfo_entity.h
@@ -18,7 +18,9 @@
 #define OSINFO_IS_ENTITY_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_ENTITY))
 #define OSINFO_ENTITY_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_ENTITY, OsinfoEntityClass))
 
-//typedef struct _OsinfoEntity        OsinfoEntity;
+typedef struct _OsinfoEntity        OsinfoEntity;
+/* Temp hack */
+typedef struct _OsinfoFilter        OsinfoFilter;
 
 typedef struct _OsinfoEntityClass   OsinfoEntityClass;
 
diff --git a/osinfo/osinfo_filter.c b/osinfo/osinfo_filter.c
index 6a9ac72..b60f5e3 100644
--- a/osinfo/osinfo_filter.c
+++ b/osinfo/osinfo_filter.c
@@ -113,7 +113,7 @@ gint osinfo_filter_add_constraint(OsinfoFilter *self, gchar *propName, gchar *pr
 }
 
 // Only applicable to OSes, ignored by other types of objects
-gint osinfo_filter_add_relation_constraint(OsinfoFilter *self, osinfoRelationship relshp, OsinfoOs *os)
+gint osinfo_filter_add_relation_constraint(OsinfoFilter *self, OsinfoOsRelationship relshp, OsinfoOs *os)
 {
     g_return_val_if_fail(OSINFO_IS_FILTER(self), -1);
     g_return_val_if_fail(OSINFO_IS_OS(os), -1);
@@ -141,7 +141,7 @@ void osinfo_filter_clear_constraint(OsinfoFilter *self, gchar *propName)
     g_hash_table_remove(self->priv->propertyConstraints, propName);
 }
 
-void osinfo_filter_clear_relationship_constraint(OsinfoFilter *self, osinfoRelationship relshp)
+void osinfo_filter_clear_relationship_constraint(OsinfoFilter *self, OsinfoOsRelationship relshp)
 {
     g_hash_table_remove(self->priv->relationshipConstraints, (gpointer) relshp);
 }
@@ -170,7 +170,7 @@ GList *osinfo_filter_get_constraint_values(OsinfoFilter *self, gchar *propName)
 }
 
 // get oses for given relshp
-OsinfoOsList *osinfo_filter_get_relationship_constraint_value(OsinfoFilter *self, osinfoRelationship relshp)
+OsinfoOsList *osinfo_filter_get_relationship_constraint_value(OsinfoFilter *self, OsinfoOsRelationship relshp)
 {
     g_return_val_if_fail(OSINFO_IS_FILTER(self), NULL);
 
diff --git a/osinfo/osinfo_filter.h b/osinfo/osinfo_filter.h
index 6d13392..3f9e497 100644
--- a/osinfo/osinfo_filter.h
+++ b/osinfo/osinfo_filter.h
@@ -19,9 +19,6 @@
 #define OSINFO_FILTER_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_FILTER, OsinfoFilterClass))
 
 //typedef struct _OsinfoFilter        OsinfoFilter;
-// (defined in osinfo_objects.h)
-
-#include "osinfo_oslist.h"
 
 typedef struct _OsinfoFilterClass  OsinfoFilterClass;
 
@@ -51,22 +48,22 @@ GType osinfo_filter_get_type(void);
 gint osinfo_filter_add_constraint(OsinfoFilter *self, gchar *propName, gchar *propVal);
 
 // Only applicable to OSes, ignored by other types of objects
-gint osinfo_filter_add_relation_constraint(OsinfoFilter *self, osinfoRelationship relshp, OsinfoOs *os);
+gint osinfo_filter_add_relation_constraint(OsinfoFilter *self, OsinfoOsRelationship relshp, OsinfoOs *os);
 
 void osinfo_filter_clear_constraint(OsinfoFilter *self, gchar *propName);
-void osinfo_filter_clear_relationship_constraint(OsinfoFilter *self, osinfoRelationship relshp);
+void osinfo_filter_clear_relationship_constraint(OsinfoFilter *self, OsinfoOsRelationship relshp);
 void osinfo_filter_clear_all_constraints(OsinfoFilter *self);
 
 GList *osinfo_filter_get_constraint_keys(OsinfoFilter *self);
 GList *osinfo_filter_get_constraint_values(OsinfoFilter *self, gchar *propName);
-OsinfoOsList *osinfo_filter_get_relationship_constraint_value(OsinfoFilter *self, osinfoRelationship relshp);
+OsinfoOsList *osinfo_filter_get_relationship_constraint_value(OsinfoFilter *self, OsinfoOsRelationship relshp);
 
 typedef gboolean (*osinfo_filter_match_func)(OsinfoFilter *self,
 					     const gchar *propName,
 					     GList *propValues,
 					     gpointer data);
 typedef gboolean (*osinfo_filter_match_relation_func)(OsinfoFilter *self,
-						      osinfoRelationship relshp,
+						      OsinfoOsRelationship relshp,
 						      GList *relOses,
 						      gpointer data);
 
diff --git a/osinfo/osinfo_hypervisor.h b/osinfo/osinfo_hypervisor.h
index 15f45cc..bf2996d 100644
--- a/osinfo/osinfo_hypervisor.h
+++ b/osinfo/osinfo_hypervisor.h
@@ -20,8 +20,7 @@
 #define OSINFO_IS_HYPERVISOR_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_HYPERVISOR))
 #define OSINFO_HYPERVISOR_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_HYPERVISOR, OsinfoHypervisorClass))
 
-//typedef struct _OsinfoHypervisor        OsinfoHypervisor;
-// (defined in osinfo_objects.h)
+typedef struct _OsinfoHypervisor        OsinfoHypervisor;
 
 typedef struct _OsinfoHypervisorClass   OsinfoHypervisorClass;
 
diff --git a/osinfo/osinfo_hypervisorlist.h b/osinfo/osinfo_hypervisorlist.h
index 160a9c9..2487ac2 100644
--- a/osinfo/osinfo_hypervisorlist.h
+++ b/osinfo/osinfo_hypervisorlist.h
@@ -17,7 +17,7 @@
 #define OSINFO_IS_HYPERVISORLIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_HYPERVISORLIST))
 #define OSINFO_HYPERVISORLIST_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_HYPERVISORLIST, OsinfoHypervisorListClass))
 
-//typedef struct _OsinfoHypervisorList        OsinfoHypervisorList;
+typedef struct _OsinfoHypervisorList        OsinfoHypervisorList;
 
 typedef struct _OsinfoHypervisorListClass   OsinfoHypervisorListClass;
 
diff --git a/osinfo/osinfo_list.h b/osinfo/osinfo_list.h
index 3263061..09a2003 100644
--- a/osinfo/osinfo_list.h
+++ b/osinfo/osinfo_list.h
@@ -17,6 +17,8 @@
 #define OSINFO_IS_LIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_LIST))
 #define OSINFO_LIST_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_LIST, OsinfoListClass))
 
+typedef struct _OsinfoList       OsinfoList;
+
 typedef struct _OsinfoListClass   OsinfoListClass;
 
 typedef struct _OsinfoListPrivate OsinfoListPrivate;
diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
index d023888..421655b 100644
--- a/osinfo/osinfo_os.c
+++ b/osinfo/osinfo_os.c
@@ -24,7 +24,7 @@ struct _OsinfoOsOsLink {
      * centos clones rhel
      * scientificlinux derives from rhel
      */
-    osinfoRelationship relshp;
+    OsinfoOsRelationship relshp;
     OsinfoOs *otherOs;
 };
 
@@ -140,7 +140,7 @@ OsinfoDevice *osinfo_os_get_preferred_device(OsinfoOs *self, OsinfoHypervisor *h
     return NULL;
 }
 
-OsinfoOsList *osinfo_os_get_related(OsinfoOs *self, osinfoRelationship relshp)
+OsinfoOsList *osinfo_os_get_related(OsinfoOs *self, OsinfoOsRelationship relshp)
 {
     g_return_val_if_fail(OSINFO_IS_OS(self), NULL);
 
@@ -214,7 +214,7 @@ void osinfo_os_add_device(OsinfoOs *self, OsinfoHypervisor *hv, OsinfoDevice *de
 }
 
 
-void osinfo_os_add_related_os(OsinfoOs *self, osinfoRelationship relshp, OsinfoOs *otheros)
+void osinfo_os_add_related_os(OsinfoOs *self, OsinfoOsRelationship relshp, OsinfoOs *otheros)
 {
     g_return_if_fail(OSINFO_IS_OS(self));
     g_return_if_fail(OSINFO_IS_OS(otheros));
diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h
index 7cc3e6c..8c0a565 100644
--- a/osinfo/osinfo_os.h
+++ b/osinfo/osinfo_os.h
@@ -22,8 +22,7 @@
 #define OSINFO_IS_OS_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_OS))
 #define OSINFO_OS_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_OS, OsinfoOsClass))
 
-//typedef struct _OsinfoOs        OsinfoOs;
-// (defined in osinfo_objects.h)
+typedef struct _OsinfoOs        OsinfoOs;
 
 typedef struct _OsinfoOsClass   OsinfoOsClass;
 
@@ -48,18 +47,25 @@ struct _OsinfoOsClass
     /* class members */
 };
 
+typedef enum {
+    DERIVES_FROM,
+    UPGRADES,
+    CLONES,
+} OsinfoOsRelationship;
+
+
 GType osinfo_os_get_type(void);
 
 OsinfoOs *osinfo_os_new(const gchar *id);
 
 OsinfoDevice *osinfo_os_get_preferred_device(OsinfoOs *self, OsinfoHypervisor *hv, gchar *devType, OsinfoFilter *filter,
 					     const gchar **driver);
-OsinfoOsList *osinfo_os_get_related(OsinfoOs *self, osinfoRelationship relshp);
+OsinfoOsList *osinfo_os_get_related(OsinfoOs *self, OsinfoOsRelationship relshp);
 
 OsinfoDeviceList *osinfo_os_get_devices(OsinfoOs *self, OsinfoHypervisor *hv, OsinfoFilter *filter);
 
 void osinfo_os_add_device(OsinfoOs *self, OsinfoHypervisor *hv, OsinfoDevice *dev, const gchar *driver);
 
-void osinfo_os_add_related_os(OsinfoOs *self, osinfoRelationship relshp, OsinfoOs *otheros);
+void osinfo_os_add_related_os(OsinfoOs *self, OsinfoOsRelationship relshp, OsinfoOs *otheros);
 
 #endif /* __OSINFO_OS_H__ */
diff --git a/osinfo/osinfo_oslist.h b/osinfo/osinfo_oslist.h
index d5d0ef9..7adc69f 100644
--- a/osinfo/osinfo_oslist.h
+++ b/osinfo/osinfo_oslist.h
@@ -18,7 +18,7 @@
 #define OSINFO_IS_OSLIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_OSLIST))
 #define OSINFO_OSLIST_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_OSLIST, OsinfoOsListClass))
 
-//typedef struct _OsinfoOsList        OsinfoOsList;
+typedef struct _OsinfoOsList        OsinfoOsList;
 
 typedef struct _OsinfoOsListClass   OsinfoOsListClass;
 
-- 
1.7.2.1




More information about the virt-tools-list mailing list