Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.1/sources/HeuristicLab.Communication.Operators/CurrentStateConstraintChecker.cs @ 583

Last change on this file since 583 was 583, checked in by abeham, 16 years ago

Adding communication framework to branch 3.1 (ticket #278)

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using HeuristicLab.Core;
5using HeuristicLab.Data;
6using HeuristicLab.Communication.Data;
7
8namespace HeuristicLab.Communication.Operators {
9  public class CurrentStateConstraintChecker : OperatorBase {
10    public override string Description {
11      get {
12        return @"TODO";
13      }
14    }
15
16    public CurrentStateConstraintChecker() {
17      AddVariableInfo(new VariableInfo("CurrentState", "", typeof(ProtocolState), VariableKind.In));
18    }
19
20    public override IOperation Apply(IScope scope) {
21      ProtocolState currentState = GetVariableValue<ProtocolState>("CurrentState", scope, true);
22      ConstrainedItemList sendingData = (ConstrainedItemList)currentState.SendingData.Clone();
23      sendingData.BeginCombinedOperation();
24      for (int i = 0; i < sendingData.Count; i++) {
25        Variable tmp = (Variable)sendingData[i];
26        tmp.Value = scope.GetVariableValue(tmp.Name, false);
27      }
28      ICollection<IConstraint> violatedConstraints;
29      bool result = sendingData.EndCombinedOperation(out violatedConstraints);
30      if (result) return null;
31      else return new AtomicOperation(SubOperators[0], scope);
32    }
33  }
34}
Note: See TracBrowser for help on using the repository browser.