Free cookie consent management tool by TermsFeed Policy Generator

Changeset 512


Ignore:
Timestamp:
08/13/08 16:33:03 (16 years ago)
Author:
gkronber
Message:

worked on #211

Location:
trunk/sources/HeuristicLab.CEDMA.Core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Core/Agent.cs

    r503 r512  
    8888        return results;
    8989      }
    90     } 
     90    }
    9191
    9292    public IView CreateView() {
     
    9494        byte[] rawData = Database.GetAgentRawData(Id);
    9595        IOperatorGraph opGraph = (IOperatorGraph)PersistenceManager.RestoreFromGZip(rawData);
    96         DownloadOperators(opGraph, new Dictionary<long, IOperator>());
    9796        foreach(IOperator op in opGraph.Operators) OperatorGraph.AddOperator(op);
    9897        OperatorGraph.InitialOperator = opGraph.InitialOperator;
     98        PatchOperatorLinks(OperatorGraph);
    9999      }
    100100      return new AgentView(this);
    101101    }
    102102
    103     private void DownloadOperators(IOperatorGraph opGraph, Dictionary<long, IOperator> downloaded) {
     103    private void PatchOperatorLinks(IOperatorGraph opGraph) {
    104104      foreach(IOperator op in opGraph.Operators) {
    105         DownloadOperators(op, downloaded);
     105        PatchOperatorLinks(op);
    106106      }
    107107    }
    108108
    109     private void DownloadOperators(IOperator op, Dictionary<long, IOperator> downloaded) {
     109    private void PatchOperatorLinks(IOperator op) {
    110110      if(op is OperatorLink) {
    111111        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);
    120132        }
    121       } else if(op is CombinedOperator) {
    122         DownloadOperators(((CombinedOperator)op).OperatorGraph, downloaded);
    123133      }
    124134    }
  • trunk/sources/HeuristicLab.CEDMA.Core/AgentView.cs

    r407 r512  
    3232namespace HeuristicLab.CEDMA.Core {
    3333  public partial class AgentView : ViewBase {
    34     private IAgent agent;
    35     public IAgent Agent {
     34    private Agent agent;
     35    public Agent Agent {
    3636      get { return agent; }
    3737      set { agent = value; }
     
    4242      Caption = "Agent";
    4343    }
    44     public AgentView(IAgent agent)
     44    public AgentView(Agent agent)
    4545      : this() {
    4646      Agent = agent;
  • trunk/sources/HeuristicLab.CEDMA.Core/DatabaseOperatorLibrary.cs

    r421 r512  
    9191    }
    9292
     93    private void PatchLinks(IOperatorGraph opGraph) {
     94      foreach(IOperator op in opGraph.Operators) {
     95        PatchLinks(op);
     96      }
     97    }
     98
    9399    private void PatchLinks(IOperator op) {
    94100      if(op is OperatorLink) {
    95101        OperatorLink link = op as OperatorLink;
    96         link.Operator = FindOperator(link.Id);
     102        link.Database = Database;
    97103      }
    98104      else if(op is CombinedOperator) {
     
    100106        foreach(IOperator internalOp in combinedOp.OperatorGraph.Operators) {
    101107          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);
    102117        }
    103118      }
  • trunk/sources/HeuristicLab.CEDMA.Core/OperatorLink.cs

    r421 r512  
    2626using HeuristicLab.Core;
    2727using System.Xml;
     28using HeuristicLab.CEDMA.DB.Interfaces;
     29using HeuristicLab.Operators;
    2830
    2931namespace HeuristicLab.CEDMA.Core {
     
    3335      get { return id; }
    3436    }
     37
     38    public IDatabase Database { get; set; }
    3539
    3640    private IOperator myOperator;
     
    6569
    6670    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      }
    6778      return myOperator.CreateView();
    6879    }
     
    8495      base.Populate(node, restoredObjects);
    8596    }
     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    }
    86130  }
    87131}
Note: See TracChangeset for help on using the changeset viewer.