Last change
on this file since 1844 was
1529,
checked in by gkronber, 15 years ago
|
Moved source files of plugins AdvancedOptimizationFrontEnd ... Grid into version-specific sub-folders. #576
|
File size:
1.3 KB
|
Rev | Line | |
---|
[704] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Text;
|
---|
| 4 | using HeuristicLab.Core;
|
---|
| 5 | using HeuristicLab.Communication.Data;
|
---|
| 6 |
|
---|
| 7 | namespace HeuristicLab.Communication.Operators {
|
---|
| 8 | public class SubScopeMessageDecomposer : OperatorBase {
|
---|
| 9 | public override string Description {
|
---|
| 10 | get {
|
---|
| 11 | return @"Takes a message and extracts the contents into subscopes";
|
---|
| 12 | }
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | public SubScopeMessageDecomposer()
|
---|
| 16 | : base() {
|
---|
| 17 | AddVariableInfo(new VariableInfo("Message", "The message to decompose", typeof(Message), VariableKind.In | VariableKind.Deleted));
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | public override IOperation Apply(IScope scope) {
|
---|
| 21 | Message message = GetVariableValue<Message>("Message", scope, false);
|
---|
[1411] | 22 | if (message.Give.Count > scope.SubScopes.Count) throw new InvalidOperationException("ERROR in SubScopeMessageDecomposer: There are not enough subscopes to put the contents of the message into");
|
---|
[704] | 23 | int i = 0;
|
---|
[1207] | 24 | foreach (IVariable var in message.Give) {
|
---|
[704] | 25 | scope.SubScopes[i].AddVariable(var);
|
---|
[1411] | 26 | i++;
|
---|
[704] | 27 | }
|
---|
| 28 | IVariableInfo info = GetVariableInfo("Message");
|
---|
| 29 | if (info.Local) {
|
---|
| 30 | RemoveVariable(info.ActualName);
|
---|
| 31 | } else {
|
---|
| 32 | scope.RemoveVariable(scope.TranslateName(info.FormalName));
|
---|
| 33 | }
|
---|
| 34 | return null;
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.