[10525] | 1 | <#@ template inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" #>
|
---|
| 2 | <#@ output extension=".cs" #>
|
---|
| 3 | <#@ assembly name="System.Core" #>
|
---|
| 4 | <#@ import namespace="System.Linq" #>
|
---|
| 5 | <#@ HLSim processor="HLSimDirectiveProcessor" requires="fileName='Model.hlsim'" #>
|
---|
| 6 | using System;
|
---|
| 7 | using System.Collections.Generic;
|
---|
| 8 | using System.Linq;
|
---|
| 9 | using HeuristicLab.Common;
|
---|
| 10 | using HeuristicLab.SimulationCore;
|
---|
| 11 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 12 |
|
---|
| 13 | namespace HeuristicLab.Simulation {
|
---|
| 14 | [StorableClass]
|
---|
| 15 | partial class <#=this.SimulationModel.ModelType#> : IModel {
|
---|
| 16 | [Storable]
|
---|
| 17 | public double CurrentTime { get; set; }
|
---|
| 18 |
|
---|
| 19 | private <#=this.SimulationModel.ModelType#>(<#=this.SimulationModel.ModelType#> original, Cloner cloner) {
|
---|
| 20 | cloner.RegisterClonedObject(original, this);
|
---|
| 21 | CurrentTime = original.CurrentTime;
|
---|
| 22 | }
|
---|
| 23 | public <#=this.SimulationModel.ModelType#>() { }
|
---|
| 24 |
|
---|
| 25 | public object Clone() { return Clone(new Cloner()); }
|
---|
| 26 | public IDeepCloneable Clone(Cloner cloner) {
|
---|
| 27 | return new <#=this.SimulationModel.ModelType#>(this, cloner);
|
---|
| 28 | }
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | <#
|
---|
| 32 | // When you change the DSL Definition, some of the code below may not work.
|
---|
| 33 |
|
---|
| 34 | foreach (var activity in this.SimulationModel.Activities)
|
---|
| 35 | {
|
---|
| 36 | #>
|
---|
| 37 | [StorableClass]
|
---|
| 38 | partial class <#=activity.Name#> : HeuristicLab.SimulationCore.Activity<<#=this.SimulationModel.ModelType#>> {
|
---|
| 39 | public override IEnumerable<Type> MonitoredActions {
|
---|
| 40 | get { return new[] { <#=string.Join(", ", activity.Actions.Select(x => "typeof(" + x.Name + ")"))#> }; }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | [StorableConstructor]
|
---|
| 44 | private <#=activity.Name#>(bool deserializing) : base(deserializing) { }
|
---|
| 45 | private <#=activity.Name#>(<#=activity.Name#> original, Cloner cloner) : base(original, cloner) { }
|
---|
| 46 | public <#=activity.Name#>() : base(new SortedListEventQueue<<#=this.SimulationModel.ModelType#>>()) { }
|
---|
| 47 |
|
---|
| 48 | public override void ManageEvents(<#=this.SimulationModel.ModelType#> model, IAction<<#=this.SimulationModel.ModelType#>> lastAction) {
|
---|
| 49 | <#
|
---|
| 50 | foreach (var action in activity.Actions)
|
---|
| 51 | {
|
---|
| 52 | #>
|
---|
| 53 | if (lastAction is <#=action.Name#>) Process<#=action.Name#>(model, (<#=action.Name#>)lastAction);
|
---|
| 54 | <#
|
---|
| 55 | }
|
---|
| 56 | #>
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | <#
|
---|
| 60 | foreach (var action in activity.Triggers)
|
---|
| 61 | {
|
---|
| 62 | #>
|
---|
| 63 | private void Enqueue<#=action.Name#>(double time, <#=action.Name#> action) {
|
---|
| 64 | EventQueue.Push(time, action);
|
---|
| 65 | }
|
---|
| 66 | <#
|
---|
| 67 | }
|
---|
| 68 | #>
|
---|
| 69 |
|
---|
| 70 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 71 | return new <#=activity.Name#>(this, cloner);
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | <#
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | foreach (var action in this.SimulationModel.Actions)
|
---|
| 79 | {
|
---|
| 80 | #>
|
---|
| 81 | [StorableClass]
|
---|
| 82 | partial class <#=action.Name#> : HeuristicLab.SimulationCore.Action<<#=this.SimulationModel.ModelType#>> {
|
---|
| 83 |
|
---|
| 84 | private <#=action.Name#>(<#=action.Name#> original, Cloner cloner) : base(original, cloner) { }
|
---|
| 85 | public <#=action.Name#>() { }
|
---|
| 86 |
|
---|
| 87 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 88 | return new <#=action.Name#>(this, cloner);
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
| 91 | <#
|
---|
| 92 | }
|
---|
| 93 | #>
|
---|
| 94 | } |
---|