Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/Interfaces/IOperator.cs @ 2033

Last change on this file since 2033 was 2033, checked in by swagner, 15 years ago

Refactoring of the operator architecture (#95)

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