Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1847 for trunk


Ignore:
Timestamp:
05/18/09 23:14:57 (16 years ago)
Author:
gkronber
Message:

Fixed #633 for the SequentialEngine by:

  • introducing a boolean property into IOperator that indicates if an operator supports abortion.
  • pushing the current operation back onto the execution stack of the SequentialEngine when the current operator can be aborted.
Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.2/Interfaces/IOperator.cs

    r776 r1847  
    6060    /// </summary>
    6161    ICollection<IVariable> Variables { get; }
    62 
     62    /// <summary>
     63    /// Gets information whether abortion of the operator is supported.
     64    /// </summary>
     65    bool SupportsAbort { get; }
    6366    /// <summary>
    6467    /// Adds the given sub operator to the current instance.
  • trunk/sources/HeuristicLab.Core/3.2/OperatorBase.cs

    r1529 r1847  
    8989    public virtual ICollection<IVariable> Variables {
    9090      get { return myVariables.Values; }
     91    }
     92    /// <inheritdoc/>
     93    /// The default is false.
     94    public virtual bool SupportsAbort {
     95      get { return false; }
    9196    }
    9297
  • trunk/sources/HeuristicLab.SequentialEngine/3.2/SequentialEngine.cs

    r1530 r1847  
    3333  public class SequentialEngine : EngineBase, IEditable {
    3434    private IOperator currentOperator;
     35    private IOperation currentOperation;
    3536
    3637    /// <summary>
     
    5758    public override void Abort() {
    5859      base.Abort();
    59       if (currentOperator != null)
     60      if (currentOperator != null && currentOperator.SupportsAbort) {
    6061        currentOperator.Abort();
     62        myExecutionStack.Push(currentOperation);
     63      }
    6164    }
    6265
     
    6972    /// If the execution was successful <see cref="EngineBase.OnOperationExecuted"/> is called.</remarks>
    7073    protected override void ProcessNextOperation() {
    71       IOperation operation = myExecutionStack.Pop();
    72       if (operation is AtomicOperation) {
    73         AtomicOperation atomicOperation = (AtomicOperation)operation;
     74      currentOperation = myExecutionStack.Pop();
     75      if (currentOperation is AtomicOperation) {
     76        AtomicOperation atomicOperation = (AtomicOperation)currentOperation;
    7477        IOperation next = null;
    7578        try {
     
    8790        OnOperationExecuted(atomicOperation);
    8891        if (atomicOperation.Operator.Breakpoint) Abort();
    89       } else if (operation is CompositeOperation) {
    90         CompositeOperation compositeOperation = (CompositeOperation)operation;
     92      } else if (currentOperation is CompositeOperation) {
     93        CompositeOperation compositeOperation = (CompositeOperation)currentOperation;
    9194        for (int i = compositeOperation.Operations.Count - 1; i >= 0; i--)
    9295          myExecutionStack.Push(compositeOperation.Operations[i]);
Note: See TracChangeset for help on using the changeset viewer.