Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1994 for branches


Ignore:
Timestamp:
06/03/09 02:40:39 (15 years ago)
Author:
swagner
Message:

Refactoring of the operator architecture (#95)

Location:
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.2
Files:
5 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.2/AtomicOperation.cs

    r1529 r1994  
    3737      get { return myOperator; }
    3838    }
    39     private IScope myScope; 
     39    private IEnvironment myEnvironment;
     40    /// <summary>
     41    /// Gets the current environment as <see cref="IEnvironment"/>.
     42    /// </summary>
     43    public IEnvironment Environment {
     44      get { return myEnvironment; }
     45    }
     46    private IScope myScope;
    4047    /// <summary>
    4148    /// Gets the current scope as <see cref="IScope"/>.
     
    5461    /// </summary>
    5562    /// <param name="op">The operator to assign.</param>
     63    /// <param name="environment">The environment to assign.</param>
    5664    /// <param name="scope">The scope to assign.</param>
    57     public AtomicOperation(IOperator op, IScope scope) {
     65    public AtomicOperation(IOperator op, IEnvironment environment, IScope scope) {
    5866      myOperator = op;
     67      myEnvironment = environment;
    5968      myScope = scope;
    6069    }
     
    7180      clonedObjects.Add(Guid, clone);
    7281      clone.myOperator = (IOperator)Auxiliary.Clone(Operator, clonedObjects);
     82      clone.myEnvironment = (IEnvironment)Auxiliary.Clone(Environment, clonedObjects);
    7383      clone.myScope = (IScope)Auxiliary.Clone(Scope, clonedObjects);
    7484      return clone;
     
    8393    /// class <see cref="ItemBase"/>. <br/>
    8494    /// The operator is saved as child node having the tag name <c>Operator</c>.<br/>
     95    /// The environment is also saved as a child node having the tag name <c>Environment</c>.<br/>
    8596    /// The scope is also saved as a child node having the tag name <c>Scope</c>.</remarks>
    8697    /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>
     
    91102      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    92103      node.AppendChild(PersistenceManager.Persist("Operator", Operator, document, persistedObjects));
     104      node.AppendChild(PersistenceManager.Persist("Environment", Environment, document, persistedObjects));
    93105      node.AppendChild(PersistenceManager.Persist("Scope", Scope, document, persistedObjects));
    94106      return node;
     
    99111    /// <remarks>Calls <see cref="HeuristicLab.Core.StorableBase.Populate"/> of base class
    100112    /// <see cref="ItemBase"/>.<br/>
    101     /// The operator must be saved as a child node with the tag name <c>Operator</c>, also the scope must
     113    /// The operator must be saved as a child node with the tag name <c>Operator</c>, the environment must be saved as
     114    /// a child node with the tag name <c>Environment</c>, and also the scope must
    102115    /// be saved as a child node having the tag name <c>Scope</c> (see <see cref="GetXmlNode"/>).</remarks>
    103116    /// <param name="node">The <see cref="XmlNode"/> where the operation is saved.</param>
     
    106119      base.Populate(node, restoredObjects);
    107120      myOperator = (IOperator)PersistenceManager.Restore(node.SelectSingleNode("Operator"), restoredObjects);
     121      myEnvironment = (IEnvironment)PersistenceManager.Restore(node.SelectSingleNode("Environment"), restoredObjects);
    108122      myScope = (IScope)PersistenceManager.Restore(node.SelectSingleNode("Scope"), restoredObjects);
    109123    }
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.2/HeuristicLab.Core-3.2.csproj

    r1534 r1994  
    126126    </Compile>
    127127    <Compile Include="AliasEventArgs.cs" />
     128    <Compile Include="Environment.cs" />
     129    <Compile Include="ParameterEventArgs.cs" />
     130    <Compile Include="ParameterType.cs" />
     131    <Compile Include="Interfaces\IParameter.cs" />
     132    <Compile Include="Interfaces\IEnvironment.cs" />
    128133    <Compile Include="KeyValueEventArgs.cs" />
    129134    <Compile Include="OperatorBaseDescriptionView.cs">
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.2/Interfaces/IItem.cs

    r776 r1994  
    2929  /// </summary>
    3030  public interface IItem : IStorable, IViewable {
    31     /// <summary>
    32     /// Fires a new <c>Changed</c> event.
    33     /// </summary>
    34     void FireChanged();
    35 
    36     /// <summary>
    37     /// Occurs when the current instance has changed.
    38     /// </summary>
    39     event EventHandler Changed;
    4031  }
    4132}
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.2/Interfaces/IOperator.cs

    r1851 r1994  
    2929  /// a basic instruction of an algorithm.
    3030  /// </summary>
    31   public interface IOperator : IConstrainedItem {
     31  public interface IOperator : IItem {
    3232    /// <summary>
    3333    /// Gets or sets the name of the current instance.
     
    4949
    5050    /// <summary>
    51     /// Gets a list of all sub operators.
    52     /// </summary>
    53     IList<IOperator> SubOperators { get; }
    54     /// <summary>
    5551    /// Gets a collection of all variable (parameter) infos.
    5652    /// </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 to the current instance if all constraints can be fulfilled.
    70     /// </summary>
    71     /// <param name="op">The operator to add.</param>
    72     /// <returns><c>true</c> if the operator could be added without violating constraints,
    73     /// <c>false</c> otherwise.</returns>
    74     bool TryAddSubOperator(IOperator op);
    75     /// <summary>
    76     /// Adds the given sub operator to the current instance if all constraints can be fulfilled.
    77     /// </summary>
    78     /// <param name="op">The operator to add.</param>
    79     /// <param name="violatedConstraints">Output parameter; contains all constraints that could not be
    80     /// fulfilled.</param>
    81     /// <returns><c>true</c> if the operator could be added without violating constraints,
    82     /// <c>false</c> otherwise.</returns>
    83     bool TryAddSubOperator(IOperator op, out ICollection<IConstraint> violatedConstraints);
    84     /// <summary>
    85     /// Adds the given sub operator at a the specified <paramref name="index"/>.
    86     /// </summary>
    87     /// <param name="op">The operator to add.</param>
    88     /// <param name="index">The position where to add the operator.</param>
    89     void AddSubOperator(IOperator op, int index);
    90     /// <summary>
    91     /// Adds the given operator at the specified <paramref name="index"/> to the current instance
    92     /// if all constraints can be fulfilled.
    93     /// </summary>
    94     /// <param name="op">The operator to add.</param>
    95     /// <param name="index">The position where to add the operator.</param>
    96     /// <returns><c>true</c> if the operator could be added without violating constraints,
    97     /// <c>false</c> otherwise.</returns>
    98     bool TryAddSubOperator(IOperator op, int index);
    99     /// <summary>
    100     /// Adds the given operator at the specified <paramref name="index"/> to the current instance
    101     /// if all constraints can be fulfilled.
    102     /// </summary>
    103     /// <param name="op">The operator to add.</param>
    104     /// <param name="index">The position where to add the operator.</param>
    105     /// <param name="violatedConstraints">Output parameter; contains all constraints that could not be
    106     /// fulfilled.</param>
    107     /// <returns><c>true</c> if the operator could be added without violating constraints,
    108     /// <c>false</c> otherwise.</returns>
    109     bool TryAddSubOperator(IOperator op, int index, out ICollection<IConstraint> violatedConstraints);
    110     /// <summary>
    111     /// Removes a sub operator at the specified <paramref name="index"/>.
    112     /// </summary>
    113     /// <param name="index">The position where to delete the operator.</param>
    114     void RemoveSubOperator(int index);
    115     /// <summary>
    116     /// Removes a sub operator at the specified <paramref name="index"/> if all constraint can be fulfilled.
    117     /// </summary>
    118     /// <param name="index">The position where to delete the operator.</param>
    119     /// <returns><c>true</c> if the operator could be deleted without violating constraints,
    120     /// <c>false</c> otherwise.</returns>
    121     bool TryRemoveSubOperator(int index);
    122     /// <summary>
    123     /// Deletes the operator at the specified <paramref name="index"/> 
    124     /// if all constraints can be fulfilled.
    125     /// </summary>
    126     /// <param name="index">The position where to delete the operator.</param>
    127     /// <param name="violatedConstraints">Output parameter; contains all constraints that could not be
    128     /// fulfilled.</param>
    129     /// <returns><c>true</c> if the operator could be deleted without violating constraints,
    130     /// <c>false</c> otherwise.</returns>
    131     bool TryRemoveSubOperator(int index, out ICollection<IConstraint> violatedConstraints);
     53    ICollection<IParameter> Parameters { get; }
    13254
    13355    /// <summary>
     
    13658    /// <param name="formalName">The formal name of the variable info.</param>
    13759    /// <returns>The variable info with the specified formal name.</returns>
    138     IVariableInfo GetVariableInfo(string formalName);
     60    IParameter GetParameter(string name);
    13961    /// <summary>
    14062    /// Adds the specified variable info to the current instance.
    14163    /// </summary>
    14264    /// <param name="variableInfo">The variable info to add.</param>
    143     void AddVariableInfo(IVariableInfo variableInfo);
    144     /// <summary>
    145     /// Adds the specified variable info to the current instance, if all constraints can be fulfilled.
    146     /// </summary>
    147     /// <param name="variableInfo">The variable info to add.</param>
    148     /// <returns><c>true</c> if the variable info could be added without violating constraints,
    149     /// <c>false</c> otherwise.</returns>
    150     bool TryAddVariableInfo(IVariableInfo variableInfo);
    151     /// <summary>
    152     /// Adds the specified variable info to the current instance, if all constraints can be fulfilled.
    153     /// </summary>
    154     /// <param name="variableInfo">The variable info to add.</param>
    155     /// <param name="violatedConstraints">Output parameter; contains all constraints that could not be
    156     /// fulfilled.</param>
    157     /// <returns><c>true</c> if the variable info could be added without violating constraints,
    158     /// <c>false</c> otherwise.</returns>
    159     bool TryAddVariableInfo(IVariableInfo variableInfo, out ICollection<IConstraint> violatedConstraints);
     65    void AddParameter(IParameter parameter);
    16066    /// <summary>
    16167    /// Removes the variable info with the given formal name.
    16268    /// </summary>
    16369    /// <param name="formalName">The formal name of the variable info to remove.</param>
    164     void RemoveVariableInfo(string formalName);
    165     /// <summary>
    166     /// Deletes the variable info with the given formal name,
    167     /// if all constraints can be fulfilled.
    168     /// </summary>
    169     /// <param name="formalName">The formal name of the variable info to remove.</param>
    170     /// <returns><c>true</c> if the variable info could be deleted without violating constraints,
    171     /// <c>false</c> otherwise.</returns>
    172     bool TryRemoveVariableInfo(string formalName);
    173     /// <summary>
    174     /// Deletes the variable info with the given formal name,
    175     /// if all constraints can be fulfilled.
    176     /// </summary>
    177     /// <param name="formalName">The formal name of the variable info to remove.</param>
    178     /// <param name="violatedConstraints">Output parameter; contains all constraints that could not be
    179     /// fulfilled.</param>
    180     /// <returns><c>true</c> if the variable info could be deleted without violating constraints,
    181     /// <c>false</c> otherwise.</returns>
    182     bool TryRemoveVariableInfo(string formalName, out ICollection<IConstraint> violatedConstraints);
    183 
    184     /// <summary>
    185     /// Gets a variable with the given <paramref name="name"/>.
    186     /// </summary>
    187     /// <param name="name">The name of the variable.</param>
    188     /// <returns>The variable with the specified name.</returns>
    189     IVariable GetVariable(string name);
    190     /// <summary>
    191     /// Adds the specified <paramref name="variable"/> to the current instance.
    192     /// </summary>
    193     /// <param name="variable">The variable to add.</param>
    194     void AddVariable(IVariable variable);
    195     /// <summary>
    196     /// Adds the specified <paramref name="variable"/> to the current instance if all constraints can
    197     /// be fulfilled.
    198     /// </summary>
    199     /// <param name="variable">The variable to add.</param>
    200     /// <returns><c>true</c> if the variable could be added without violating constraints,
    201     /// <c>false</c> otherwise.</returns>
    202     bool TryAddVariable(IVariable variable);
    203     /// <summary>
    204     /// Adds the specified <paramref name="variable"/> to the current instance if all constraints can
    205     /// be fulfilled.
    206     /// </summary>
    207     /// <param name="variable">The variable to add.</param>
    208     /// <param name="violatedConstraints">Output parameter; contains all constraints that could
    209     /// not be fulfillled.</param>
    210     /// <returns><c>true</c> if the variable could be added without violating constraints,
    211     /// <c>false</c> otherwise.</returns>
    212     bool TryAddVariable(IVariable variable, out ICollection<IConstraint> violatedConstraints);
    213     /// <summary>
    214     /// Deletes the variable with the specified <paramref name="name"/>.
    215     /// </summary>
    216     /// <param name="name">The name of the variable to delete.</param>
    217     void RemoveVariable(string name);
    218     /// <summary>
    219     /// Deletes the variable with the specified <paramref name="name"/> if all constraints can be
    220     /// fulfilled.
    221     /// </summary>
    222     /// <param name="name">The name of the variable to remove.</param>
    223     /// <returns><c>true</c> if the variable could be deleted without violating constraints,
    224     /// <c>false</c> otherwise.</returns>
    225     bool TryRemoveVariable(string name);
    226     /// <summary>
    227     /// Deletes the variable with the specified <paramref name="name"/> if all constraints can be
    228     /// fulfilled.
    229     /// </summary>
    230     /// <param name="name">The name of the variable to remove.</param>
    231     /// <param name="violatedConstraints">Output parameter; contains all constraints that could
    232     /// not be fulfilled.</param>
    233     /// <returns><c>true</c> if the variable could be deleted without violating constraints,
    234     /// <c>false</c> otherwise.</returns>
    235     bool TryRemoveVariable(string name, out ICollection<IConstraint> violatedConstraints);
    236    
    237     /// <inheritdoc cref="GetVariableValue(string, HeuristicLab.Core.IScope, bool)"/>
    238     /// <typeparam name="T">The type of the value that is searched.</typeparam>       
    239     T GetVariableValue<T>(string formalName, IScope scope, bool recursiveLookup) where T : class, IItem;
    240     /// <inheritdoc cref="GetVariableValue(string, HeuristicLab.Core.IScope, bool, bool)"/>
    241     /// <typeparam name="T">The type of the value that is searched.</typeparam>
    242     T GetVariableValue<T>(string formalName, IScope scope, bool recursiveLookup, bool throwOnError) where T : class, IItem;
    243     /// <inheritdoc cref="GetVariableValue(System.String, IScope, bool, bool)"
    244     /// select="summary"/>
    245     /// <param name="formalName">The formal name of the variable info whose variable value is searched.</param>
    246     /// <param name="scope">The scope where to look for the variable.</param>
    247     /// <param name="recursiveLookup">Boolean value, whether also the parent scopes shall be searched if
    248     /// the variable is not found in the specified <paramref name="scope"/>.</param>
    249     /// <returns>The value of the searched variable or null if it is not found.</returns>
    250     IItem GetVariableValue(string formalName, IScope scope, bool recursiveLookup);
    251     /// <summary>
    252     /// Gets the value of the variable in the specified <paramref name="scope"/>
    253     /// whose variable(parameter) info has the specified <paramref name="formalName"/>.
    254     /// </summary>
    255     /// <param name="formalName">The formal name of the variable info whose variable value is searched.</param>
    256     /// <param name="scope">The scope where to look for the variable.</param>
    257     /// <param name="recursiveLookup">Boolean value, whether also the parent scopes shall be searched if
    258     /// the variable is not found in the specified <paramref name="scope"/>.</param>
    259     /// <param name="throwOnError">Boolean value, whether an exception shall be thrown, if the variable
    260     /// cannot be found or just <c>null</c> shall be returned.</param>
    261     /// <returns>The value of the searched variable (or null if the variable is not
    262     /// found and <paramref name="throwOnError"/> is set to false).</returns>
    263     IItem GetVariableValue(string formalName, IScope scope, bool recursiveLookup, bool throwOnError);
     70    void RemoveParameter(string name);
    26471
    26572    /// <summary>
     
    26875    /// <param name="scope">The scope where to execute the current instance.</param>
    26976    /// <returns>The next operation.</returns>
    270     IOperation Execute(IScope scope);
     77    IOperation Execute(IEnvironment environment, IScope scope);
    27178    /// <summary>
    27279    /// Aborts the current operator.
     
    28390    event EventHandler BreakpointChanged;
    28491    /// <summary>
    285     /// Occurs when a sub operator has been added.
    286     /// </summary>
    287     event EventHandler<OperatorIndexEventArgs> SubOperatorAdded;
    288     /// <summary>
    289     /// Occurs when a sub operator has been deleted.
    290     /// </summary>
    291     event EventHandler<OperatorIndexEventArgs> SubOperatorRemoved;
    292     /// <summary>
    29392    /// Occurs when a variable info has been added.
    29493    /// </summary>
    295     event EventHandler<VariableInfoEventArgs> VariableInfoAdded;
     94    event EventHandler<ParameterEventArgs> ParameterAdded;
    29695    /// <summary>
    29796    /// Occurs when a variable info has been deleted.
    29897    /// </summary>
    299     event EventHandler<VariableInfoEventArgs> VariableInfoRemoved;
    300     /// <summary>
    301     /// Occurs when a variable has been added.
    302     /// </summary>
    303     event EventHandler<VariableEventArgs> VariableAdded;
    304     /// <summary>
    305     /// Occurs when a variable has been deleted.
    306     /// </summary>
    307     event EventHandler<VariableEventArgs> VariableRemoved;
     98    event EventHandler<ParameterEventArgs> ParameterRemoved;
    30899    /// <summary>
    309100    /// Occurs when the current instance is executed.
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.2/Interfaces/IScope.cs

    r801 r1994  
    3939    /// </summary>
    4040    ICollection<IVariable> Variables { get; }
    41     /// <summary>
    42     /// Gets all aliases of the current scope.
    43     /// </summary>
    44     IEnumerable<KeyValuePair<string, string>> Aliases { get; }
    4541    /// <summary>
    4642    /// Gets all subscopes in the current scope.
     
    9692
    9793    /// <summary>
    98     /// Gets the actual name of the given alias.
    99     /// </summary>
    100     /// <param name="name">The alias whose actual name is searched.</param>
    101     /// <returns>The actual name.</returns>
    102     string TranslateName(string name);
    103     /// <summary>
    104     /// Adds an alias to the current instance.
    105     /// </summary>
    106     /// <param name="alias">The alias to add.</param>
    107     /// <param name="name">The actual name of the alias.</param>
    108     void AddAlias(string alias, string name);
    109     /// <summary>
    110     /// Deletes the specified <paramref name="alias"/> from the current instance.
    111     /// </summary>
    112     /// <param name="alias">The alias to delete.</param>
    113     void RemoveAlias(string alias);
    114 
    115     /// <summary>
    11694    /// Adds the specified sub scope to the current instance.
    11795    /// </summary>
     
    155133    event EventHandler<VariableEventArgs> VariableRemoved;
    156134    /// <summary>
    157     /// Occurs when an alias has been added to the current instance.
    158     /// </summary>
    159     event EventHandler<AliasEventArgs> AliasAdded;
    160     /// <summary>
    161     /// Occurs when an alias has been removed from the current instance.
    162     /// </summary>
    163     event EventHandler<AliasEventArgs> AliasRemoved;
    164     /// <summary>
    165135    /// Occurs when a sub scope has been added to the current instance.
    166136    /// </summary>
  • branches/Operator Architecture Refactoring/HeuristicLab.Core/3.2/Interfaces/IViewable.cs

    r776 r1994  
    3030  public interface IViewable {
    3131    /// <summary>
     32    /// Fires a new <c>Changed</c> event.
     33    /// </summary>
     34    void FireChanged();
     35    /// <summary>
     36    /// Occurs when the current instance has changed.
     37    /// </summary>
     38    event EventHandler Changed;
     39
     40    /// <summary>
    3241    /// Creates a view to display the current instance.
    3342    /// </summary>
Note: See TracChangeset for help on using the changeset viewer.