[2653] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[12012] | 3 | * Copyright (C) 2002-2015 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;
|
---|
[3376] | 23 | using HeuristicLab.Common;
|
---|
[2653] | 24 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 25 |
|
---|
| 26 | namespace HeuristicLab.Core {
|
---|
[13368] | 27 | [StorableClass("159ADE61-BD88-413E-9189-5096B8AB75AA")]
|
---|
[3385] | 28 | public sealed class ExecutionContext : DeepCloneable, IExecutionContext, IAtomicOperation {
|
---|
[2653] | 29 | [Storable]
|
---|
[2834] | 30 | private IParameterizedItem parameterizedItem;
|
---|
| 31 |
|
---|
| 32 | [Storable]
|
---|
| 33 | private IExecutionContext parent;
|
---|
| 34 | public IExecutionContext Parent {
|
---|
[2653] | 35 | get { return parent; }
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[3393] | 38 | public IKeyedItemCollection<string, IParameter> Parameters {
|
---|
[2834] | 39 | get { return parameterizedItem.Parameters; }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
[2653] | 42 | public IOperator Operator {
|
---|
[2834] | 43 | get { return parameterizedItem as IOperator; }
|
---|
[2653] | 44 | }
|
---|
| 45 |
|
---|
| 46 | [Storable]
|
---|
[2687] | 47 | private IScope scope;
|
---|
| 48 | public IScope Scope {
|
---|
[2653] | 49 | get { return scope; }
|
---|
| 50 | }
|
---|
| 51 |
|
---|
[4722] | 52 | [StorableConstructor]
|
---|
| 53 | private ExecutionContext(bool deserializing) { }
|
---|
| 54 | private ExecutionContext(ExecutionContext original, Cloner cloner)
|
---|
| 55 | : base(original, cloner) {
|
---|
| 56 | parent = cloner.Clone(original.parent);
|
---|
| 57 | parameterizedItem = cloner.Clone(original.parameterizedItem);
|
---|
| 58 | scope = cloner.Clone(original.scope);
|
---|
| 59 | }
|
---|
[2653] | 60 | private ExecutionContext() {
|
---|
| 61 | parent = null;
|
---|
[2834] | 62 | parameterizedItem = null;
|
---|
[2653] | 63 | scope = null;
|
---|
| 64 | }
|
---|
[2834] | 65 | public ExecutionContext(IExecutionContext parent, IParameterizedItem parameterizedItem, IScope scope) {
|
---|
| 66 | if ((parameterizedItem == null) || (scope == null)) throw new ArgumentNullException();
|
---|
[2653] | 67 | this.parent = parent;
|
---|
[2834] | 68 | this.parameterizedItem = parameterizedItem;
|
---|
[2653] | 69 | this.scope = scope;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
[3385] | 72 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
[4722] | 73 | return new ExecutionContext(this, cloner);
|
---|
[2653] | 74 | }
|
---|
[2796] | 75 |
|
---|
[2834] | 76 | public IAtomicOperation CreateOperation(IOperator op) {
|
---|
| 77 | return new ExecutionContext(parent, op, scope);
|
---|
[2796] | 78 | }
|
---|
[2834] | 79 | public IAtomicOperation CreateOperation(IOperator op, IScope scope) {
|
---|
| 80 | return new ExecutionContext(parent, op, scope);
|
---|
[2796] | 81 | }
|
---|
[2834] | 82 | public IAtomicOperation CreateChildOperation(IOperator op) {
|
---|
| 83 | return new ExecutionContext(this, op, scope);
|
---|
[2796] | 84 | }
|
---|
[2834] | 85 | public IAtomicOperation CreateChildOperation(IOperator op, IScope scope) {
|
---|
| 86 | return new ExecutionContext(this, op, scope);
|
---|
[2796] | 87 | }
|
---|
[2653] | 88 | }
|
---|
| 89 | }
|
---|