Changeset 2684 for trunk/sources
- Timestamp:
- 01/26/10 05:14:51 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 6 deleted
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/HeuristicLab.Core.Views-3.3.csproj
r2665 r2684 95 95 <DependentUpon>OperatorGraphView.cs</DependentUpon> 96 96 </Compile> 97 <Compile Include="OperatorListView.cs"> 98 <SubType>UserControl</SubType> 99 </Compile> 100 <Compile Include="OperatorListView.Designer.cs"> 101 <DependentUpon>OperatorListView.cs</DependentUpon> 102 </Compile> 97 103 <Compile Include="OperatorsSidebar.cs"> 98 104 <SubType>UserControl</SubType> … … 154 160 <Compile Include="ScopeListView.Designer.cs"> 155 161 <DependentUpon>ScopeListView.cs</DependentUpon> 156 </Compile>157 <Compile Include="OperatorListView.cs">158 <SubType>UserControl</SubType>159 </Compile>160 <Compile Include="OperatorListView.Designer.cs">161 <DependentUpon>OperatorListView.cs</DependentUpon>162 162 </Compile> 163 163 <Compile Include="ItemListView.cs"> -
trunk/sources/HeuristicLab.Core.Views/3.3/ViewHost.cs
r2676 r2684 57 57 viewPanel.Controls.Clear(); 58 58 viewPanel.Enabled = false; 59 viewPanel.Visible = false; 59 60 60 61 if (Object != null) { … … 79 80 view.Dock = DockStyle.Fill; 80 81 viewPanel.Enabled = true; 82 viewPanel.Visible = true; 81 83 viewComboBox.SelectedItem = view.GetType(); 82 84 } -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IParameter.cs
r2653 r2684 31 31 32 32 IItem GetValue(ExecutionContext context); 33 IItem GetValue(ExecutionContext context, bool throwOnError); 33 34 } 34 35 } -
trunk/sources/HeuristicLab.Core/3.3/ItemCollection.cs
r2653 r2684 87 87 foreach (T item in items) 88 88 if (item != null) item.Changed += new ChangedEventHandler(Item_Changed); 89 IEnumerable<IEngine> i = (IEnumerable<IEngine>)items; 89 90 base.OnItemsAdded(items); 90 91 } -
trunk/sources/HeuristicLab.Core/3.3/ItemParameter.cs
r2664 r2684 31 31 /// Represents a parameter. 32 32 /// </summary> 33 [Item("Item 33 [Item("ItemParameter", "A parameter which represents an IItem.")] 34 34 [Creatable("Test")] 35 35 public class ItemParameter : Parameter { … … 84 84 85 85 public override IItem GetValue(ExecutionContext context) { 86 return GetValue(context, true); 87 } 88 public override IItem GetValue(ExecutionContext context, bool throwOnError) { 86 89 if (Value != null) return Value; 87 90 ExecutionContext parent = context.Parent; … … 94 97 95 98 if (parameter != null) return parameter.GetValue(context); 96 else return context.Scope.Lookup(ActualName, true).Value; 99 else { 100 Variable variable = context.Scope.Lookup(ActualName, true, throwOnError); 101 return variable == null ? null : variable.Value; 102 } 97 103 } 98 104 … … 126 132 } 127 133 128 [Item(" Parameter<T>", "A generic parameter which represents an instance of type T.")]134 [Item("ItemParameter<T>", "A generic parameter which represents an instance of type T.")] 129 135 [EmptyStorableClass] 130 136 public class ItemParameter<T> : ItemParameter where T : class, IItem { … … 148 154 149 155 public new T GetValue(ExecutionContext context) { 150 return (T)base.GetValue(context); 156 return GetValue(context, true); 157 } 158 public new T GetValue(ExecutionContext context, bool throwOnError) { 159 return (T)base.GetValue(context, throwOnError); 151 160 } 152 161 } -
trunk/sources/HeuristicLab.Core/3.3/Parameter.cs
r2669 r2684 57 57 58 58 public abstract IItem GetValue(ExecutionContext context); 59 public abstract IItem GetValue(ExecutionContext context, bool throwOnError); 59 60 60 61 public override IDeepCloneable Clone(Cloner cloner) { -
trunk/sources/HeuristicLab.Data/3.3/BoolData.cs
r2676 r2684 29 29 namespace HeuristicLab.Data { 30 30 [EmptyStorableClass] 31 [Item("Bool ean", "Represents a boolean value.")]31 [Item("BoolData", "Represents a boolean value.")] 32 32 [Creatable("Test")] 33 33 public sealed class BoolData : ValueTypeData<bool>, IStringConvertibleData { -
trunk/sources/HeuristicLab.Data/3.3/DateTimeData.cs
r2676 r2684 29 29 namespace HeuristicLab.Data { 30 30 [EmptyStorableClass] 31 [Item("DateTime ", "Represents a date and time value.")]31 [Item("DateTimeData", "Represents a date and time value.")] 32 32 [Creatable("Test")] 33 33 public sealed class DateTimeData : ValueTypeData<DateTime>, IStringConvertibleData { -
trunk/sources/HeuristicLab.Data/3.3/DoubleData.cs
r2676 r2684 29 29 namespace HeuristicLab.Data { 30 30 [EmptyStorableClass] 31 [Item("Double ", "Represents a double value.")]31 [Item("DoubleData", "Represents a double value.")] 32 32 [Creatable("Test")] 33 33 public sealed class DoubleData : ValueTypeData<double>, IStringConvertibleData { -
trunk/sources/HeuristicLab.Data/3.3/IntData.cs
r2676 r2684 29 29 namespace HeuristicLab.Data { 30 30 [EmptyStorableClass] 31 [Item("Int eger", "Represents an integer value.")]31 [Item("IntData", "Represents an integer value.")] 32 32 [Creatable("Test")] 33 33 public sealed class IntData : ValueTypeData<int>, IStringConvertibleData { -
trunk/sources/HeuristicLab.Data/3.3/StringData.cs
r2676 r2684 29 29 namespace HeuristicLab.Data { 30 30 [EmptyStorableClass] 31 [Item("String ", "Represents a string.")]31 [Item("StringData", "Represents a string.")] 32 32 [Creatable("Test")] 33 33 public sealed class StringData : Item, IStringConvertibleData { -
trunk/sources/HeuristicLab.Data/3.3/TimeSpanData.cs
r2676 r2684 29 29 namespace HeuristicLab.Data { 30 30 [EmptyStorableClass] 31 [Item("TimeSpan ", "Represents a duration of time.")]31 [Item("TimeSpanData", "Represents a duration of time.")] 32 32 [Creatable("Test")] 33 33 public sealed class TimeSpanData : ValueTypeData<TimeSpan>, IStringConvertibleData { -
trunk/sources/HeuristicLab.Operators.Views/3.3/HeuristicLab.Operators.Views-3.3.csproj
r2664 r2684 51 51 </ItemGroup> 52 52 <ItemGroup> 53 <Compile Include="CombinedOperatorView.cs"> 54 <SubType>UserControl</SubType> 55 </Compile> 56 <Compile Include="CombinedOperatorView.Designer.cs"> 57 <DependentUpon>CombinedOperatorView.cs</DependentUpon> 58 </Compile> 53 59 <Compile Include="HeuristicLabOperatorsViewsPlugin.cs" /> 54 60 <Compile Include="OperatorView.cs"> -
trunk/sources/HeuristicLab.Operators/3.3/CombinedOperator.cs
r2526 r2684 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Text; 25 26 using System.Xml; 27 using HeuristicLab.Collections; 26 28 using HeuristicLab.Core; 27 29 using HeuristicLab.Data; … … 30 32 namespace HeuristicLab.Operators { 31 33 /// <summary> 32 /// Contains an operator graph and automatically injects its sub-operators into the scope it is 33 /// applied on (useful for modularization to assemble complex operators out of simpler ones). 34 /// Operator which contains an operator graph. 34 35 /// </summary> 35 public class CombinedOperator : DelegatingOperator { 36 36 [Item("CombinedOperator", "An operator which contains an operator graph.")] 37 [Creatable("Test")] 38 public sealed class CombinedOperator : StandardOperator, IOperator { 39 public override Image ItemImage { 40 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Module; } 41 } 37 42 [Storable] 38 private string myDescription; 39 /// <summary> 40 /// Gets the description of the current instance. 41 /// </summary> 42 public override string Description { 43 get { return myDescription; } 43 private OperatorGraph operatorGraph; 44 public OperatorGraph OperatorGraph { 45 get { return operatorGraph; } 46 } 47 public new ParameterCollection Parameters { 48 get { 49 return base.Parameters; 50 } 51 } 52 IObservableKeyedCollection<string, IParameter> IOperator.Parameters { 53 get { return Parameters; } 54 } 55 public override bool CanChangeDescription { 56 get { return true; } 44 57 } 45 58 46 [Storable] 47 private IOperatorGraph myOperatorGraph; 48 /// <summary> 49 /// Gets the operator graph of the current instance. 50 /// </summary> 51 public IOperatorGraph OperatorGraph { 52 get { return myOperatorGraph; } 59 public CombinedOperator() 60 : base() { 61 operatorGraph = new OperatorGraph(); 53 62 } 54 63 55 /// <summary> 56 /// Initializes a new instance of <see cref="CombinedOperator"/>. 57 /// </summary> 58 public CombinedOperator() 59 : base() { 60 myDescription = 61 @"A combined operator contains a whole operator graph. It is useful for modularization to assemble complex operators out of simpler ones. 62 63 A combined operator automatically inject its sub-operators into the scope it is applied on. Thereby the names of the sub-operators are used as variable names. Those operators can be extracted again in the contained operator graph by using an OperatorExtractor. So it is possible to parameterize a combined operator with custom operators."; 64 myOperatorGraph = new OperatorGraph(); 64 public override IDeepCloneable Clone(Cloner cloner) { 65 CombinedOperator clone = (CombinedOperator)base.Clone(cloner); 66 clone.operatorGraph = (OperatorGraph)cloner.Clone(operatorGraph); 67 return base.Clone(cloner); 65 68 } 66 69 67 /// <summary> 68 /// Sets the description of the current instance. 69 /// </summary> 70 /// <remarks>Calls <see cref="OnDescriptionChanged"/>.</remarks> 71 /// <exception cref="NullReferenceException">Thrown when <paramref name="description"/> is <c>null</c>.</exception> 72 /// <param name="description">The description to set.</param> 73 public void SetDescription(string description) { 74 if (description == null) 75 throw new NullReferenceException("description must not be null"); 76 77 if (description != myDescription) { 78 myDescription = description; 79 OnDescriptionChanged(); 80 } 81 } 82 83 /// <summary> 84 /// Clones the current instance (deep clone). 85 /// </summary> 86 /// <remarks>Calls <see cref="OperatorBase.Clone 87 /// (System.Collections.Generic.IDictionary<System.Guid, object>)"/> 88 /// of base class <see cref="DelegatingOperator"/>.<br/> 89 /// Deep clone through <see cref="cloner.Clone"/> method of helper class 90 /// <see cref="Auxiliary"/>.</remarks> 91 /// <param name="clonedObjects">Dictionary of all already cloned objects. (Needed to avoid cycles.)</param> 92 /// <returns>The cloned object as <see cref="CombinedOperator"/>.</returns> 93 public override IItem Clone(ICloner cloner) { 94 CombinedOperator clone = (CombinedOperator)base.Clone(cloner); 95 clone.myDescription = Description; 96 clone.myOperatorGraph = (IOperatorGraph)cloner.Clone(OperatorGraph); 97 return clone; 98 } 99 100 /// <summary> 101 /// Adds all sub operators to the specified <paramref name="scope"/>. 102 /// </summary> 103 /// <param name="scope">The scope where to inject the sub operators.</param> 104 /// <returns><c>null</c> if the initial operator is <c>nulll</c>, else a new 105 /// <see cref="AtomicOperation"/> with the initial operator and the given <paramref name="scope"/>.</returns> 106 public override IOperation Apply(IScope scope) { 107 if (OperatorGraph.InitialOperator != null) { 108 for (int i = 0; i < SubOperators.Count; i++) { 109 if (scope.GetVariable(SubOperators[i].Name) != null) 110 scope.RemoveVariable(SubOperators[i].Name); 111 scope.AddVariable(new Variable(SubOperators[i].Name, SubOperators[i])); 112 } 113 return new AtomicOperation(OperatorGraph.InitialOperator, scope); 114 } else { 115 return null; 116 } 117 } 118 119 /// <summary> 120 /// Occurs when the description of the current instance has been changed. 121 /// </summary> 122 public event EventHandler DescriptionChanged; 123 /// <summary> 124 /// Fires a new <c>DescriptionChanged</c> event. 125 /// </summary> 126 protected virtual void OnDescriptionChanged() { 127 if (DescriptionChanged != null) 128 DescriptionChanged(this, new EventArgs()); 70 public override ExecutionContextCollection Apply(ExecutionContext context) { 71 ExecutionContextCollection next = base.Apply(context); 72 if (operatorGraph.InitialOperator != null) 73 next.Insert(0, new ExecutionContext(context, operatorGraph.InitialOperator, context.Scope)); 74 return next; 129 75 } 130 76 } -
trunk/sources/HeuristicLab.Operators/3.3/Counter.cs
r1530 r2684 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.Data; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 28 29 namespace HeuristicLab.Operators { 29 30 /// <summary> 30 /// Class to increment an int variable by 1.31 /// Operator which increments an integer variable. 31 32 /// </summary> 32 public class Counter : OperatorBase { 33 /// <summary> 34 /// Gets the description of the current instance. 35 /// </summary> 36 public override string Description { 37 get { return @"TODO\r\nOperator description still missing ..."; } 33 [Item("Counter", "An operator which increments an integer variable.")] 34 [EmptyStorableClass] 35 [Creatable("Test")] 36 public sealed class Counter : StandardOperator { 37 public ItemParameter<IntData> Value { 38 get { return (ItemParameter<IntData>)Parameters["Value"]; } 39 } 40 public ItemParameter<IntData> Increment { 41 get { return (ItemParameter<IntData>)Parameters["Increment"]; } 38 42 } 39 43 40 /// <summary>41 /// Initializes a new instance of <see cref="Counter"/> with one variable info (<c>Value</c>).42 /// </summary>43 44 public Counter() 44 45 : base() { 45 AddVariableInfo(new VariableInfo("Value", "Counter value", typeof(IntData), VariableKind.In | VariableKind.Out)); 46 Parameters.Add(new ItemParameter<IntData>("Value", "The value which should be incremented.")); 47 Parameters.Add(new ItemParameter<IntData>("Increment", "The increment which is added to the value.", new IntData(1))); 46 48 } 47 49 48 /// <summary> 49 /// Increments an int value of the specified <paramref name="scope"/> by one. 50 /// </summary> 51 /// <param name="scope">The scope whose variable should be incremented.</param> 52 /// <returns><c>null</c>.</returns> 53 public override IOperation Apply(IScope scope) { 54 IntData value = GetVariableValue<IntData>("Value", scope, true); 55 value.Data++; 56 return null; 50 public override ExecutionContextCollection Apply(ExecutionContext context) { 51 IntData value = Value.GetValue(context); 52 IntData increment = Increment.GetValue(context); 53 value.Value += increment.Value; 54 return base.Apply(context); 57 55 } 58 56 } -
trunk/sources/HeuristicLab.Operators/3.3/EmptyOperator.cs
r2664 r2684 31 31 /// An operator which represents an empty statement. 32 32 /// </summary> 33 [Item("Empty 33 [Item("EmptyOperator", "An operator which represents an empty statement.")] 34 34 [Creatable("Test")] 35 35 [EmptyStorableClass] -
trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj
r2664 r2684 85 85 </ItemGroup> 86 86 <ItemGroup> 87 <Compile Include="CombinedOperator.cs" /> 88 <Compile Include="Counter.cs" /> 87 89 <Compile Include="EmptyOperator.cs"> 88 90 <SubType>Code</SubType> … … 91 93 <Compile Include="Operator.cs" /> 92 94 <Compile Include="Properties\AssemblyInfo.cs" /> 95 <Compile Include="SequentialProcessor.cs" /> 93 96 <Compile Include="StandardOperator.cs" /> 94 97 </ItemGroup> -
trunk/sources/HeuristicLab.Operators/3.3/Operator.cs
r2664 r2684 37 37 public override Image ItemImage { 38 38 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Method; } 39 } 40 public override bool CanChangeDescription { 41 get { return false; } 39 42 } 40 43 -
trunk/sources/HeuristicLab.Operators/3.3/SequentialProcessor.cs
r1530 r2684 23 23 using System.Collections.Generic; 24 24 using System.Text; 25 using System.Xml; 26 using HeuristicLab.Collections; 25 27 using HeuristicLab.Core; 26 28 using HeuristicLab.Data; 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 30 28 31 namespace HeuristicLab.Operators { 29 32 /// <summary> 30 /// Performs <c>n</c> operators on the given scopesequentially.33 /// Operator which executes multiple operators sequentially. 31 34 /// </summary> 32 public class SequentialProcessor : OperatorBase { 33 /// <inheritdoc select="summary"/> 34 public override string Description { 35 get { return @"TODO\r\nOperator description still missing ..."; } 35 [Item("SequentialProcessor", "An operator which executes multiple operators sequentially.")] 36 [Creatable("Test")] 37 [EmptyStorableClass] 38 public sealed class SequentialProcessor : Operator, IOperator { 39 public new ParameterCollection Parameters { 40 get { 41 return base.Parameters; 42 } 43 } 44 IObservableKeyedCollection<string, IParameter> IOperator.Parameters { 45 get { return Parameters; } 36 46 } 37 47 38 /// <summary> 39 /// Applies <c>n</c> operators on the given <paramref name="scope"/>. 40 /// </summary> 41 /// <param name="scope">The scope to apply the operators on.</param> 42 /// <returns>A new <see cref="CompositeOperation"/> with the <c>n</c> operators applied 43 /// to the given <paramref name="scope"/>.</returns> 44 public override IOperation Apply(IScope scope) { 45 CompositeOperation next = new CompositeOperation(); 46 for (int i = 0; i < SubOperators.Count; i++) 47 next.AddOperation(new AtomicOperation(SubOperators[i], scope)); 48 public SequentialProcessor() 49 : base() { 50 } 51 52 public override ExecutionContextCollection Apply(ExecutionContext context) { 53 ExecutionContextCollection next = new ExecutionContextCollection(); 54 foreach (IParameter param in Parameters) { 55 IOperatorParameter opParam = param as IOperatorParameter; 56 if (opParam != null) { 57 IOperator op = (IOperator)opParam.GetValue(context); 58 if (op != null) next.Add(new ExecutionContext(context.Parent, op, context.Scope)); 59 } 60 } 48 61 return next; 49 62 } -
trunk/sources/HeuristicLab.Operators/3.3/StandardOperator.cs
r2664 r2684 31 31 /// A base class for operators which have only one successor. 32 32 /// </summary> 33 [Item("Standard 33 [Item("StandardOperator", "A base class for operators which have only one successor.")] 34 34 [Creatable("Test")] 35 35 [EmptyStorableClass] … … 45 45 46 46 public override ExecutionContextCollection Apply(ExecutionContext context) { 47 IOperator successor = Successor.GetValue(context );47 IOperator successor = Successor.GetValue(context, false); 48 48 if (successor != null) 49 49 return new ExecutionContextCollection(new ExecutionContext(context.Parent, successor, context.Scope));
Note: See TracChangeset
for help on using the changeset viewer.