Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/03/10 03:14:37 (14 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on engines and algorithms
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.3/Engine.cs

    r2851 r2916  
    3939    }
    4040
    41     private OperatorGraph operatorGraph;
    42     /// <summary>
    43     /// Gets or sets the current operator graph.
    44     /// </summary>
    45     [Storable]
    46     public OperatorGraph OperatorGraph {
    47       get { return operatorGraph; }
    48       set {
    49         if (value == null) throw new ArgumentNullException();
    50         if (value != operatorGraph) {
    51           if (operatorGraph != null) operatorGraph.InitialOperatorChanged -= new EventHandler(operatorGraph_InitialOperatorChanged);
    52           operatorGraph = value;
    53           if (operatorGraph != null) operatorGraph.InitialOperatorChanged += new EventHandler(operatorGraph_InitialOperatorChanged);
    54           OnOperatorGraphChanged();
    55           Prepare();
    56         }
    57       }
    58     }
    59 
    60     /// <summary>
    61     /// Field of the current instance that represent the global scope.
    62     /// </summary>
    63     [Storable]
    64     private IScope globalScope;
    65     /// <summary>
    66     /// Gets the current global scope.
    67     /// </summary>
    68     public IScope GlobalScope {
    69       get { return globalScope; }
    70     }
    71 
    7241    [Storable]
    7342    private TimeSpan executionTime;
     
    134103    /// </summary>
    135104    protected Engine() {
    136       globalScope = new Scope("Global");
    137105      executionStack = new Stack<IOperation>();
    138       OperatorGraph = new OperatorGraph();
    139106    }
    140107
     
    148115    public override IDeepCloneable Clone(Cloner cloner) {
    149116      Engine clone = (Engine)base.Clone(cloner);
    150       clone.OperatorGraph = (OperatorGraph)cloner.Clone(operatorGraph);
    151       clone.globalScope = (Scope)cloner.Clone(globalScope);
    152117      clone.executionTime = executionTime;
    153118      IOperation[] contexts = executionStack.ToArray();
     
    162127      Canceled = false;
    163128      running = false;
    164       globalScope.Clear();
    165129      ExecutionTime = new TimeSpan();
    166130      executionStack.Clear();
     
    168132        executionStack.Push(initialOperation);
    169133      OnPrepared();
    170     }
    171     /// <inheritdoc/>
    172     /// <remarks>Sets <c>myCanceled</c> and <c>myRunning</c> to <c>false</c>. The global scope is cleared,
    173     /// the execution time is reset, the execution stack is cleared and a new <see cref="AtomicOperation"/>
    174     /// with the initial operator is added. <br/>
    175     /// Calls <see cref="OnPrepared"/>.</remarks>
    176     public void Prepare() {
    177       if (OperatorGraph.InitialOperator != null)
    178         Prepare(new ExecutionContext(null, OperatorGraph.InitialOperator, GlobalScope));
    179134    }
    180135    /// <inheritdoc/>
     
    229184    protected abstract void ProcessNextOperator();
    230185
    231     private void operatorGraph_InitialOperatorChanged(object sender, EventArgs e) {
    232       Prepare();
    233     }
    234 
    235     /// <summary>
    236     /// Occurs when the operator graph was changed.
    237     /// </summary>
    238     public event EventHandler OperatorGraphChanged;
    239     /// <summary>
    240     /// Fires a new <c>OperatorGraphChanged</c> event.
    241     /// </summary>
    242     protected virtual void OnOperatorGraphChanged() {
    243       if (OperatorGraphChanged != null)
    244         OperatorGraphChanged(this, EventArgs.Empty);
    245     }
    246186    /// <summary>
    247187    /// Occurs when the execution time changed.
Note: See TracChangeset for help on using the changeset viewer.