Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/06/09 02:09:35 (15 years ago)
Author:
swagner
Message:

Refactoring of the operator architecture (#95)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Operator Architecture Refactoring/HeuristicLab.Operators/3.2/ComparatorBase.cs

    r1530 r2027  
    3636    /// </summary>
    3737    protected ComparatorBase() {
    38       AddVariableInfo(new VariableInfo("LeftSide", "Variable on the left side of the comparison", typeof(IItem), VariableKind.In));
    39       AddVariableInfo(new VariableInfo("RightSide", "Variable on the right side of the comparison", typeof(IItem), VariableKind.In));
    40       AddVariableInfo(new VariableInfo("Result", "Result of the comparison", typeof(BoolData), VariableKind.Out | VariableKind.New));
     38      AddParameter(new Parameter("LeftSide", "Variable on the left side of the comparison", typeof(IItem), ParameterType.In));
     39      AddParameter(new Parameter("RightSide", "Variable on the right side of the comparison", typeof(IItem), ParameterType.In));
     40      AddParameter(new Parameter("Result", "Result of the comparison", typeof(BoolData), ParameterType.Out));
    4141    }
    4242
     
    5050    /// <param name="scope">The scope where to apply the compare operation.</param>
    5151    /// <returns><c>null</c>.</returns>
    52     public override IOperation Apply(IScope scope) {
    53       BoolData result = GetVariableValue<BoolData>("Result", scope, false, false);
     52    public override IOperation Apply(IEnvironment env, IScope scope) {
     53      string resultName = env.TranslateName("Result");
     54      BoolData result = scope.GetVariableValue<BoolData>(resultName, false, false);
    5455      if (result == null) {
    5556        result = new BoolData(true);
    56         IVariableInfo info = GetVariableInfo("Result");
    57         if (info.Local)
    58           AddVariable(new Variable(info.ActualName, result));
    59         else
    60           scope.AddVariable(new Variable(scope.TranslateName(info.FormalName), result));
     57        scope.AddVariable(new Variable(resultName, result));
    6158      }
    62       IItem leftSide = GetVariableValue<IItem>("LeftSide", scope, true);
     59      IItem leftSide = scope.GetVariableValue<IItem>(env.TranslateName("LeftSide"), true);
    6360      if (!(leftSide is IComparable)) throw new InvalidOperationException("Comparator: Left side needs to be of type IComparable");
    6461      IComparable left = (IComparable)leftSide;
    65       IItem rightSide = GetVariableValue<IItem>("RightSide", scope, true);
     62      IItem rightSide = scope.GetVariableValue<IItem>(env.TranslateName("RightSide"), true);
    6663      result.Data = Compare(left, rightSide);
    6764      return null;
Note: See TracChangeset for help on using the changeset viewer.