Free cookie consent management tool by TermsFeed Policy Generator

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

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

Operator architecture refactoring (#95)

  • worked on operators, parameters and problems
File size: 2.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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 System.Collections.Generic;
24using System.Text;
25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
26
27namespace HeuristicLab.Core {
28  public class ExecutionContext : DeepCloneable, IExecutionSequence {
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]
42    private IScope scope;
43    public IScope Scope {
44      get { return scope; }
45    }
46
47    [Storable]
48    private IProblem problem;
49    public IProblem Problem {
50      get { return problem; }
51    }
52
53    private ExecutionContext() {
54      parent = null;
55      op = null;
56      scope = null;
57      problem = null;
58    }
59    public ExecutionContext(ExecutionContext parent, IOperator op, IScope scope, IProblem problem) {
60      if ((op == null) || (scope == null) || (problem == null)) throw new ArgumentNullException();
61      this.parent = parent;
62      this.op = op;
63      this.scope = scope;
64      this.problem = problem;
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);
72      clone.scope = (IScope)cloner.Clone(scope);
73      clone.problem = (IProblem)cloner.Clone(problem);
74      return clone;
75    }
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    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.