[PATCH v3 09/16] util: Introduce virObjectLoookupHashGet{UUID|Name}

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

 



Add a pair of accessor API's for the object elements which will return
the requested key value from the object to the caller.

It is up to the caller to check the returned key value and error if the
return value is NULL.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/libvirt_private.syms |  2 ++
 src/util/virobject.c     | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/util/virobject.h     |  6 ++++++
 3 files changed, 56 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 655a8f8..28244ab 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2286,6 +2286,8 @@ virObjectListFree;
 virObjectListFreeCount;
 virObjectLock;
 virObjectLockableNew;
+virObjectLookupHashGetName;
+virObjectLookupHashGetUUID;
 virObjectLookupHashNew;
 virObjectLookupKeysGetName;
 virObjectLookupKeysGetUUID;
diff --git a/src/util/virobject.c b/src/util/virobject.c
index 79f1fe9..949a93d 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -514,6 +514,18 @@ virObjectGetLookupKeysObj(void *anyobj)
 }
 
 
+static virObjectLookupHashPtr
+virObjectGetLookupHashObj(void *anyobj)
+{
+    if (virObjectIsClass(anyobj, virObjectLookupHashClass))
+        return anyobj;
+
+    VIR_OBJECT_USAGE_PRINT_WARNING(anyobj, virObjectLookupHashClass);
+
+    return NULL;
+}
+
+
 /**
  * virObjectLock:
  * @anyobj: any instance of virObjectLockablePtr
@@ -740,3 +752,39 @@ virObjectLookupKeysGetName(void *anyobj)
 
     return obj->name;
 }
+
+
+/**
+ * virObjectLookupHashGetUUID
+ * @anyobj: Pointer to a LookupHash object
+ *
+ * Returns: Pointer to the UUID Hash Table or NULL on failure
+ */
+virHashTablePtr
+virObjectLookupHashGetUUID(void *anyobj)
+{
+    virObjectLookupHashPtr obj = virObjectGetLookupHashObj(anyobj);
+
+    if (!obj)
+        return NULL;
+
+    return obj->objsUUID;
+}
+
+
+/**
+ * virObjectLookupHashGetName
+ * @anyobj: Pointer to a LookupHash object
+ *
+ * Returns: Pointer to the Name Hash Table or NULL on failure
+ */
+virHashTablePtr
+virObjectLookupHashGetName(void *anyobj)
+{
+    virObjectLookupHashPtr obj = virObjectGetLookupHashObj(anyobj);
+
+    if (!obj)
+        return NULL;
+
+    return obj->objsName;
+}
diff --git a/src/util/virobject.h b/src/util/virobject.h
index 3c45182..7da680a 100644
--- a/src/util/virobject.h
+++ b/src/util/virobject.h
@@ -179,4 +179,10 @@ virObjectLookupKeysGetUUID(void *anyobj);
 const char *
 virObjectLookupKeysGetName(void *anyobj);
 
+virHashTablePtr
+virObjectLookupHashGetUUID(void *anyobj);
+
+virHashTablePtr
+virObjectLookupHashGetName(void *anyobj);
+
 #endif /* __VIR_OBJECT_H */
-- 
2.9.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux