<#@ template inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" #> <#@ output extension=".cs" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ HLSim processor="HLSimDirectiveProcessor" requires="fileName='Model.hlsim'" #> using System; using System.Collections.Generic; using System.Linq; using HeuristicLab.Common; using HeuristicLab.SimulationCore; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Simulation { [StorableClass] partial class <#=this.SimulationModel.ModelType#> : IModel { [Storable] public double CurrentTime { get; set; } private <#=this.SimulationModel.ModelType#>(<#=this.SimulationModel.ModelType#> original, Cloner cloner) { cloner.RegisterClonedObject(original, this); CurrentTime = original.CurrentTime; } public <#=this.SimulationModel.ModelType#>() { } public object Clone() { return Clone(new Cloner()); } public IDeepCloneable Clone(Cloner cloner) { return new <#=this.SimulationModel.ModelType#>(this, cloner); } } <# // When you change the DSL Definition, some of the code below may not work. foreach (var activity in this.SimulationModel.Activities) { #> [StorableClass] partial class <#=activity.Name#> : HeuristicLab.SimulationCore.Activity<<#=this.SimulationModel.ModelType#>> { public override IEnumerable MonitoredActions { get { return new[] { <#=string.Join(", ", activity.Actions.Select(x => "typeof(" + x.Name + ")"))#> }; } } [StorableConstructor] private <#=activity.Name#>(bool deserializing) : base(deserializing) { } private <#=activity.Name#>(<#=activity.Name#> original, Cloner cloner) : base(original, cloner) { } public <#=activity.Name#>() : base(new SortedListEventQueue<<#=this.SimulationModel.ModelType#>>()) { } public override void ManageEvents(<#=this.SimulationModel.ModelType#> model, IAction<<#=this.SimulationModel.ModelType#>> lastAction) { <# foreach (var action in activity.Actions) { #> if (lastAction is <#=action.Name#>) Process<#=action.Name#>(model, (<#=action.Name#>)lastAction); <# } #> } <# foreach (var action in activity.Triggers) { #> private void Enqueue<#=action.Name#>(double time, <#=action.Name#> action) { EventQueue.Push(time, action); } <# } #> public override IDeepCloneable Clone(Cloner cloner) { return new <#=activity.Name#>(this, cloner); } } <# } foreach (var action in this.SimulationModel.Actions) { #> [StorableClass] partial class <#=action.Name#> : HeuristicLab.SimulationCore.Action<<#=this.SimulationModel.ModelType#>> { private <#=action.Name#>(<#=action.Name#> original, Cloner cloner) : base(original, cloner) { } public <#=action.Name#>() { } public override IDeepCloneable Clone(Cloner cloner) { return new <#=action.Name#>(this, cloner); } } <# } #> }