Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/01/08 21:35:35 (16 years ago)
Author:
gkronber
Message:

worked on #211.

  • Implemented downloading of linked operators from the database in AgentList (to allow view/edit of the whole operator graph)
  • Implemented downloading and patching of linked operators in RunScheduler to prepare the operator-graph for execution (OperatorLink operator can't be executed)

(there is some code duplication because the patching is very similar in AgentList DatabaseOperatorLibrary and RunScheduler. This needs some more work)

File:
1 edited

Legend:

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

    r403 r420  
    3030using System.Runtime.Serialization;
    3131using System.IO;
     32using HeuristicLab.Operators;
    3233
    3334namespace HeuristicLab.CEDMA.Core {
     
    5051        newAgent.Status = a.Status;
    5152        IOperatorGraph opGraph = (IOperatorGraph)PersistenceManager.RestoreFromGZip(a.RawData);
    52         foreach(IOperator op in opGraph.Operators) newAgent.OperatorGraph.AddOperator(op);
     53
     54        DownloadOperators(opGraph, new Dictionary<long, IOperator>());
     55
     56        foreach(IOperator op in opGraph.Operators) {
     57          newAgent.OperatorGraph.AddOperator(op);
     58        }
    5359        newAgent.OperatorGraph.InitialOperator = opGraph.InitialOperator;
    5460        agentList.Add(newAgent);
     
    8086    }
    8187
     88    private void DownloadOperators(IOperatorGraph opGraph, Dictionary<long, IOperator> downloaded) {
     89      foreach(IOperator op in opGraph.Operators) {
     90        DownloadOperators(op, downloaded);
     91      }
     92    }
     93
     94    private void DownloadOperators(IOperator op, Dictionary<long, IOperator> downloaded) {
     95      if(op is OperatorLink) {
     96        OperatorLink link = op as OperatorLink;
     97        if(downloaded.ContainsKey(link.Id)) {
     98          link.Operator = downloaded[link.Id];
     99        } else {
     100          OperatorEntry targetEntry = database.GetOperator(link.Id);
     101          IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData);
     102          downloaded.Add(link.Id, target);
     103          DownloadOperators(target, downloaded);
     104          link.Operator = target;
     105        }
     106      } else if(op is CombinedOperator) {
     107        DownloadOperators(((CombinedOperator)op).OperatorGraph, downloaded);
     108      }
     109    }
     110
    82111    public override IView CreateView() {
    83112      return new AgentListView(this);
Note: See TracChangeset for help on using the changeset viewer.