Re: Roadmap for the future.



On Thu, 2004-02-19 at 15:37, Joe Shaw wrote:
> One way to consider doing it is in the engine so that the backends don't
> need to know about the special "wildcard" match type.
> 
> Backends already subscribe to certain match types, so you could
> synthesize new clues based on the union of all the supported match types
> and blast those out.
> 
> I haven't looked at it myself, but it feels conceptually cleaner to me.

That's probably true. The only problem is where a cluepacket contains
multiple wildcard clues - this leads to combinatorial explosion of the
number of cluepackets we need to generate. OTH this shouldn't happen
(should it?).

Attached is a patch which does it by generating appropriate new
cluepackets. It only allows for at most one wildcarded clue per packet.
I can fix this if you think this is a problem.

dave


diff -Naur --exclude-from=exclude dashboard/engine/CluePacketManager.cs dashboard-wildcard/engine/CluePacketManager.cs
--- dashboard/engine/CluePacketManager.cs	2004-02-19 04:30:23.000000000 +0000
+++ dashboard-wildcard/engine/CluePacketManager.cs	2004-02-19 17:26:57.141055292 +0000
@@ -147,6 +147,15 @@
 			if (cp == null)
 				return;
 
+			/* check for wildcard clues */
+			int wildcard = 0;
+			foreach (Clue clue in cp.Clues)
+				if (clue.Type == "*")
+					wildcard++;
+
+			if (wildcard > 1)
+				Console.WriteLine("Too many wildcards. Arg.");
+			
 			lock (dashboard.backends) {
 				foreach (Backend backend in dashboard.backends) {
 					if (! backend.Initialized)
@@ -160,15 +169,37 @@
 					if (! backend.AcceptCluePacket (cp))
 						continue;
 
-					Console.WriteLine ("--sending--> " + backend.Name);
+					ArrayList packets = new ArrayList ();
+					if (wildcard == 0)
+						packets.Add (cp);
+					if (wildcard == 1) {
+						Clue wildClue;
+						int i = 0;
+						foreach (Clue c in cp.Clues)
+							if (c.Type == "*") { wildClue = c; break; } else i++;
+
+						if (backend.SubscribedClues != null)
+							foreach (String type in backend.SubscribedClues) {
+								CluePacket cp2 = (CluePacket) cp.Clone ();
+								if (wildClue.TriggeringMatch == null)
+									cp2.Clues[i] = new Clue (type, wildClue.Text, wildClue.Relevance, null);
+								else
+									cp2.Clues[i] = new Clue (type, wildClue.Text, wildClue.Relevance, (Match) wildClue.TriggeringMatch.Clone());
+								packets.Add (cp2);
+							}
+					}
+
+					foreach (CluePacket p in packets) {
+						Console.WriteLine ("--sending--> " + backend.Name);
 
-					// Process each of the backends in a new thread
-					BackendWorker worker = new BackendWorker (backend, cp, parent, new BackendWorkerCallback (BackendWorkerDone));
-					Thread worker_thread = new Thread (new ThreadStart (worker.QueryBackend));
-					lock (this.backend_workers) {
-						backend_workers.Add (new ActiveBackendWorker (worker_thread, backend));
+						// Process each of the backends in a new thread
+						BackendWorker worker = new BackendWorker (backend, p, parent, new BackendWorkerCallback (BackendWorkerDone));
+						Thread worker_thread = new Thread (new ThreadStart (worker.QueryBackend));
+						lock (this.backend_workers) {
+							backend_workers.Add (new ActiveBackendWorker (worker_thread, backend));
+						}
+						worker_thread.Start ();
 					}
-					worker_thread.Start ();
 				}
 			}
 		}
diff -Naur --exclude-from=exclude dashboard/engine/dashboard.cs dashboard-wildcard/engine/dashboard.cs
--- dashboard/engine/dashboard.cs	2004-02-19 04:30:23.000000000 +0000
+++ dashboard-wildcard/engine/dashboard.cs	2004-02-19 15:54:25.968167962 +0000
@@ -292,7 +292,7 @@
 
 		private void SendQuery (object o, EventArgs e) {
 			CluePacket cp = new CluePacket ("Dashboard", "Default", true);
-			cp.Clues.Add (new Clue ("email", this.window.QueryEntry.Text, 10));
+			cp.Clues.Add (new Clue ("*", this.window.QueryEntry.Text, 10));
 			CluePacketNotifyCallback(cp);
 		}
 


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