Changeset 2046 for branches/Operator Architecture Refactoring
- Timestamp:
- 06/16/09 03:36:48 (15 years ago)
- Location:
- branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3
- Files:
-
- 7 added
- 15 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/CallGraph.cs
r2033 r2046 23 23 using System.Collections.Generic; 24 24 using System.Text; 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 26 26 27 namespace HeuristicLab.Core { 27 public class CallGraph : ItemBase, ICallGraph { 28 public class CallGraph : CallNodeBase, ICallGraph { 29 [Storable] 30 private Dictionary<ICallNode, List<ICallNode>> transitions; 31 32 [Storable] 33 private List<ICallNode> myCallNodes; 34 public ICollection<ICallNode> CallNodes { 35 get { return myCallNodes.AsReadOnly(); } 36 } 37 [Storable] 38 private ICallNode myInitialCallNode; 39 public ICallNode InitialCallNode { 40 get { return myInitialCallNode; } 41 internal set { 42 if (myInitialCallNode != value) { 43 myInitialCallNode = value; 44 OnInitialCallNodeChanged(); 45 } 46 } 47 } 48 49 public CallGraph() 50 : base() { 51 transitions = new Dictionary<ICallNode, List<ICallNode>>(); 52 myCallNodes = new List<ICallNode>(); 53 myInitialCallNode = null; 54 } 55 public CallGraph(CallGraph parentGraph) 56 : base(parentGraph) { 57 transitions = new Dictionary<ICallNode, List<ICallNode>>(); 58 myCallNodes = new List<ICallNode>(); 59 myInitialCallNode = null; 60 } 61 62 public override ICloneable Clone(ICloner cloner) { 63 CallGraph clone = (CallGraph)base.Clone(cloner); 64 foreach (ICallNode callNode in CallNodes) 65 clone.AddCallNode((ICallNode)cloner.Clone(callNode)); 66 foreach (ICallNode source in CallNodes) 67 foreach (ICallNode target in transitions[source]) 68 clone.AddTransition((ICallNode)cloner.Clone(source), (ICallNode)cloner.Clone(target)); 69 clone.InitialCallNode = (ICallNode)cloner.Clone(InitialCallNode); 70 71 return base.Clone(cloner); 72 } 73 74 public override IView CreateView() { 75 return new CallGraphView(this); 76 } 77 78 internal void AddCallNode(ICallNode callNode) { 79 myCallNodes.Add(callNode); 80 transitions.Add(callNode, new List<ICallNode>()); 81 OnCallNodeAdded(callNode); 82 } 83 public void RemoveCallNode(ICallNode callNode) { 84 if (myCallNodes.Remove(callNode)) { 85 foreach (ICallNode node in CallNodes) { // remove incoming transitions 86 while (transitions[node].Contains(callNode)) 87 RemoveTransition(node, callNode); 88 } 89 while (transitions[callNode].Count > 0) // remove outgoing transitions 90 RemoveTransition(callNode, transitions[callNode][0]); 91 transitions.Remove(callNode); 92 OnCallNodeRemoved(callNode); 93 } 94 } 95 96 public void AddTransition(ICallNode source, ICallNode target) { 97 transitions[source].Add(target); 98 OnTransitionAdded(source, target); 99 } 100 public void RemoveTransition(ICallNode source, ICallNode target) { 101 if (transitions[source].Remove(target)) 102 OnTransitionRemoved(source, target); 103 } 104 105 internal IList<ICallNode> GetSuccessorNodes(ICallNode callNode) { 106 return transitions[callNode].AsReadOnly(); 107 } 108 109 public event EventHandler<EventArgs<ICallNode>> CallNodeAdded; 110 protected virtual void OnCallNodeAdded(ICallNode callNode) { 111 if (CallNodeAdded != null) 112 CallNodeAdded(this, new EventArgs<ICallNode>(callNode)); 113 } 114 public event EventHandler<EventArgs<ICallNode>> CallNodeRemoved; 115 protected virtual void OnCallNodeRemoved(ICallNode callNode) { 116 if (CallNodeRemoved != null) 117 CallNodeRemoved(this, new EventArgs<ICallNode>(callNode)); 118 } 119 public event EventHandler InitialCallNodeChanged; 120 protected virtual void OnInitialCallNodeChanged() { 121 if (InitialCallNodeChanged != null) 122 InitialCallNodeChanged(this, new EventArgs()); 123 } 124 public event EventHandler<EventArgs<ICallNode, ICallNode>> TransistionAdded; 125 protected virtual void OnTransitionAdded(ICallNode source, ICallNode target) { 126 if (TransistionAdded != null) 127 TransistionAdded(this, new EventArgs<ICallNode,ICallNode>(source, target)); 128 } 129 public event EventHandler<EventArgs<ICallNode, ICallNode>> TransistionRemoved; 130 protected virtual void OnTransitionRemoved(ICallNode source, ICallNode target) { 131 if (TransistionRemoved != null) 132 TransistionRemoved(this, new EventArgs<ICallNode, ICallNode>(source, target)); 133 } 28 134 } 29 135 } -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Cloner.cs
r2042 r2046 46 46 47 47 public ICloneable Clone(ICloneable obj) { 48 if (obj == null) return null; 48 49 ICloneable clone; 49 50 if (mapping.TryGetValue(obj, out clone)) -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/EngineBase.cs
r2042 r2046 237 237 /// Occurs when an operation is executed. 238 238 /// </summary> 239 public event EventHandler< OperationEventArgs> OperationExecuted;239 public event EventHandler<EventArgs<IOperation>> OperationExecuted; 240 240 /// <summary> 241 241 /// Fires a new <c>OperationExecuted</c> event. … … 244 244 protected virtual void OnOperationExecuted(IOperation operation) { 245 245 if (OperationExecuted != null) 246 OperationExecuted(this, new OperationEventArgs(operation));246 OperationExecuted(this, new EventArgs<IOperation>(operation)); 247 247 } 248 248 /// <summary> 249 249 /// Occurs when an exception occured during the execution. 250 250 /// </summary> 251 public event EventHandler<E xceptionEventArgs> ExceptionOccurred;251 public event EventHandler<EventArgs<Exception>> ExceptionOccurred; 252 252 /// <summary> 253 253 /// Aborts the execution and fires a new <c>ExceptionOccurred</c> event. … … 257 257 Abort(); 258 258 if (ExceptionOccurred != null) 259 ExceptionOccurred(this, new E xceptionEventArgs(exception));259 ExceptionOccurred(this, new EventArgs<Exception>(exception)); 260 260 } 261 261 /// <summary> -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj
r2042 r2046 122 122 <DependentUpon>ChooseTypeDialog.cs</DependentUpon> 123 123 </Compile> 124 <Compile Include="AliasEventArgs.cs" />125 124 <Compile Include="CallGraph.cs" /> 126 <Compile Include=" CallNode.cs" />125 <Compile Include="OperatorCallNode.cs" /> 127 126 <Compile Include="Cloner.cs" /> 128 <Compile Include="ParameterEventArgs.cs" /> 127 <Compile Include="CallGraphView.cs"> 128 <SubType>UserControl</SubType> 129 </Compile> 130 <Compile Include="CallGraphView.Designer.cs"> 131 <DependentUpon>CallGraphView.cs</DependentUpon> 132 </Compile> 133 <Compile Include="CancelEventArgs.cs" /> 134 <Compile Include="CallNodeBase.cs" /> 135 <Compile Include="EventArgs.cs" /> 129 136 <Compile Include="Interfaces\ICloner.cs" /> 130 137 <Compile Include="Interfaces\ICloneable.cs" /> … … 140 147 <Compile Include="Interfaces\ICallNode.cs" /> 141 148 <Compile Include="Interfaces\ICallGraph.cs" /> 142 <Compile Include="KeyValueEventArgs.cs" />143 149 <Compile Include="OperatorBaseDescriptionView.cs"> 144 150 <SubType>UserControl</SubType> … … 150 156 <Compile Include="Interfaces\IOperatorLibrary.cs" /> 151 157 <Compile Include="Interfaces\IVisualizationItem.cs" /> 152 <Compile Include="NameChangingEventArgs.cs" />153 <Compile Include="OperationEventArgs.cs" />154 158 <Compile Include="OperatorBaseVariablesView.cs"> 155 159 <SubType>UserControl</SubType> … … 164 168 <DependentUpon>OperatorBaseVariableInfosView.cs</DependentUpon> 165 169 </Compile> 166 <Compile Include="ExceptionEventArgs.cs" />167 170 <Compile Include="Interfaces\IItem.cs" /> 168 171 <Compile Include="ItemBase.cs" /> … … 173 176 <DependentUpon>ItemBaseView.cs</DependentUpon> 174 177 </Compile> 175 <Compile Include="ItemEventArgs.cs" />176 <Compile Include="ItemIndexEventArgs.cs" />177 178 <Compile Include="OperatorLibrary.cs" /> 178 179 <Compile Include="OperatorLibraryEditor.cs"> … … 187 188 <DependentUpon>Resources.resx</DependentUpon> 188 189 </Compile> 189 <Compile Include="ScopeIndexEventArgs.cs" />190 190 <Compile Include="EngineBaseEditor.cs"> 191 191 <SubType>UserControl</SubType> … … 194 194 <DependentUpon>EngineBaseEditor.cs</DependentUpon> 195 195 </Compile> 196 <Compile Include="VariableInfoEventArgs.cs" />197 <Compile Include="VariableEventArgs.cs" />198 196 <Compile Include="Interfaces\IOperatorGroup.cs" /> 199 197 <Compile Include="Interfaces\IOperatorGraph.cs" /> … … 201 199 <Compile Include="Interfaces\IVariable.cs" /> 202 200 <Compile Include="Interfaces\IVariableInfo.cs" /> 203 <Compile Include="OperatorEventArgs.cs" />204 201 <Compile Include="OperatorGroup.cs"> 205 202 <SubType>Code</SubType> 206 203 </Compile> 207 <Compile Include="OperatorIndexEventArgs.cs" />208 <Compile Include="ScopeEventArgs.cs" />209 204 <Compile Include="OperatorBaseView.cs"> 210 205 <SubType>UserControl</SubType> … … 300 295 <SubType>Designer</SubType> 301 296 </EmbeddedResource> 297 <EmbeddedResource Include="CallGraphView.resx"> 298 <DependentUpon>CallGraphView.cs</DependentUpon> 299 <SubType>Designer</SubType> 300 </EmbeddedResource> 302 301 <EmbeddedResource Include="ParameterView.resx"> 303 302 <DependentUpon>ParameterView.cs</DependentUpon> -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/ICallGraph.cs
r2033 r2046 25 25 26 26 namespace HeuristicLab.Core { 27 public interface ICallGraph : IItem { 27 public interface ICallGraph : ICallNode { 28 ICollection<ICallNode> CallNodes { get; } 29 ICallNode InitialCallNode { get; } 30 31 void RemoveCallNode(ICallNode callNode); 32 33 event EventHandler<EventArgs<ICallNode>> CallNodeAdded; 34 event EventHandler<EventArgs<ICallNode>> CallNodeRemoved; 35 event EventHandler InitialCallNodeChanged; 36 28 37 } 29 38 } -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/ICallNode.cs
r2033 r2046 26 26 namespace HeuristicLab.Core { 27 27 public interface ICallNode : IItem { 28 IEnumerable<KeyValuePair<string, string>> NameMappings { get; } 29 IList<ICallNode> SuccessorNodes { get; } 30 bool InitialCallNode { get; set; } 31 32 void AddNameMapping(string name, string alias); 33 void RemoveNameMapping(string name); 34 string MapName(string name); 35 36 event EventHandler<EventArgs<string, string>> NameMappingAdded; 37 event EventHandler<EventArgs<string, string>> NameMappingRemoved; 28 38 } 29 39 } -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IEngine.cs
r776 r2046 87 87 /// Occurs when an operation is executed. 88 88 /// </summary> 89 event EventHandler< OperationEventArgs> OperationExecuted;89 event EventHandler<EventArgs<IOperation>> OperationExecuted; 90 90 /// <summary> 91 91 /// Occurs when an exception was thrown. 92 92 /// </summary> 93 event EventHandler<E xceptionEventArgs> ExceptionOccurred;93 event EventHandler<EventArgs<Exception>> ExceptionOccurred; 94 94 /// <summary> 95 95 /// Occurs when the execution time was changed. -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IOperator.cs
r2042 r2046 92 92 /// Occurs when a variable info has been added. 93 93 /// </summary> 94 event EventHandler< ParameterEventArgs> ParameterAdded;94 event EventHandler<EventArgs<IParameter>> ParameterAdded; 95 95 /// <summary> 96 96 /// Occurs when a variable info has been deleted. 97 97 /// </summary> 98 event EventHandler< ParameterEventArgs> ParameterRemoved;98 event EventHandler<EventArgs<IParameter>> ParameterRemoved; 99 99 /// <summary> 100 100 /// Occurs when the current instance is executed. -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IOperatorGraph.cs
r2033 r2046 57 57 /// Occurs when a new operator has been added to the current instance. 58 58 /// </summary> 59 event EventHandler< OperatorEventArgs> OperatorAdded;59 event EventHandler<EventArgs<IOperator>> OperatorAdded; 60 60 /// <summary> 61 61 /// Occurs when an operator has been deleted from the current instance. 62 62 /// </summary> 63 event EventHandler< OperatorEventArgs> OperatorRemoved;63 event EventHandler<EventArgs<IOperator>> OperatorRemoved; 64 64 /// <summary> 65 65 /// Occurs when the initial operator (the starting one) has been changed. -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IParameter.cs
r2033 r2046 30 30 Type DataType { get; } 31 31 ParamterType Type { get; } 32 IItem Value { get; set; } 32 33 } 33 34 } -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IScope.cs
r2042 r2046 121 121 /// Occurs when a variable has been added to the current instance. 122 122 /// </summary> 123 event EventHandler< VariableEventArgs> VariableAdded;123 event EventHandler<EventArgs<IVariable>> VariableAdded; 124 124 /// <summary> 125 125 /// Occurs when a variable has been deleted from the current instance. 126 126 /// </summary> 127 event EventHandler< VariableEventArgs> VariableRemoved;127 event EventHandler<EventArgs<IVariable>> VariableRemoved; 128 128 /// <summary> 129 129 /// Occurs when a sub scope has been added to the current instance. 130 130 /// </summary> 131 event EventHandler< ScopeIndexEventArgs> SubScopeAdded;131 event EventHandler<EventArgs<IScope, int>> SubScopeAdded; 132 132 /// <summary> 133 133 /// Occurs when a sub scope has been deleted from the current instance. 134 134 /// </summary> 135 event EventHandler< ScopeIndexEventArgs> SubScopeRemoved;135 event EventHandler<EventArgs<IScope, int>> SubScopeRemoved; 136 136 /// <summary> 137 137 /// Occurs when the sub scopes have been reordered. -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IVariable.cs
r776 r2046 49 49 /// Occurs when the name of the variable is currently changing. 50 50 /// </summary> 51 event EventHandler< NameChangingEventArgs> NameChanging;51 event EventHandler<CancelEventArgs<string>> NameChanging; 52 52 /// <summary> 53 53 /// Occurs when the name of the current instance has been changed. -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/OperatorBase.cs
r2042 r2046 186 186 } 187 187 /// <inheritdoc/> 188 public event EventHandler< ParameterEventArgs> ParameterAdded;188 public event EventHandler<EventArgs<IParameter>> ParameterAdded; 189 189 /// <summary> 190 190 /// Fires a new <c>VariableInfoAdded</c> event. … … 193 193 protected virtual void OnParameterAdded(IParameter parameter) { 194 194 if (ParameterAdded != null) 195 ParameterAdded(this, new ParameterEventArgs(parameter));196 } 197 /// <inheritdoc/> 198 public event EventHandler< ParameterEventArgs> ParameterRemoved;195 ParameterAdded(this, new EventArgs<IParameter>(parameter)); 196 } 197 /// <inheritdoc/> 198 public event EventHandler<EventArgs<IParameter>> ParameterRemoved; 199 199 /// <summary> 200 200 /// Fires a new <c>VariableInfoRemoved</c> event. … … 203 203 protected virtual void OnParameterRemoved(IParameter parameter) { 204 204 if (ParameterRemoved != null) 205 ParameterRemoved(this, new ParameterEventArgs(parameter));205 ParameterRemoved(this, new EventArgs<IParameter>(parameter)); 206 206 } 207 207 /// <inheritdoc/> -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/OperatorGraph.cs
r2042 r2046 127 127 128 128 /// <inheritdoc/> 129 public event EventHandler< OperatorEventArgs> OperatorAdded;129 public event EventHandler<EventArgs<IOperator>> OperatorAdded; 130 130 /// <summary> 131 131 /// Fires a new <c>OperatorAdded</c> event. … … 134 134 protected virtual void OnOperatorAdded(IOperator op) { 135 135 if (OperatorAdded != null) 136 OperatorAdded(this, new OperatorEventArgs(op));136 OperatorAdded(this, new EventArgs<IOperator>(op)); 137 137 } 138 138 /// <inheritdoc/> 139 public event EventHandler< OperatorEventArgs> OperatorRemoved;139 public event EventHandler<EventArgs<IOperator>> OperatorRemoved; 140 140 /// <summary> 141 141 /// Fires a new <c>OperatorRemoved</c> event. … … 144 144 protected virtual void OnOperatorRemoved(IOperator op) { 145 145 if (OperatorRemoved != null) 146 OperatorRemoved(this, new OperatorEventArgs(op));146 OperatorRemoved(this, new EventArgs<IOperator>(op)); 147 147 } 148 148 /// <inheritdoc/> -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Scope.cs
r2042 r2046 238 238 239 239 /// <inheritdoc /> 240 public event EventHandler< VariableEventArgs> VariableAdded;240 public event EventHandler<EventArgs<IVariable>> VariableAdded; 241 241 /// <summary> 242 242 /// Fires a new <c>VariableAdded</c> event. … … 245 245 protected virtual void OnVariableAdded(IVariable variable) { 246 246 if (VariableAdded != null) 247 VariableAdded(this, new VariableEventArgs(variable));247 VariableAdded(this, new EventArgs<IVariable>(variable)); 248 248 } 249 249 /// <inheritdoc /> 250 public event EventHandler< VariableEventArgs> VariableRemoved;250 public event EventHandler<EventArgs<IVariable>> VariableRemoved; 251 251 /// <summary> 252 252 /// Fires a new <c>VariableRemoved</c>. … … 255 255 protected virtual void OnVariableRemoved(IVariable variable) { 256 256 if (VariableRemoved != null) 257 VariableRemoved(this, new VariableEventArgs(variable));258 } 259 /// <inheritdoc/> 260 public event EventHandler< ScopeIndexEventArgs> SubScopeAdded;257 VariableRemoved(this, new EventArgs<IVariable>(variable)); 258 } 259 /// <inheritdoc/> 260 public event EventHandler<EventArgs<IScope, int>> SubScopeAdded; 261 261 /// <summary> 262 262 /// Fires a new <c>SubScopeAdded</c> event. … … 266 266 protected virtual void OnSubScopeAdded(IScope scope, int index) { 267 267 if (SubScopeAdded != null) 268 SubScopeAdded(this, new ScopeIndexEventArgs(scope, index));269 } 270 /// <inheritdoc/> 271 public event EventHandler< ScopeIndexEventArgs> SubScopeRemoved;268 SubScopeAdded(this, new EventArgs<IScope,int>(scope, index)); 269 } 270 /// <inheritdoc/> 271 public event EventHandler<EventArgs<IScope, int>> SubScopeRemoved; 272 272 /// <summary> 273 273 /// Fires a new <c>SubScopeRemoved</c> event. … … 277 277 protected virtual void OnSubScopeRemoved(IScope scope, int index) { 278 278 if (SubScopeRemoved != null) 279 SubScopeRemoved(this, new ScopeIndexEventArgs(scope, index));279 SubScopeRemoved(this, new EventArgs<IScope,int>(scope, index)); 280 280 } 281 281 /// <inheritdoc /> -
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Variable.cs
r2042 r2046 41 41 set { 42 42 if (!myName.Equals(value)) { 43 NameChangingEventArgs e = new NameChangingEventArgs(value); 44 OnNameChanging(e); 45 if (!e.Cancel) { 43 if (! OnNameChanging(value).Cancel) { 46 44 myName = value; 47 45 OnNameChanged(); … … 120 118 121 119 /// <inheritdoc/> 122 public event EventHandler< NameChangingEventArgs> NameChanging;120 public event EventHandler<CancelEventArgs<string>> NameChanging; 123 121 /// <summary> 124 122 /// Fires a new <c>NameChanging</c> event. 125 123 /// </summary> 126 124 /// <param name="e">The event arguments of the changing.</param> 127 protected virtual void OnNameChanging(NameChangingEventArgs e) { 125 protected virtual CancelEventArgs<string> OnNameChanging(string name) { 126 CancelEventArgs<string> eventArgs = new CancelEventArgs<string>(name); 128 127 if (NameChanging != null) 129 NameChanging(this, e); 128 NameChanging(this, eventArgs); 129 return eventArgs; 130 130 } 131 131 /// <inheritdoc/>
Note: See TracChangeset
for help on using the changeset viewer.