Changeset 2916 for trunk/sources/HeuristicLab.Core/3.3/Engine.cs
- Timestamp:
- 03/03/10 03:14:37 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Engine.cs
r2851 r2916 39 39 } 40 40 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 72 41 [Storable] 73 42 private TimeSpan executionTime; … … 134 103 /// </summary> 135 104 protected Engine() { 136 globalScope = new Scope("Global");137 105 executionStack = new Stack<IOperation>(); 138 OperatorGraph = new OperatorGraph();139 106 } 140 107 … … 148 115 public override IDeepCloneable Clone(Cloner cloner) { 149 116 Engine clone = (Engine)base.Clone(cloner); 150 clone.OperatorGraph = (OperatorGraph)cloner.Clone(operatorGraph);151 clone.globalScope = (Scope)cloner.Clone(globalScope);152 117 clone.executionTime = executionTime; 153 118 IOperation[] contexts = executionStack.ToArray(); … … 162 127 Canceled = false; 163 128 running = false; 164 globalScope.Clear();165 129 ExecutionTime = new TimeSpan(); 166 130 executionStack.Clear(); … … 168 132 executionStack.Push(initialOperation); 169 133 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));179 134 } 180 135 /// <inheritdoc/> … … 229 184 protected abstract void ProcessNextOperator(); 230 185 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 }246 186 /// <summary> 247 187 /// Occurs when the execution time changed.
Note: See TracChangeset
for help on using the changeset viewer.