#region License Information /* HeuristicLab * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections.Generic; using System.Text; using System.Xml; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Core { /// /// Represents a class for operations consisting themselves of several operations. /// Can also be executed in parallel. /// public class CompositeOperation : ItemBase, IOperation { [Storable] private bool myExecuteInParallel; /// /// Gets or sets the bool value, whether the operation should be executed in parallel or not. /// public bool ExecuteInParallel { get { return myExecuteInParallel; } set { myExecuteInParallel = value; } } [Storable] private List myOperations; /// /// Gets all current operations. /// Operations are read-only! /// public IList Operations { get { return myOperations.AsReadOnly(); } } /// /// Initializes a new instance of , the /// property set to false. /// public CompositeOperation() { myOperations = new List(); myExecuteInParallel = false; } /// /// Adds an operation to the current list of operations. /// /// The operation to add. public void AddOperation(IOperation operation) { myOperations.Add(operation); } /// /// Removes an operation from the current list. /// /// The operation to remove. public void RemoveOperation(IOperation operation) { myOperations.Remove(operation); } /// /// Clones the current instance of (deep clone). /// /// All operations of the current instance are cloned, too (deep clone), with the /// method of the class . /// A dictionary of all already cloned objects. (Needed to avoid cycles.) /// The cloned operation as . public override IItem Clone(ICloner cloner) { CompositeOperation clone = new CompositeOperation(); cloner.RegisterClonedObject(this, clone); clone.myExecuteInParallel = ExecuteInParallel; for (int i = 0; i < Operations.Count; i++) clone.AddOperation((IOperation)cloner.Clone(Operations[i])); return clone; } } }