Changeset 512
- Timestamp:
- 08/13/08 16:33:03 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.CEDMA.Core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Core/Agent.cs
r503 r512 88 88 return results; 89 89 } 90 } 90 } 91 91 92 92 public IView CreateView() { … … 94 94 byte[] rawData = Database.GetAgentRawData(Id); 95 95 IOperatorGraph opGraph = (IOperatorGraph)PersistenceManager.RestoreFromGZip(rawData); 96 DownloadOperators(opGraph, new Dictionary<long, IOperator>());97 96 foreach(IOperator op in opGraph.Operators) OperatorGraph.AddOperator(op); 98 97 OperatorGraph.InitialOperator = opGraph.InitialOperator; 98 PatchOperatorLinks(OperatorGraph); 99 99 } 100 100 return new AgentView(this); 101 101 } 102 102 103 private void DownloadOperators(IOperatorGraph opGraph, Dictionary<long, IOperator> downloaded) {103 private void PatchOperatorLinks(IOperatorGraph opGraph) { 104 104 foreach(IOperator op in opGraph.Operators) { 105 DownloadOperators(op, downloaded);105 PatchOperatorLinks(op); 106 106 } 107 107 } 108 108 109 private void DownloadOperators(IOperator op, Dictionary<long, IOperator> downloaded) {109 private void PatchOperatorLinks(IOperator op) { 110 110 if(op is OperatorLink) { 111 111 OperatorLink link = op as OperatorLink; 112 if(downloaded.ContainsKey(link.Id)) { 113 link.Operator = downloaded[link.Id]; 114 } else { 115 OperatorEntry targetEntry = Database.GetOperator(link.Id); 116 IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData); 117 downloaded.Add(link.Id, target); 118 DownloadOperators(target, downloaded); 119 link.Operator = target; 112 link.Database = Database; 113 //if(downloaded.ContainsKey(link.Id)) { 114 // link.Operator = downloaded[link.Id]; 115 //} else { 116 // OperatorEntry targetEntry = Database.GetOperator(link.Id); 117 // IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData); 118 // downloaded.Add(link.Id, target); 119 // PatchOperatorLinks(target, downloaded); 120 // link.Operator = target; 121 //} 122 } else if(op is CombinedOperator) { 123 PatchOperatorLinks(((CombinedOperator)op).OperatorGraph); 124 } 125 // also patch operator links contained (indirectly) in variables 126 foreach(VariableInfo varInfo in op.VariableInfos) { 127 IVariable var = op.GetVariable(varInfo.ActualName); 128 if(var != null && var.Value is IOperatorGraph) { 129 PatchOperatorLinks((IOperatorGraph)var.Value); 130 } else if(var != null && var.Value is IOperator) { 131 PatchOperatorLinks((IOperator)var.Value); 120 132 } 121 } else if(op is CombinedOperator) {122 DownloadOperators(((CombinedOperator)op).OperatorGraph, downloaded);123 133 } 124 134 } -
trunk/sources/HeuristicLab.CEDMA.Core/AgentView.cs
r407 r512 32 32 namespace HeuristicLab.CEDMA.Core { 33 33 public partial class AgentView : ViewBase { 34 private IAgent agent;35 public IAgent Agent {34 private Agent agent; 35 public Agent Agent { 36 36 get { return agent; } 37 37 set { agent = value; } … … 42 42 Caption = "Agent"; 43 43 } 44 public AgentView( IAgent agent)44 public AgentView(Agent agent) 45 45 : this() { 46 46 Agent = agent; -
trunk/sources/HeuristicLab.CEDMA.Core/DatabaseOperatorLibrary.cs
r421 r512 91 91 } 92 92 93 private void PatchLinks(IOperatorGraph opGraph) { 94 foreach(IOperator op in opGraph.Operators) { 95 PatchLinks(op); 96 } 97 } 98 93 99 private void PatchLinks(IOperator op) { 94 100 if(op is OperatorLink) { 95 101 OperatorLink link = op as OperatorLink; 96 link. Operator = FindOperator(link.Id);102 link.Database = Database; 97 103 } 98 104 else if(op is CombinedOperator) { … … 100 106 foreach(IOperator internalOp in combinedOp.OperatorGraph.Operators) { 101 107 PatchLinks(internalOp); 108 } 109 } 110 // also patch operator links contained (indirectly) in variables 111 foreach(VariableInfo varInfo in op.VariableInfos) { 112 IVariable var = op.GetVariable(varInfo.ActualName); 113 if(var != null && var.Value is IOperatorGraph) { 114 PatchLinks((IOperatorGraph)var.Value); 115 } else if(var != null && var.Value is IOperator) { 116 PatchLinks((IOperator)var.Value); 102 117 } 103 118 } -
trunk/sources/HeuristicLab.CEDMA.Core/OperatorLink.cs
r421 r512 26 26 using HeuristicLab.Core; 27 27 using System.Xml; 28 using HeuristicLab.CEDMA.DB.Interfaces; 29 using HeuristicLab.Operators; 28 30 29 31 namespace HeuristicLab.CEDMA.Core { … … 33 35 get { return id; } 34 36 } 37 38 public IDatabase Database { get; set; } 35 39 36 40 private IOperator myOperator; … … 65 69 66 70 public override IView CreateView() { 71 if(Operator == null) { 72 if(Database == null) return null; 73 OperatorEntry targetEntry = Database.GetOperator(Id); 74 IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData); 75 PatchOperatorLinks(target); 76 Operator = target; 77 } 67 78 return myOperator.CreateView(); 68 79 } … … 84 95 base.Populate(node, restoredObjects); 85 96 } 97 98 private void PatchOperatorLinks(IOperatorGraph opGraph) { 99 foreach(IOperator op in opGraph.Operators) { 100 PatchOperatorLinks(op); 101 } 102 } 103 104 private void PatchOperatorLinks(IOperator op) { 105 if(op is OperatorLink) { 106 OperatorLink link = op as OperatorLink; 107 link.Database = Database; 108 //if(downloaded.ContainsKey(link.Id)) { 109 // link.Operator = downloaded[link.Id]; 110 //} else { 111 // OperatorEntry targetEntry = Database.GetOperator(link.Id); 112 // IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData); 113 // downloaded.Add(link.Id, target); 114 // PatchOperatorLinks(target, downloaded); 115 // link.Operator = target; 116 //} 117 } else if(op is CombinedOperator) { 118 PatchOperatorLinks(((CombinedOperator)op).OperatorGraph); 119 } 120 // also patch operator links contained (indirectily) in variables 121 foreach(VariableInfo varInfo in op.VariableInfos) { 122 IVariable var = op.GetVariable(varInfo.ActualName); 123 if(var != null && var.Value is IOperatorGraph) { 124 PatchOperatorLinks((IOperatorGraph)var.Value); 125 } else if(var != null && var.Value is IOperator) { 126 PatchOperatorLinks((IOperator)var.Value); 127 } 128 } 129 } 86 130 } 87 131 }
Note: See TracChangeset
for help on using the changeset viewer.