[Libvirt-cim] [PATCH 1 of 3] Enhance handling of association's references

Heidi Eckhart heidieck at linux.vnet.ibm.com
Fri Nov 30 08:27:10 UTC 2007


# HG changeset patch
# User Heidi Eckhart <heidieck at linux.vnet.ibm.com>
# Date 1196333488 -3600
# Node ID 393cc9ffc3e218d537618d314ca4eb6120fc6043
# Parent  12eaba9327d0f5f9c401c990956e5f95b9bb7b1b
Enhance handling of association's references

The source and target classnames of std_assoc are now lists,
containing all supported classnames. This approach frees
the provider from  listing all possible combinations as
instances of std_assoc.

Signed-off-by: Heidi Eckhart <heidieck at linux.vnet.ibm.com>

diff -r 12eaba9327d0 -r 393cc9ffc3e2 std_association.c
--- a/std_association.c	Wed Nov 28 07:29:17 2007 -0800
+++ b/std_association.c	Thu Nov 29 11:51:28 2007 +0100
@@ -61,18 +61,44 @@ static bool match_class(const CMPIBroker
 static bool match_class(const CMPIBroker *broker,
                         const char *ns,
                         const char *test_class,
-                        const char *comp_class)
+                        char **comp_class_list)
 {
         CMPIObjectPath *rop;
+        char *comp_class;
+        int i;
 
         rop = CMNewObjectPath(broker, ns, test_class, NULL);
 
-        if ((test_class == NULL) ||
-            (comp_class == NULL) ||
-            match_op(broker, rop, comp_class))
-                return true;
-        else
-                return false;
+        for (i = 0; comp_class_list[i]; i++) {
+                comp_class = comp_class_list[i];
+
+                if ((test_class == NULL) ||
+                    (comp_class == NULL) ||
+                    match_op(broker, rop, comp_class))
+                        return true;
+        }
+
+        return false;
+}
+
+static bool match_source_class(const CMPIBroker *broker,
+                               const CMPIObjectPath *ref,
+                               struct std_assoc *ptr)
+{
+        char *source_class;
+        int i;
+
+        for (i = 0; ptr->source_class[i]; i++) {
+                source_class = ptr->source_class[i];
+                
+                if (CMClassPathIsA(broker, 
+                                   ref, 
+                                   source_class, 
+                                   NULL))
+                        return true;
+        }
+
+        return false;
 }
 
 static CMPIStatus filter_results(struct inst_list *list,
@@ -113,13 +139,13 @@ std_assoc_get_handler(const struct std_a
 std_assoc_get_handler(const struct std_assoc_ctx *ctx,
                       const CMPIObjectPath *ref)
 {
-        struct std_assoc *ptr;
+        struct std_assoc *ptr = NULL;
         int i;
 
         for (i = 0; ctx->handlers[i]; i++) {
                 ptr = ctx->handlers[i];
 
-                if (CMClassPathIsA(ctx->brkr, ref, ptr->source_class, NULL))
+                if (match_source_class(ctx->brkr, ref, ptr))
                         return ptr;
         }
 
diff -r 12eaba9327d0 -r 393cc9ffc3e2 std_association.h
--- a/std_association.h	Wed Nov 28 07:29:17 2007 -0800
+++ b/std_association.h	Thu Nov 29 11:51:28 2007 +0100
@@ -37,13 +37,13 @@ typedef CMPIInstance *(*make_ref_t)(cons
                                     struct std_assoc *);
 
 struct std_assoc {
-        char *source_class;
+        char **source_class;
         char *source_prop;
 
-        char *target_class;
+        char **target_class;
         char *target_prop;
     
-        char *assoc_class;
+        char **assoc_class;
 
         assoc_handler_t handler;
         make_ref_t make_ref;




More information about the Libvirt-cim mailing list