[2653] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[2790] | 3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[2653] | 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.Collections.Generic;
|
---|
[2757] | 23 | using System.Linq;
|
---|
[2653] | 24 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 25 |
|
---|
| 26 | namespace HeuristicLab.Core {
|
---|
[3017] | 27 | [StorableClass]
|
---|
[2834] | 28 | public class OperationCollection : DeepCloneable, IList<IOperation>, IOperation {
|
---|
[2653] | 29 | [Storable]
|
---|
[2834] | 30 | private IList<IOperation> operations;
|
---|
[2653] | 31 |
|
---|
| 32 | [Storable]
|
---|
| 33 | private bool parallel;
|
---|
| 34 | public bool Parallel {
|
---|
| 35 | get { return parallel; }
|
---|
| 36 | set { parallel = value; }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
[2834] | 39 | public OperationCollection() {
|
---|
| 40 | operations = new List<IOperation>();
|
---|
[2653] | 41 | parallel = false;
|
---|
| 42 | }
|
---|
[2834] | 43 | public OperationCollection(IEnumerable<IOperation> collection) {
|
---|
| 44 | operations = new List<IOperation>(collection.Where(e => e != null));
|
---|
[2653] | 45 | parallel = false;
|
---|
| 46 | }
|
---|
[2834] | 47 | public OperationCollection(params IOperation[] list) {
|
---|
| 48 | operations = new List<IOperation>(list.Where(e => e != null));
|
---|
[2653] | 49 | parallel = false;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
[2834] | 53 | OperationCollection clone = new OperationCollection(this.Select(x => (IOperation)cloner.Clone(x)));
|
---|
[2653] | 54 | cloner.RegisterClonedObject(this, clone);
|
---|
| 55 | clone.parallel = parallel;
|
---|
| 56 | return clone;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
[2834] | 59 | #region IList<IOperation> Members
|
---|
| 60 | public int IndexOf(IOperation item) {
|
---|
| 61 | return operations.IndexOf(item);
|
---|
[2653] | 62 | }
|
---|
[2834] | 63 | public void Insert(int index, IOperation item) {
|
---|
| 64 | if (item != null) operations.Insert(index, item);
|
---|
[2653] | 65 | }
|
---|
| 66 | public void RemoveAt(int index) {
|
---|
[2834] | 67 | operations.RemoveAt(index);
|
---|
[2653] | 68 | }
|
---|
[2834] | 69 | public IOperation this[int index] {
|
---|
| 70 | get { return operations[index]; }
|
---|
| 71 | set { if (value != null) operations[index] = value; }
|
---|
[2653] | 72 | }
|
---|
| 73 | #endregion
|
---|
| 74 |
|
---|
[2834] | 75 | #region ICollection<IOperation> Members
|
---|
| 76 | public void Add(IOperation item) {
|
---|
| 77 | if (item != null) operations.Add(item);
|
---|
[2653] | 78 | }
|
---|
| 79 | public void Clear() {
|
---|
[2834] | 80 | operations.Clear();
|
---|
[2653] | 81 | }
|
---|
[2834] | 82 | public bool Contains(IOperation item) {
|
---|
| 83 | return operations.Contains(item);
|
---|
[2653] | 84 | }
|
---|
[2834] | 85 | public void CopyTo(IOperation[] array, int arrayIndex) {
|
---|
| 86 | operations.CopyTo(array, arrayIndex);
|
---|
[2653] | 87 | }
|
---|
| 88 | public int Count {
|
---|
[2834] | 89 | get { return operations.Count; }
|
---|
[2653] | 90 | }
|
---|
| 91 | public bool IsReadOnly {
|
---|
[2834] | 92 | get { return operations.IsReadOnly; }
|
---|
[2653] | 93 | }
|
---|
[2834] | 94 | public bool Remove(IOperation item) {
|
---|
| 95 | return operations.Remove(item);
|
---|
[2653] | 96 | }
|
---|
| 97 | #endregion
|
---|
| 98 |
|
---|
[2834] | 99 | #region IEnumerable<IOperation> Members
|
---|
| 100 | public IEnumerator<IOperation> GetEnumerator() {
|
---|
| 101 | return operations.GetEnumerator();
|
---|
[2653] | 102 | }
|
---|
| 103 | #endregion
|
---|
| 104 |
|
---|
| 105 | #region IEnumerable Members
|
---|
| 106 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
|
---|
[2834] | 107 | return operations.GetEnumerator();
|
---|
[2653] | 108 | }
|
---|
| 109 | #endregion
|
---|
| 110 | }
|
---|
| 111 | }
|
---|