Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Core/3.3/ExecutionContext.cs @ 2806

Last change on this file since 2806 was 2796, checked in by swagner, 15 years ago

Operator architecture refactoring (#95)

  • worked on operators, parameters and problems
File size: 2.9 KB
RevLine 
[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
22using System;
23using System.Collections.Generic;
24using System.Text;
25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
26
27namespace HeuristicLab.Core {
[2773]28  public class ExecutionContext : DeepCloneable, IExecutionSequence {
[2653]29    [Storable]
30    private ExecutionContext parent;
31    public ExecutionContext Parent {
32      get { return parent; }
33    }
34
35    [Storable]
36    private IOperator op;
37    public IOperator Operator {
38      get { return op; }
39    }
40
41    [Storable]
[2687]42    private IScope scope;
43    public IScope Scope {
[2653]44      get { return scope; }
45    }
46
[2796]47    [Storable]
48    private IProblem problem;
49    public IProblem Problem {
50      get { return problem; }
51    }
52
[2653]53    private ExecutionContext() {
54      parent = null;
55      op = null;
56      scope = null;
[2796]57      problem = null;
[2653]58    }
[2796]59    public ExecutionContext(ExecutionContext parent, IOperator op, IScope scope, IProblem problem) {
60      if ((op == null) || (scope == null) || (problem == null)) throw new ArgumentNullException();
[2653]61      this.parent = parent;
62      this.op = op;
63      this.scope = scope;
[2796]64      this.problem = problem;
[2653]65    }
66
67    public override IDeepCloneable Clone(Cloner cloner) {
68      ExecutionContext clone = new ExecutionContext();
69      cloner.RegisterClonedObject(this, clone);
70      clone.parent = (ExecutionContext)cloner.Clone(parent);
71      clone.op = (IOperator)cloner.Clone(op);
[2687]72      clone.scope = (IScope)cloner.Clone(scope);
[2796]73      clone.problem = (IProblem)cloner.Clone(problem);
[2653]74      return clone;
75    }
[2796]76
77    public ExecutionContext CreateContext(IOperator op) {
78      return new ExecutionContext(parent, op, scope, problem);
79    }
80    public ExecutionContext CreateContext(IOperator op, IScope scope) {
81      return new ExecutionContext(parent, op, scope, problem);
82    }
83    public ExecutionContext CreateChildContext(IOperator op) {
84      return new ExecutionContext(this, op, scope, problem);
85    }
86    public ExecutionContext CreateChildContext(IOperator op, IScope scope) {
87      return new ExecutionContext(this, op, scope, problem);
88    }
[2653]89  }
90}
Note: See TracBrowser for help on using the repository browser.