#region License Information /* HeuristicLab * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections.Generic; using System.Text; namespace HeuristicLab.Core { /// /// Interface to represent an operator (e.g. GreaterThanComparator,...), /// a basic instruction of an algorithm. /// public interface IOperator : IConstrainedItem { /// /// Gets or sets the name of the current instance. /// string Name { get; set; } /// /// Gets or sets the description of the current instance. /// string Description { get; } /// /// Gets information whether the current operator has been canceled. /// bool Canceled { get; } /// /// Gets or sets a boolean value whether the engine should stop here during the run. /// bool Breakpoint { get; set; } /// /// Gets a list of all sub operators. /// IList SubOperators { get; } /// /// Gets a collection of all variable (parameter) infos. /// ICollection VariableInfos { get; } /// /// Gets a collection of all variables of the current operator. /// ICollection Variables { get; } /// /// Gets information whether abortion of the operator is supported. /// bool SupportsAbort { get; } /// /// Adds the given sub operator to the current instance. /// /// The operator to add. void AddSubOperator(IOperator op); /// /// Adds the given sub operator to the current instance if all constraints can be fulfilled. /// /// The operator to add. /// true if the operator could be added without violating constraints, /// false otherwise. bool TryAddSubOperator(IOperator op); /// /// Adds the given sub operator to the current instance if all constraints can be fulfilled. /// /// The operator to add. /// Output parameter; contains all constraints that could not be /// fulfilled. /// true if the operator could be added without violating constraints, /// false otherwise. bool TryAddSubOperator(IOperator op, out ICollection violatedConstraints); /// /// Adds the given sub operator at a the specified . /// /// The operator to add. /// The position where to add the operator. void AddSubOperator(IOperator op, int index); /// /// Adds the given operator at the specified to the current instance /// if all constraints can be fulfilled. /// /// The operator to add. /// The position where to add the operator. /// true if the operator could be added without violating constraints, /// false otherwise. bool TryAddSubOperator(IOperator op, int index); /// /// Adds the given operator at the specified to the current instance /// if all constraints can be fulfilled. /// /// The operator to add. /// The position where to add the operator. /// Output parameter; contains all constraints that could not be /// fulfilled. /// true if the operator could be added without violating constraints, /// false otherwise. bool TryAddSubOperator(IOperator op, int index, out ICollection violatedConstraints); /// /// Removes a sub operator at the specified . /// /// The position where to delete the operator. void RemoveSubOperator(int index); /// /// Removes a sub operator at the specified if all constraint can be fulfilled. /// /// The position where to delete the operator. /// true if the operator could be deleted without violating constraints, /// false otherwise. bool TryRemoveSubOperator(int index); /// /// Deletes the operator at the specified /// if all constraints can be fulfilled. /// /// The position where to delete the operator. /// Output parameter; contains all constraints that could not be /// fulfilled. /// true if the operator could be deleted without violating constraints, /// false otherwise. bool TryRemoveSubOperator(int index, out ICollection violatedConstraints); /// /// Gets the variable info with the given . /// /// The formal name of the variable info. /// The variable info with the specified formal name. IVariableInfo GetVariableInfo(string formalName); /// /// Adds the specified variable info to the current instance. /// /// The variable info to add. void AddVariableInfo(IVariableInfo variableInfo); /// /// Adds the specified variable info to the current instance, if all constraints can be fulfilled. /// /// The variable info to add. /// true if the variable info could be added without violating constraints, /// false otherwise. bool TryAddVariableInfo(IVariableInfo variableInfo); /// /// Adds the specified variable info to the current instance, if all constraints can be fulfilled. /// /// The variable info to add. /// Output parameter; contains all constraints that could not be /// fulfilled. /// true if the variable info could be added without violating constraints, /// false otherwise. bool TryAddVariableInfo(IVariableInfo variableInfo, out ICollection violatedConstraints); /// /// Removes the variable info with the given formal name. /// /// The formal name of the variable info to remove. void RemoveVariableInfo(string formalName); /// /// Deletes the variable info with the given formal name, /// if all constraints can be fulfilled. /// /// The formal name of the variable info to remove. /// true if the variable info could be deleted without violating constraints, /// false otherwise. bool TryRemoveVariableInfo(string formalName); /// /// Deletes the variable info with the given formal name, /// if all constraints can be fulfilled. /// /// The formal name of the variable info to remove. /// Output parameter; contains all constraints that could not be /// fulfilled. /// true if the variable info could be deleted without violating constraints, /// false otherwise. bool TryRemoveVariableInfo(string formalName, out ICollection violatedConstraints); /// /// Gets a variable with the given . /// /// The name of the variable. /// The variable with the specified name. IVariable GetVariable(string name); /// /// Adds the specified to the current instance. /// /// The variable to add. void AddVariable(IVariable variable); /// /// Adds the specified to the current instance if all constraints can /// be fulfilled. /// /// The variable to add. /// true if the variable could be added without violating constraints, /// false otherwise. bool TryAddVariable(IVariable variable); /// /// Adds the specified to the current instance if all constraints can /// be fulfilled. /// /// The variable to add. /// Output parameter; contains all constraints that could /// not be fulfillled. /// true if the variable could be added without violating constraints, /// false otherwise. bool TryAddVariable(IVariable variable, out ICollection violatedConstraints); /// /// Deletes the variable with the specified . /// /// The name of the variable to delete. void RemoveVariable(string name); /// /// Deletes the variable with the specified if all constraints can be /// fulfilled. /// /// The name of the variable to remove. /// true if the variable could be deleted without violating constraints, /// false otherwise. bool TryRemoveVariable(string name); /// /// Deletes the variable with the specified if all constraints can be /// fulfilled. /// /// The name of the variable to remove. /// Output parameter; contains all constraints that could /// not be fulfilled. /// true if the variable could be deleted without violating constraints, /// false otherwise. bool TryRemoveVariable(string name, out ICollection violatedConstraints); /// /// The type of the value that is searched. T GetVariableValue(string formalName, IScope scope, bool recursiveLookup) where T : class, IItem; /// /// The type of the value that is searched. T GetVariableValue(string formalName, IScope scope, bool recursiveLookup, bool throwOnError) where T : class, IItem; /// /// The formal name of the variable info whose variable value is searched. /// The scope where to look for the variable. /// Boolean value, whether also the parent scopes shall be searched if /// the variable is not found in the specified . /// The value of the searched variable or null if it is not found. IItem GetVariableValue(string formalName, IScope scope, bool recursiveLookup); /// /// Gets the value of the variable in the specified /// whose variable(parameter) info has the specified . /// /// The formal name of the variable info whose variable value is searched. /// The scope where to look for the variable. /// Boolean value, whether also the parent scopes shall be searched if /// the variable is not found in the specified . /// Boolean value, whether an exception shall be thrown, if the variable /// cannot be found or just null shall be returned. /// The value of the searched variable (or null if the variable is not /// found and is set to false). IItem GetVariableValue(string formalName, IScope scope, bool recursiveLookup, bool throwOnError); /// /// Executes the current instance on the specified . /// /// The scope where to execute the current instance. /// The next operation. IOperation Execute(IScope scope); /// /// Aborts the current operator. /// void Abort(); /// /// Occurs when the name of the operator was changed. /// event EventHandler NameChanged; /// /// Occurs when the breakpoint flag of the current instance was changed. /// event EventHandler BreakpointChanged; /// /// Occurs when a sub operator has been added. /// event EventHandler SubOperatorAdded; /// /// Occurs when a sub operator has been deleted. /// event EventHandler SubOperatorRemoved; /// /// Occurs when a variable info has been added. /// event EventHandler VariableInfoAdded; /// /// Occurs when a variable info has been deleted. /// event EventHandler VariableInfoRemoved; /// /// Occurs when a variable has been added. /// event EventHandler VariableAdded; /// /// Occurs when a variable has been deleted. /// event EventHandler VariableRemoved; /// /// Occurs when the current instance is executed. /// event EventHandler Executed; } }