[rygel] tracker: Allow triplets to be chainable



commit 6a0b0ebf1dee64f583d4dbef8fafbff4a7f82a4c
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Dec 21 20:09:01 2009 +0200

    tracker: Allow triplets to be chainable
    
    Allow a triplet to have another triplet as it's object.

 .../tracker/rygel-tracker-query-triplet.vala       |   44 +++++++++++++++++---
 1 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-query-triplet.vala b/src/plugins/tracker/rygel-tracker-query-triplet.vala
index 6755100..eef4871 100644
--- a/src/plugins/tracker/rygel-tracker-query-triplet.vala
+++ b/src/plugins/tracker/rygel-tracker-query-triplet.vala
@@ -32,6 +32,8 @@ public class Rygel.TrackerQueryTriplet {
 
     public bool optional;
 
+    public TrackerQueryTriplet next;
+
     public TrackerQueryTriplet (string? subject,
                                 string  predicate,
                                 string  obj,
@@ -42,19 +44,43 @@ public class Rygel.TrackerQueryTriplet {
         this.optional = optional;
     }
 
+    public TrackerQueryTriplet.chain (string?             subject,
+                                      string              predicate,
+                                      TrackerQueryTriplet next,
+                                      bool                optional = true) {
+        this.subject = subject;
+        this.predicate = predicate;
+        this.next = next;
+        this.optional = optional;
+    }
+
     public TrackerQueryTriplet.clone (TrackerQueryTriplet triplet) {
-        this (triplet.subject,
-              triplet.predicate,
-              triplet.obj,
-              triplet.optional);
+        this.subject = triplet.subject;
+        this.predicate = triplet.predicate;
+        this.optional = triplet.optional;
+
+        if (triplet.next != null) {
+            this.next = triplet.next;
+        } else {
+            this.obj = triplet.obj;
+        }
     }
 
     public static bool equal_func (TrackerQueryTriplet a,
                                    TrackerQueryTriplet b) {
+        bool chain_equal;
+
+        if (a.next != null && b.next != null) {
+            chain_equal = equal_func (a.next, b.next);
+        } else {
+            chain_equal = a.next == b.next;
+        }
+
         return a.subject == b.subject &&
                a.obj == b.obj &&
                a.predicate == b.predicate &&
-               a.optional == b.optional;
+               a.optional == b.optional &&
+               chain_equal;
     }
 
     public string to_string () {
@@ -68,7 +94,13 @@ public class Rygel.TrackerQueryTriplet {
             str += " " + subject;
         }
 
-        str += " " + predicate + " " + obj;
+        str += " " + predicate;
+
+        if (this.next != null) {
+            str += " [ " + this.next.to_string () + " ] ";
+        } else {
+            str += " " + this.obj;
+        }
 
         if (this.optional) {
             str += " }";



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