1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2008 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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Text;
|
---|
25 | using HeuristicLab.Common;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.Core {
|
---|
28 | /// <summary>
|
---|
29 | /// Interface to represent an operator (e.g. GreaterThanComparator,...),
|
---|
30 | /// a basic instruction of an algorithm.
|
---|
31 | /// </summary>
|
---|
32 | public interface IOperator : IItem {
|
---|
33 | /// <summary>
|
---|
34 | /// Gets or sets the name of the current instance.
|
---|
35 | /// </summary>
|
---|
36 | string Name { get; set; }
|
---|
37 | /// <summary>
|
---|
38 | /// Gets or sets the description of the current instance.
|
---|
39 | /// </summary>
|
---|
40 | string Description { get; }
|
---|
41 |
|
---|
42 | /// <summary>
|
---|
43 | /// Gets information whether the current operator has been canceled.
|
---|
44 | /// </summary>
|
---|
45 | bool Canceled { get; }
|
---|
46 | /// <summary>
|
---|
47 | /// Gets or sets a boolean value whether the engine should stop here during the run.
|
---|
48 | /// </summary>
|
---|
49 | bool Breakpoint { get; set; }
|
---|
50 |
|
---|
51 | /// <summary>
|
---|
52 | /// Gets a list of all sub operators.
|
---|
53 | /// </summary>
|
---|
54 | IList<IOperator> SubOperators { get; }
|
---|
55 | /// <summary>
|
---|
56 | /// Gets a collection of all variable (parameter) infos.
|
---|
57 | /// </summary>
|
---|
58 | ICollection<IVariableInfo> VariableInfos { get; }
|
---|
59 | /// <summary>
|
---|
60 | /// Gets a collection of all variables of the current operator.
|
---|
61 | /// </summary>
|
---|
62 | ICollection<IVariable> Variables { get; }
|
---|
63 |
|
---|
64 | /// <summary>
|
---|
65 | /// Adds the given sub operator to the current instance.
|
---|
66 | /// </summary>
|
---|
67 | /// <param name="op">The operator to add.</param>
|
---|
68 | void AddSubOperator(IOperator op);
|
---|
69 | /// <summary>
|
---|
70 | /// Adds the given sub operator at a the specified <paramref name="index"/>.
|
---|
71 | /// </summary>
|
---|
72 | /// <param name="op">The operator to add.</param>
|
---|
73 | /// <param name="index">The position where to add the operator.</param>
|
---|
74 | void AddSubOperator(IOperator op, int index);
|
---|
75 | /// <summary>
|
---|
76 | /// Removes a sub operator at the specified <paramref name="index"/>.
|
---|
77 | /// </summary>
|
---|
78 | /// <param name="index">The position where to delete the operator.</param>
|
---|
79 | void RemoveSubOperator(int index);
|
---|
80 |
|
---|
81 | /// <summary>
|
---|
82 | /// Gets the variable info with the given <paramref name="formalName"/>.
|
---|
83 | /// </summary>
|
---|
84 | /// <param name="formalName">The formal name of the variable info.</param>
|
---|
85 | /// <returns>The variable info with the specified formal name.</returns>
|
---|
86 | IVariableInfo GetVariableInfo(string formalName);
|
---|
87 | /// <summary>
|
---|
88 | /// Adds the specified variable info to the current instance.
|
---|
89 | /// </summary>
|
---|
90 | /// <param name="variableInfo">The variable info to add.</param>
|
---|
91 | void AddVariableInfo(IVariableInfo variableInfo);
|
---|
92 | /// <summary>
|
---|
93 | /// Removes the variable info with the given formal name.
|
---|
94 | /// </summary>
|
---|
95 | /// <param name="formalName">The formal name of the variable info to remove.</param>
|
---|
96 | void RemoveVariableInfo(string formalName);
|
---|
97 |
|
---|
98 | /// <summary>
|
---|
99 | /// Gets a variable with the given <paramref name="name"/>.
|
---|
100 | /// </summary>
|
---|
101 | /// <param name="name">The name of the variable.</param>
|
---|
102 | /// <returns>The variable with the specified name.</returns>
|
---|
103 | IVariable GetVariable(string name);
|
---|
104 | /// <summary>
|
---|
105 | /// Adds the specified <paramref name="variable"/> to the current instance.
|
---|
106 | /// </summary>
|
---|
107 | /// <param name="variable">The variable to add.</param>
|
---|
108 | void AddVariable(IVariable variable);
|
---|
109 | /// <summary>
|
---|
110 | /// Deletes the variable with the specified <paramref name="name"/>.
|
---|
111 | /// </summary>
|
---|
112 | /// <param name="name">The name of the variable to delete.</param>
|
---|
113 | void RemoveVariable(string name);
|
---|
114 |
|
---|
115 | /// <inheritdoc cref="GetVariableValue(string, HeuristicLab.Core.IScope, bool)"/>
|
---|
116 | /// <typeparam name="T">The type of the value that is searched.</typeparam>
|
---|
117 | T GetVariableValue<T>(string formalName, IScope scope, bool recursiveLookup) where T : class, IItem;
|
---|
118 | /// <inheritdoc cref="GetVariableValue(string, HeuristicLab.Core.IScope, bool, bool)"/>
|
---|
119 | /// <typeparam name="T">The type of the value that is searched.</typeparam>
|
---|
120 | T GetVariableValue<T>(string formalName, IScope scope, bool recursiveLookup, bool throwOnError) where T : class, IItem;
|
---|
121 | /// <inheritdoc cref="GetVariableValue(System.String, IScope, bool, bool)"
|
---|
122 | /// select="summary"/>
|
---|
123 | /// <param name="formalName">The formal name of the variable info whose variable value is searched.</param>
|
---|
124 | /// <param name="scope">The scope where to look for the variable.</param>
|
---|
125 | /// <param name="recursiveLookup">Boolean value, whether also the parent scopes shall be searched if
|
---|
126 | /// the variable is not found in the specified <paramref name="scope"/>.</param>
|
---|
127 | /// <returns>The value of the searched variable or null if it is not found.</returns>
|
---|
128 | IItem GetVariableValue(string formalName, IScope scope, bool recursiveLookup);
|
---|
129 | /// <summary>
|
---|
130 | /// Gets the value of the variable in the specified <paramref name="scope"/>
|
---|
131 | /// whose variable(parameter) info has the specified <paramref name="formalName"/>.
|
---|
132 | /// </summary>
|
---|
133 | /// <param name="formalName">The formal name of the variable info whose variable value is searched.</param>
|
---|
134 | /// <param name="scope">The scope where to look for the variable.</param>
|
---|
135 | /// <param name="recursiveLookup">Boolean value, whether also the parent scopes shall be searched if
|
---|
136 | /// the variable is not found in the specified <paramref name="scope"/>.</param>
|
---|
137 | /// <param name="throwOnError">Boolean value, whether an exception shall be thrown, if the variable
|
---|
138 | /// cannot be found or just <c>null</c> shall be returned.</param>
|
---|
139 | /// <returns>The value of the searched variable (or null if the variable is not
|
---|
140 | /// found and <paramref name="throwOnError"/> is set to false).</returns>
|
---|
141 | IItem GetVariableValue(string formalName, IScope scope, bool recursiveLookup, bool throwOnError);
|
---|
142 |
|
---|
143 | /// <summary>
|
---|
144 | /// Executes the current instance on the specified <paramref name="scope"/>.
|
---|
145 | /// </summary>
|
---|
146 | /// <param name="scope">The scope where to execute the current instance.</param>
|
---|
147 | /// <returns>The next operation.</returns>
|
---|
148 | IOperation Execute(IScope scope);
|
---|
149 | /// <summary>
|
---|
150 | /// Aborts the current operator.
|
---|
151 | /// </summary>
|
---|
152 | void Abort();
|
---|
153 |
|
---|
154 | /// <summary>
|
---|
155 | /// Occurs when the name of the operator was changed.
|
---|
156 | /// </summary>
|
---|
157 | event EventHandler NameChanged;
|
---|
158 | /// <summary>
|
---|
159 | /// Occurs when the breakpoint flag of the current instance was changed.
|
---|
160 | /// </summary>
|
---|
161 | event EventHandler BreakpointChanged;
|
---|
162 | /// <summary>
|
---|
163 | /// Occurs when a sub operator has been added.
|
---|
164 | /// </summary>
|
---|
165 | event EventHandler<EventArgs<IOperator, int>> SubOperatorAdded;
|
---|
166 | /// <summary>
|
---|
167 | /// Occurs when a sub operator has been deleted.
|
---|
168 | /// </summary>
|
---|
169 | event EventHandler<EventArgs<IOperator, int>> SubOperatorRemoved;
|
---|
170 | /// <summary>
|
---|
171 | /// Occurs when a variable info has been added.
|
---|
172 | /// </summary>
|
---|
173 | event EventHandler<EventArgs<IVariableInfo>> VariableInfoAdded;
|
---|
174 | /// <summary>
|
---|
175 | /// Occurs when a variable info has been deleted.
|
---|
176 | /// </summary>
|
---|
177 | event EventHandler<EventArgs<IVariableInfo>> VariableInfoRemoved;
|
---|
178 | /// <summary>
|
---|
179 | /// Occurs when a variable has been added.
|
---|
180 | /// </summary>
|
---|
181 | event EventHandler<EventArgs<IVariable>> VariableAdded;
|
---|
182 | /// <summary>
|
---|
183 | /// Occurs when a variable has been deleted.
|
---|
184 | /// </summary>
|
---|
185 | event EventHandler<EventArgs<IVariable>> VariableRemoved;
|
---|
186 | /// <summary>
|
---|
187 | /// Occurs when the current instance is executed.
|
---|
188 | /// </summary>
|
---|
189 | event EventHandler Executed;
|
---|
190 | }
|
---|
191 | }
|
---|