[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH 33/47] Make entity object fully private



Make the OsinfoEntityPrivate struct fully private to
the OsinfoEntity object.

* osinfo/osinfo_common.h: Remove OsinfoEntityPrivate
* osinfo/osinfo_entity.c: Add OsinfoEntityPrivate
* osinfo/osinfo_list.c: Use API instead of direct
  access to private data of OsinfoEntity objects
---
 osinfo/osinfo_common.h |    8 --------
 osinfo/osinfo_entity.c |    9 +++++++++
 osinfo/osinfo_list.c   |   18 +++++++-----------
 3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/osinfo/osinfo_common.h b/osinfo/osinfo_common.h
index 8726c41..9ea70f7 100644
--- a/osinfo/osinfo_common.h
+++ b/osinfo/osinfo_common.h
@@ -106,14 +106,6 @@ struct _OsinfoOsPrivate
     GList *osLinks;
 };
 
-struct _OsinfoEntityPrivate
-{
-    gchar *id;
-
-    // Key: gchar*
-    // Value: GList of gchar* values
-    GHashTable *params;
-};
 
 
 #endif /* __OSINFO_OBJECTS_H__ */
diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c
index 3625a86..2bec761 100644
--- a/osinfo/osinfo_entity.c
+++ b/osinfo/osinfo_entity.c
@@ -4,6 +4,15 @@ G_DEFINE_ABSTRACT_TYPE (OsinfoEntity, osinfo_entity, G_TYPE_OBJECT);
 
 #define OSINFO_ENTITY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_ENTITY, OsinfoEntityPrivate))
 
+struct _OsinfoEntityPrivate
+{
+    gchar *id;
+
+    // Key: gchar*
+    // Value: GList of gchar* values
+    GHashTable *params;
+};
+
 static void osinfo_entity_finalize (GObject *object);
 
 enum OSI_ENTITY_PROPERTIES {
diff --git a/osinfo/osinfo_list.c b/osinfo/osinfo_list.c
index b5eed93..e21eebb 100644
--- a/osinfo/osinfo_list.c
+++ b/osinfo/osinfo_list.c
@@ -95,19 +95,17 @@ void osinfo_list_add_intersection(OsinfoList *self, OsinfoList *sourceOne, Osinf
     len = osinfo_list_get_length(sourceTwo);
     for (i = 0; i < len; i++) {
         OsinfoEntity *entity = osinfo_list_get_nth(sourceTwo, i);
-        gchar *id = entity->priv->id;
-        g_hash_table_insert(otherSet, id, entity);
+        g_hash_table_insert(otherSet, osinfo_entity_get_id(entity), entity);
     }
 
     // If other contains entity, and new list does not, add to new list
     len = osinfo_list_get_length(sourceOne);
     for (i = 0; i < len; i++) {
         OsinfoEntity *entity = osinfo_list_get_nth(sourceOne, i);
-        gchar *id = entity->priv->id;
 
-        if (g_hash_table_lookup(otherSet, entity->priv->id) &&
-            !g_hash_table_lookup(newSet, entity->priv->id)) {
-            g_hash_table_insert(newSet, id, entity);
+        if (g_hash_table_lookup(otherSet, osinfo_entity_get_id(entity)) &&
+            !g_hash_table_lookup(newSet, osinfo_entity_get_id(entity))) {
+	    g_hash_table_insert(newSet, osinfo_entity_get_id(entity), entity);
             osinfo_list_add(self, entity);
         }
     }
@@ -127,20 +125,18 @@ void osinfo_list_add_union(OsinfoList *self, OsinfoList *sourceOne, OsinfoList *
     len = osinfo_list_get_length(sourceTwo);
     for (i = 0; i < len; i++) {
         OsinfoEntity *entity = osinfo_list_get_nth(sourceTwo, i);
-        gchar *id = entity->priv->id;
         osinfo_list_add(self, entity);
-        g_hash_table_insert(newSet, id, entity);
+        g_hash_table_insert(newSet, osinfo_entity_get_id(entity), entity);
     }
 
     // Add remaining elements from this list to new list
     len = osinfo_list_get_length(sourceOne);
     for (i = 0; i < len; i++) {
         OsinfoEntity *entity = osinfo_list_get_nth(sourceOne, i);
-        gchar *id = entity->priv->id;
         // If new list does not contain element, add to new list
-        if (!g_hash_table_lookup(newSet, id)) {
+        if (!g_hash_table_lookup(newSet, osinfo_entity_get_id(entity))) {
 	    osinfo_list_add(self, entity);
-            g_hash_table_insert(newSet, id, entity);
+            g_hash_table_insert(newSet, osinfo_entity_get_id(entity), entity);
         }
     }
 
-- 
1.7.2.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]