[2] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Text;
|
---|
| 25 | using HeuristicLab.Core;
|
---|
| 26 | using HeuristicLab.Data;
|
---|
| 27 |
|
---|
| 28 | namespace HeuristicLab.Operators {
|
---|
[801] | 29 | /// <summary>
|
---|
| 30 | /// Retrieves an operator from a specified scope and returns a successor operation with this operation
|
---|
| 31 | /// and scope.
|
---|
| 32 | /// </summary>
|
---|
[2] | 33 | public class OperatorExtractor : OperatorBase {
|
---|
[801] | 34 | /// <inheritdoc select="summary"/>
|
---|
[2] | 35 | public override string Description {
|
---|
[48] | 36 | get { return @"An operator extractor retrievs an operator from the scope it is applied on and returns a successor operation containing this operator and the current scope. Lookup for the operator is done recursively.
|
---|
| 37 |
|
---|
| 38 | Operator extractors can be used to get those operators again that have been injected by combined operators."; }
|
---|
[2] | 39 | }
|
---|
| 40 |
|
---|
[801] | 41 | /// <summary>
|
---|
| 42 | /// Initializes a new instance of <see cref="OperatorExtractor"/> with
|
---|
| 43 | /// one variable info (<c>Operator</c>).
|
---|
| 44 | /// </summary>
|
---|
[2] | 45 | public OperatorExtractor()
|
---|
| 46 | : base() {
|
---|
[50] | 47 | AddVariableInfo(new VariableInfo("Operator", "Extracted operator", typeof(IOperator), VariableKind.In));
|
---|
[2] | 48 | }
|
---|
| 49 |
|
---|
[801] | 50 | /// <summary>
|
---|
| 51 | /// Gets an operator from the specified <paramref name="scope"/> and returns an
|
---|
| 52 | /// <see cref="AtomicOperation"/> containing this operator and scope.
|
---|
| 53 | /// </summary>
|
---|
| 54 | /// <param name="scope">The scope where to apply the operator on.</param>
|
---|
| 55 | /// <returns>A new <see cref="AtomicOperation"/> containing the operator and the given
|
---|
| 56 | /// <paramref name="scope"/>.</returns>
|
---|
[2] | 57 | public override IOperation Apply(IScope scope) {
|
---|
[50] | 58 | IOperator op = GetVariableValue<IOperator>("Operator", scope, true, true);
|
---|
[2] | 59 | return new AtomicOperation(op, scope);
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 | }
|
---|