Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2898_GeneralizedAdditiveModels/HeuristicLab.Core/3.3/ExecutionContext.cs @ 17357

Last change on this file since 17357 was 15583, checked in by swagner, 7 years ago

#2640: Updated year of copyrights in license headers

File size: 3.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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 HeuristicLab.Common;
24using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
25
26namespace HeuristicLab.Core {
27  [StorableClass]
28  public sealed class ExecutionContext : DeepCloneable, IExecutionContext, IAtomicOperation {
29    [Storable]
30    private IParameterizedItem parameterizedItem;
31
32    [Storable]
33    private IExecutionContext parent;
34    public IExecutionContext Parent {
35      get { return parent; }
36    }
37
38    public IKeyedItemCollection<string, IParameter> Parameters {
39      get { return parameterizedItem.Parameters; }
40    }
41
42    public IOperator Operator {
43      get { return parameterizedItem as IOperator; }
44    }
45
46    [Storable]
47    private IScope scope;
48    public IScope Scope {
49      get { return scope; }
50    }
51
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    }
60    private ExecutionContext() {
61      parent = null;
62      parameterizedItem = null;
63      scope = null;
64    }
65    public ExecutionContext(IExecutionContext parent, IParameterizedItem parameterizedItem, IScope scope) {
66      if ((parameterizedItem == null) || (scope == null)) throw new ArgumentNullException();
67      this.parent = parent;
68      this.parameterizedItem = parameterizedItem;
69      this.scope = scope;
70    }
71
72    public override IDeepCloneable Clone(Cloner cloner) {
73      return new ExecutionContext(this, cloner);
74    }
75
76    public IAtomicOperation CreateOperation(IOperator op) {
77      return new ExecutionContext(parent, op, scope);
78    }
79    public IAtomicOperation CreateOperation(IOperator op, IScope scope) {
80      return new ExecutionContext(parent, op, scope);
81    }
82    public IAtomicOperation CreateChildOperation(IOperator op) {
83      return new ExecutionContext(this, op, scope);
84    }
85    public IAtomicOperation CreateChildOperation(IOperator op, IScope scope) {
86      return new ExecutionContext(this, op, scope);
87    }
88  }
89}
Note: See TracBrowser for help on using the repository browser.