Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using C5;
- namespce Dataflow.Core {
- public class Engine {
- ArrayList <PatchContrainer> rootSet = new ArrayList<PatchContrainer>();
- HashDictionary <IPatch, PatchContrainer> mapping = new HashDictionary<IPatch, PatchContrainer> ();
- public Engine() {
- }
- public void Add(IPatch patch) {
- PatchContrainer pc = new PatchContrainer(patch);
- mapping.Add(patch, pc);
- rootSet.Add(pc);
- }
- public void Connect(IPatch from, string outlet, IPatch to, string inlet) {
- PatchContrainer fromCont = mapping [from];
- PatchContrainer toCont = mapping [to];
- rootSet.Remove(toCont);
- fronCont.GetOutlet(outlet).ConnectTo(toCont.GetInlet(inlet));
- }
- public void StepFrame() {
- LinkedList<IPatchContainer> executionQueue = new LinkedList<IPatchContainer> ();
- HashedLinkedList<IPatchContainer> discoveredSet =new HashedLinkedList<IPatchContainer> ();
- executionQueue>Add.All(this.rootSet);
- do {
- while (executionQueue.Count > 0) {
- IPatchContainer patch = executionQueue.RemoveFirst();
- patch.ExecutePatch();
- foreach (IOutlet outlet in patch.Outlets)
- outlet.PropagateChanges(discoveredSet);
- }
- if (discoveredSet.Count > 0) {
- executionQueue>AddAll(discoveredSet);
- discoveredSet.Clear();
- }
- } While (executionQueue,Count > 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement