Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Core/3.3/AtomicOperation.cs @ 2553

Last change on this file since 2553 was 2526, checked in by swagner, 15 years ago

Refactored cloning (#806)

File size: 2.9 KB
RevLine 
[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
22using System;
23using System.Collections.Generic;
24using System.Text;
25using System.Xml;
[1823]26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[2]27
28namespace HeuristicLab.Core {
[776]29  /// <summary>
30  /// Represents a single operation with one operator and one scope.
31  /// </summary>
[2]32  public class AtomicOperation : ItemBase, IOperation {
[1667]33
34    [Storable]
[2]35    private IOperator myOperator;
[776]36    /// <summary>
37    /// Gets the current operator as <see cref="IOperator"/>.
38    /// </summary>
[2]39    public IOperator Operator {
40      get { return myOperator; }
41    }
[1667]42
43    [Storable]
44    private IScope myScope;
[776]45    /// <summary>
46    /// Gets the current scope as <see cref="IScope"/>.
47    /// </summary>
[2]48    public IScope Scope {
49      get { return myScope; }
50    }
51
[776]52    /// <summary>
53    /// Initializes a new instance of <see cref="AtomicOperation"/>.
54    /// </summary>
[2]55    public AtomicOperation() { }
[776]56    /// <summary>
57    /// Initializes a new instance of <see cref="AtomicOperation"/> with the given <paramref name="op"/>
58    /// and the given <paramref name="scope"/>.
59    /// </summary>
60    /// <param name="op">The operator to assign.</param>
61    /// <param name="scope">The scope to assign.</param>
[2]62    public AtomicOperation(IOperator op, IScope scope) {
63      myOperator = op;
64      myScope = scope;
65    }
66
[776]67    /// <summary>
68    /// Clones the current instance.
69    /// </summary>
70    /// <remarks>The operator and the scope objects are cloned with the
[2526]71    /// <see cref="HeuristicLab.Core.cloner.Clone"/> method of the <see cref="Auxiliary"/> class.</remarks>
[776]72    /// <param name="clonedObjects">All already cloned objects. (Needed to avoid cycles.)</param>
73    /// <returns>The cloned object as <see cref="AtomicOperation"/>.</returns>
[2526]74    public override IItem Clone(ICloner cloner) {
[2]75      AtomicOperation clone = new AtomicOperation();
[2526]76      cloner.RegisterClonedObject(this, clone);
77      clone.myOperator = (IOperator)cloner.Clone(Operator);
78      clone.myScope = (IScope)cloner.Clone(Scope);
[2]79      return clone;
80    }
81  }
82}
Note: See TracBrowser for help on using the repository browser.