Free cookie consent management tool by TermsFeed Policy Generator

Changeset 40


Ignore:
Timestamp:
03/05/08 02:08:02 (17 years ago)
Author:
swagner
Message:

Worked on ticket #41

  • added generic ItemList<T>
Location:
trunk/sources
Files:
13 edited
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Constraints/AndConstraint.cs

    r2 r40  
    2929namespace HeuristicLab.Constraints {
    3030  public class AndConstraint : ConstraintBase, IViewable {
    31     private ItemList clauses;
    32     public ItemList Clauses {
     31    private ItemList<IConstraint> clauses;
     32    public ItemList<IConstraint> Clauses {
    3333      get { return clauses; }
    3434      set {
     
    4545
    4646    public AndConstraint() {
    47       clauses = new ItemList();
    48       clauses.ItemType = typeof(IConstraint);
     47      clauses = new ItemList<IConstraint>();
    4948    }
    5049
     
    5251      bool result = true;
    5352      for (int i = 0 ; i < clauses.Count ; i++) {
    54         result = ((IConstraint)clauses[i]).Check(data);
     53        result = clauses[i].Check(data);
    5554        if (!result) return false;
    5655      }
     
    6564      AndConstraint clone = new AndConstraint();
    6665      clonedObjects.Add(Guid, clone);
    67       clone.Clauses = (ItemList)Auxiliary.Clone(Clauses, clonedObjects);
     66      clone.Clauses = (ItemList<IConstraint>)Auxiliary.Clone(Clauses, clonedObjects);
    6867      return clone;
    6968    }
     
    8483    public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    8584      base.Populate(node, restoredObjects);
    86       clauses = (ItemList)PersistenceManager.Restore(node.SelectSingleNode("Clauses"), restoredObjects);
     85      clauses = (ItemList<IConstraint>)PersistenceManager.Restore(node.SelectSingleNode("Clauses"), restoredObjects);
    8786    }
    8887    #endregion persistence
  • trunk/sources/HeuristicLab.Constraints/AndConstraintView.Designer.cs

    r2 r40  
    4646    /// </summary>
    4747    private void InitializeComponent() {
    48       this.clausesItemListView = new HeuristicLab.Data.ItemListView();
     48      this.clausesItemListView = new HeuristicLab.Data.ItemListView<HeuristicLab.Core.IConstraint>();
    4949      this.SuspendLayout();
    5050      //
     
    7373    #endregion
    7474
    75     private HeuristicLab.Data.ItemListView clausesItemListView;
     75    private HeuristicLab.Data.ItemListView<HeuristicLab.Core.IConstraint> clausesItemListView;
    7676
    7777  }
  • trunk/sources/HeuristicLab.Constraints/ItemTypeConstraint.cs

    r2 r40  
    8181      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    8282      XmlAttribute itemTypeAttribute = document.CreateAttribute("ItemType");
    83       string typeString = Type.AssemblyQualifiedName;
    84       string[] tokens = typeString.Split(new string[] { ", " }, StringSplitOptions.None);
    85       typeString = tokens[0] + ", " + tokens[1];
    86       itemTypeAttribute.Value = typeString;
     83      itemTypeAttribute.Value = PersistenceManager.BuildTypeString(Type);
    8784      node.Attributes.Append(itemTypeAttribute);
    8885      return node;
  • trunk/sources/HeuristicLab.Constraints/OrConstraint.cs

    r2 r40  
    2929namespace HeuristicLab.Constraints {
    3030  public class OrConstraint : ConstraintBase, IViewable {
    31     private ItemList clauses;
    32     public ItemList Clauses {
     31    private ItemList<IConstraint> clauses;
     32    public ItemList<IConstraint> Clauses {
    3333      get { return clauses; }
    3434      set {
     
    4545
    4646    public OrConstraint() {
    47       clauses = new ItemList();
    48       clauses.ItemType = typeof(IConstraint);
     47      clauses = new ItemList<IConstraint>();
    4948    }
    5049
     
    5251      bool result = false;
    5352      for (int i = 0 ; i < clauses.Count ; i++) {
    54         result = ((IConstraint)clauses[i]).Check(data);
     53        result = clauses[i].Check(data);
    5554        if (result) return true;
    5655      }
     
    6564      OrConstraint clone = new OrConstraint();
    6665      clonedObjects.Add(Guid, clone);
    67       clone.Clauses = (ItemList)Auxiliary.Clone(Clauses, clonedObjects);
     66      clone.Clauses = (ItemList<IConstraint>)Auxiliary.Clone(Clauses, clonedObjects);
    6867      return clone;
    6968    }
     
    8584    public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    8685      base.Populate(node, restoredObjects);
    87       clauses = (ItemList)PersistenceManager.Restore(node.SelectSingleNode("Clauses"), restoredObjects);
     86      clauses = (ItemList<IConstraint>)PersistenceManager.Restore(node.SelectSingleNode("Clauses"), restoredObjects);
    8887    }
    8988    #endregion persistence
  • trunk/sources/HeuristicLab.Constraints/OrConstraintView.Designer.cs

    r2 r40  
    4646    /// </summary>
    4747    private void InitializeComponent() {
    48       this.clausesItemListView = new HeuristicLab.Data.ItemListView();
     48      this.clausesItemListView = new HeuristicLab.Data.ItemListView<HeuristicLab.Core.IConstraint>();
    4949      this.SuspendLayout();
    5050      //
     
    7373    #endregion
    7474
    75     private HeuristicLab.Data.ItemListView clausesItemListView;
     75    private HeuristicLab.Data.ItemListView<HeuristicLab.Core.IConstraint> clausesItemListView;
    7676  }
    7777}
  • trunk/sources/HeuristicLab.Core/PersistenceManager.cs

    r22 r40  
    8282      return PersistenceManager.Restore(doc.ChildNodes[1], new Dictionary<Guid, IStorable>());
    8383    }
     84
     85    public static string BuildTypeString(Type type) {
     86      string assembly = type.Assembly.FullName;
     87      assembly = assembly.Split(new string[] { ", " }, StringSplitOptions.None)[0];
     88
     89      StringBuilder builder = new StringBuilder();
     90      builder.Append(type.Namespace);
     91      builder.Append(".");
     92      builder.Append(type.Name);
     93      Type[] args = type.GetGenericArguments();
     94      if (args.Length > 0) {
     95        builder.Append("[[");
     96        builder.Append(BuildTypeString(args[0]));
     97        builder.Append("]");
     98        for (int i = 1; i < args.Length; i++) {
     99          builder.Append(",[");
     100          builder.Append(BuildTypeString(args[i]));
     101          builder.Append("]");
     102        }
     103        builder.Append("]");
     104      }
     105      builder.Append(", ");
     106      builder.Append(assembly);
     107      return builder.ToString();
     108    }
    84109  }
    85110}
  • trunk/sources/HeuristicLab.Core/StorableBase.cs

    r2 r40  
    4747    public virtual XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {
    4848      XmlNode node = document.CreateNode(XmlNodeType.Element, name, null);
    49       Type type = this.GetType();
    50       string typeString = type.AssemblyQualifiedName;
    51       string[] tokens = typeString.Split(new string[] { ", " }, StringSplitOptions.None);
    52       typeString = tokens[0] + ", " + tokens[1];
    5349      XmlAttribute typeAttribute = document.CreateAttribute("Type");
    54       typeAttribute.Value = typeString;
     50      typeAttribute.Value = PersistenceManager.BuildTypeString(this.GetType());
    5551      node.Attributes.Append(typeAttribute);
    5652      XmlAttribute guidAttribute = document.CreateAttribute("GUID");
  • trunk/sources/HeuristicLab.Core/VariableInfo.cs

    r2 r40  
    124124
    125125      XmlAttribute dataTypeAttribute = document.CreateAttribute("DataType");
    126       string typeString = DataType.AssemblyQualifiedName;
    127       string[] tokens = typeString.Split(new string[] { ", " }, StringSplitOptions.None);
    128       typeString = tokens[0] + ", " + tokens[1];
    129       dataTypeAttribute.Value = typeString;
     126      dataTypeAttribute.Value = PersistenceManager.BuildTypeString(DataType);
    130127      node.Attributes.Append(dataTypeAttribute);
    131128
  • trunk/sources/HeuristicLab.Data/HeuristicLab.Data.csproj

    r30 r40  
    150150    <Compile Include="IObjectData.cs" />
    151151    <Compile Include="IObjectDataVisitor.cs" />
    152     <Compile Include="ItemList.cs" />
    153     <Compile Include="ItemListView.cs">
    154       <SubType>UserControl</SubType>
    155     </Compile>
    156     <Compile Include="ItemListView.Designer.cs">
    157       <DependentUpon>ItemListView.cs</DependentUpon>
     152    <Compile Include="ItemListView_T.cs">
     153      <SubType>UserControl</SubType>
     154    </Compile>
     155    <Compile Include="ItemListView_T.Designer.cs">
     156      <DependentUpon>ItemListView_T.cs</DependentUpon>
     157    </Compile>
     158    <Compile Include="ItemList_T.cs">
     159      <SubType>UserControl</SubType>
    158160    </Compile>
    159161    <Compile Include="MatrixDataBaseView.cs">
     
    223225      <SubType>Designer</SubType>
    224226    </EmbeddedResource>
    225     <EmbeddedResource Include="ItemListView.resx">
    226       <DependentUpon>ItemListView.cs</DependentUpon>
     227    <EmbeddedResource Include="ItemListView_T.resx">
     228      <DependentUpon>ItemListView_T.cs</DependentUpon>
    227229      <SubType>Designer</SubType>
    228230    </EmbeddedResource>
  • trunk/sources/HeuristicLab.Data/ItemListView_T.Designer.cs

    r38 r40  
    2525
    2626namespace HeuristicLab.Data {
    27   partial class ItemListView {
     27  partial class ItemListView<T> {
    2828    /// <summary>
    2929    /// Required designer variable.
     
    6060      this.detailsGroupBox = new System.Windows.Forms.GroupBox();
    6161      this.itemTypeLabel = new System.Windows.Forms.Label();
    62       this.setTypeButton = new System.Windows.Forms.Button();
    6362      this.typeTextBox = new System.Windows.Forms.TextBox();
    6463      this.splitContainer.Panel1.SuspendLayout();
     
    8685      this.splitContainer.Size = new System.Drawing.Size(423, 246);
    8786      this.splitContainer.SplitterDistance = 198;
    88       this.splitContainer.TabIndex = 3;
     87      this.splitContainer.TabIndex = 2;
    8988      //
    9089      // itemsGroupBox
     
    167166      this.itemTypeLabel.Text = "&Item Type:";
    168167      //
    169       // setTypeButton
    170       //
    171       this.setTypeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    172       this.setTypeButton.Location = new System.Drawing.Point(380, 0);
    173       this.setTypeButton.Name = "setTypeButton";
    174       this.setTypeButton.Size = new System.Drawing.Size(43, 20);
    175       this.setTypeButton.TabIndex = 1;
    176       this.setTypeButton.Text = "&Set...";
    177       this.setTypeButton.UseVisualStyleBackColor = true;
    178       this.setTypeButton.Click += new System.EventHandler(this.setTypeButton_Click);
    179       //
    180168      // typeTextBox
    181169      //
     
    185173      this.typeTextBox.Name = "typeTextBox";
    186174      this.typeTextBox.ReadOnly = true;
    187       this.typeTextBox.Size = new System.Drawing.Size(308, 20);
    188       this.typeTextBox.TabIndex = 2;
     175      this.typeTextBox.Size = new System.Drawing.Size(357, 20);
     176      this.typeTextBox.TabIndex = 1;
    189177      //
    190178      // ItemListView
     
    193181      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    194182      this.Controls.Add(this.typeTextBox);
    195       this.Controls.Add(this.setTypeButton);
    196183      this.Controls.Add(this.itemTypeLabel);
    197184      this.Controls.Add(this.splitContainer);
     
    217204    private System.Windows.Forms.ColumnHeader columnHeader1;
    218205    private Label itemTypeLabel;
    219     private Button setTypeButton;
    220206    private TextBox typeTextBox;
    221207
  • trunk/sources/HeuristicLab.Data/ItemListView_T.cs

    r38 r40  
    2727using System.Text;
    2828using System.Windows.Forms;
    29 using HeuristicLab.PluginInfrastructure;
    3029using HeuristicLab.Core;
    3130
    3231namespace HeuristicLab.Data {
    33   public partial class ItemListView : ViewBase {
     32  public partial class ItemListView<T> : ViewBase where T : IItem {
    3433    private ChooseItemDialog chooseItemDialog;
    3534
    36     public ItemList ItemList {
    37       get { return (ItemList)Item; }
     35    public ItemList<T> ItemList {
     36      get { return (ItemList<T>)Item; }
    3837      set { base.Item = value; }
    3938    }
     
    4342      itemsListView.Columns[0].Width = Math.Max(0, itemsListView.Width - 25);
    4443    }
    45     public ItemListView(ItemList itemList)
     44    public ItemListView(ItemList<T> itemList)
    4645      : this() {
    4746      ItemList = itemList;
     
    4948
    5049    protected override void RemoveItemEvents() {
    51       ItemList.ItemTypeChanged -= new EventHandler(ItemList_ItemTypeChanged);
    5250      ItemList.ItemAdded -= new EventHandler<ItemIndexEventArgs>(ItemList_ItemInserted);
    5351      ItemList.ItemRemoved -= new EventHandler<ItemIndexEventArgs>(ItemList_ItemRemoved);
     
    5755    protected override void AddItemEvents() {
    5856      base.AddItemEvents();
    59       ItemList.ItemTypeChanged += new EventHandler(ItemList_ItemTypeChanged);
    6057      ItemList.ItemAdded += new EventHandler<ItemIndexEventArgs>(ItemList_ItemInserted);
    6158      ItemList.ItemRemoved += new EventHandler<ItemIndexEventArgs>(ItemList_ItemRemoved);
     
    7067      if (ItemList == null) {
    7168        typeTextBox.Text = "";
    72         setTypeButton.Enabled = false;
    7369        splitContainer.Enabled = false;
    7470      } else {
    75         typeTextBox.Text = ItemList.ItemType.FullName;
    76         setTypeButton.Enabled = true;
     71        typeTextBox.Text = typeof(T).FullName;
    7772        splitContainer.Enabled = true;
    7873        foreach (ListViewItem item in itemsListView.Items) {
     
    125120
    126121    #region Button Events
    127     private void setTypeButton_Click(object sender, EventArgs e) {
    128       ChooseTypeDialog dialog = new ChooseTypeDialog();
    129       dialog.Caption = "Set Item Type";
    130       if (dialog.ShowDialog(this) == DialogResult.OK) {
    131         try {
    132           ItemList.ItemType = dialog.Type;
    133         }
    134         catch (Exception ex) {
    135           Auxiliary.ShowErrorMessageBox(ex);
    136         }
    137       }
    138       dialog.Dispose();
    139     }
    140122    private void addButton_Click(object sender, EventArgs e) {
    141123      if (chooseItemDialog == null) {
    142         chooseItemDialog = new ChooseItemDialog(ItemList.ItemType);
     124        chooseItemDialog = new ChooseItemDialog(typeof(T));
    143125        chooseItemDialog.Caption = "Add Item";
    144126      }
    145127      if (chooseItemDialog.ShowDialog(this) == DialogResult.OK) {
    146128        try {
    147           ItemList.Add(chooseItemDialog.Item);
     129          ItemList.Add((T)chooseItemDialog.Item);
    148130        }
    149131        catch (Exception ex) {
     
    193175          if (item != null) {
    194176            int index = item.Index;
    195             ItemList.Remove(data);
    196             ItemList.Insert(index, data);
     177            ItemList.Remove((T)data);
     178            ItemList.Insert(index, (T)data);
    197179            itemsListView.SelectedIndices.Clear();
    198180            itemsListView.SelectedIndices.Add(index);
     
    204186
    205187    #region Item and Item List Events
    206     private void ItemList_ItemTypeChanged(object sender, EventArgs e) {
    207       if (InvokeRequired)
    208         Invoke(new EventHandler(ItemList_ItemTypeChanged), sender, e);
    209       else {
    210         typeTextBox.Text = ItemList.ItemType.FullName;
    211         if (chooseItemDialog != null) chooseItemDialog.Dispose();
    212         chooseItemDialog = new ChooseItemDialog(ItemList.ItemType);
    213         chooseItemDialog.Caption = "Add Item";
    214       }
    215     }
    216188    private void ItemList_ItemInserted(object sender, ItemIndexEventArgs e) {
    217189      if (InvokeRequired)
  • trunk/sources/HeuristicLab.Data/ItemList_T.cs

    r38 r40  
    2828
    2929namespace HeuristicLab.Data {
    30   public class ItemList : ItemBase, IList<IItem> {
    31     private List<IItem> list;
    32 
    33     private Type myItemType;
    34     public Type ItemType {
    35       get { return myItemType; }
    36       set {
    37         if (value == null) value = typeof(IItem);
    38         if (value != myItemType) {
    39           if (!typeof(IItem).IsAssignableFrom(value))
    40             throw new InvalidOperationException("Cannot set item type. Only types compatible to IItem are allowed.");
    41           foreach (IItem item in list) {
    42             if (!value.IsAssignableFrom(item.GetType()))
    43               throw new InvalidOperationException("Cannot set item type. Items are incompatible.");
    44           }
    45           myItemType = value;
    46           OnItemTypeChanged();
    47         }
    48       }
    49     }
     30  public class ItemList<T> : ItemBase, IList<T> where T : IItem {
     31    private List<T> list;
    5032
    5133    public ItemList() {
    52       list = new List<IItem>();
    53       myItemType = typeof(IItem);
     34      list = new List<T>();
    5435    }
    5536
    5637    public override IView CreateView() {
    57       return new ItemListView(this);
     38      return new ItemListView<T>(this);
    5839    }
    5940
    6041    public override object Clone(IDictionary<Guid, object> clonedObjects) {
    61       ItemList clone = new ItemList();
     42      ItemList<T> clone = new ItemList<T>();
    6243      clonedObjects.Add(Guid, clone);
    63       clone.myItemType = ItemType;
    6444      for (int i = 0; i < list.Count; i++)
    65         clone.list.Add((IItem)Auxiliary.Clone(list[i], clonedObjects));
     45        clone.list.Add((T)Auxiliary.Clone(list[i], clonedObjects));
    6646      return clone;
    6747    }
     
    6949    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {
    7050      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    71       if (ItemType != null) {
    72         XmlAttribute itemTypeAttribute = document.CreateAttribute("ItemType");
    73         string typeString = ItemType.AssemblyQualifiedName;
    74         string[] tokens = typeString.Split(new string[] { ", " }, StringSplitOptions.None);
    75         typeString = tokens[0] + ", " + tokens[1];
    76         itemTypeAttribute.Value = typeString;
    77         node.Attributes.Append(itemTypeAttribute);
    78       }
    7951      for (int i = 0; i < list.Count; i++)
    8052        node.AppendChild(PersistenceManager.Persist(list[i], document, persistedObjects));
     
    8355    public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    8456      base.Populate(node, restoredObjects);
    85       XmlAttribute itemTypeAttribute = node.Attributes["ItemType"];
    86       if (itemTypeAttribute != null)
    87         myItemType = Type.GetType(itemTypeAttribute.Value);
    8857      for (int i = 0; i < node.ChildNodes.Count; i++)
    89         list.Add((IItem)PersistenceManager.Restore(node.ChildNodes[i], restoredObjects));
     58        list.Add((T)PersistenceManager.Restore(node.ChildNodes[i], restoredObjects));
    9059    }
    9160
     
    10473    }
    10574
    106     #region IList<IItem> Members
    107     public int IndexOf(IItem item) {
     75    #region IList<T> Members
     76    public int IndexOf(T item) {
    10877      return list.IndexOf(item);
    10978    }
    110     public void Insert(int index, IItem item) {
    111       if ((ItemType != null) && (!ItemType.IsAssignableFrom(item.GetType())))
    112         throw new InvalidOperationException("item type is incompatible to required item type");
     79    public void Insert(int index, T item) {
    11380      list.Insert(index, item);
    11481      OnItemAdded(item, index);
     
    11986      OnItemRemoved(item, index);
    12087    }
    121     public IItem this[int index] {
     88    public T this[int index] {
    12289      get { return list[index]; }
    123       set {
    124         if ((ItemType != null) && (!ItemType.IsAssignableFrom(value.GetType())))
    125           throw new InvalidOperationException("item type is incompatible to required item type");
    126         list[index] = value;
    127       }
     90      set { list[index] = value; }
    12891    }
    12992    #endregion
    13093
    131     #region ICollection<IItem> Members
    132     public void Add(IItem item) {
    133       if ((ItemType != null) && (!ItemType.IsAssignableFrom(item.GetType())))
    134         throw new InvalidOperationException("item type is incompatible to required item type");
     94    #region ICollection<T> Members
     95    public void Add(T item) {
    13596      list.Add(item);
    13697      OnItemAdded(item, list.Count - 1);
     
    140101      OnCleared();
    141102    }
    142     public bool Contains(IItem item) {
     103    public bool Contains(T item) {
    143104      return list.Contains(item);
    144105    }
    145     public void CopyTo(IItem[] array, int arrayIndex) {
     106    public void CopyTo(T[] array, int arrayIndex) {
    146107      list.CopyTo(array, arrayIndex);
    147108    }
     
    152113      get { return false; }
    153114    }
    154     public bool Remove(IItem item) {
     115    public bool Remove(T item) {
    155116      int index = list.IndexOf(item);
    156117      if (list.Remove(item)) {
     
    163124    #endregion
    164125
    165     #region IEnumerable<IItem> Members
    166     public IEnumerator<IItem> GetEnumerator() {
     126    #region IEnumerable<T> Members
     127    public IEnumerator<T> GetEnumerator() {
    167128      return list.GetEnumerator();
    168129    }
     
    175136    #endregion
    176137
    177     public event EventHandler ItemTypeChanged;
    178     protected virtual void OnItemTypeChanged() {
    179       if (ItemTypeChanged != null)
    180         ItemTypeChanged(this, new EventArgs());
    181       OnChanged();
    182     }
    183138    public event EventHandler<ItemIndexEventArgs> ItemAdded;
    184139    protected virtual void OnItemAdded(IItem item, int index) {
     
    200155    }
    201156  }
     157
     158  public class ItemList : ItemList<IItem> { }
     159  public class ItemListView : ItemListView<IItem> {
     160    public ItemListView() { }
     161    public ItemListView(ItemList itemList)
     162      : this() {
     163      ItemList = itemList;
     164    }
     165  }
    202166}
  • trunk/sources/HeuristicLab.Evolutionary/SubScopesStorer.cs

    r2 r40  
    3636      : base() {
    3737      AddVariableInfo(new VariableInfo("SubScopes", "Number of sub-scopes that should be available", typeof(IntData), VariableKind.In));
    38       AddVariableInfo(new VariableInfo("SubScopesStore", "Temporarily stored sub-scopes", typeof(ItemList), VariableKind.New | VariableKind.In | VariableKind.Out | VariableKind.Deleted));
     38      AddVariableInfo(new VariableInfo("SubScopesStore", "Temporarily stored sub-scopes", typeof(ItemList<IScope>), VariableKind.New | VariableKind.In | VariableKind.Out | VariableKind.Deleted));
    3939    }
    4040
    4141    public override IOperation Apply(IScope scope) {
    4242      IntData subScopes = GetVariableValue<IntData>("SubScopes", scope, true);
    43       ItemList subScopesStore = GetVariableValue<ItemList>("SubScopesStore", scope, false);
     43      ItemList<IScope> subScopesStore = GetVariableValue<ItemList<IScope>>("SubScopesStore", scope, false);
    4444
    4545      if (subScopesStore == null) {
    46         subScopesStore = new ItemList();
    47         subScopesStore.ItemType = typeof(IScope);
     46        subScopesStore = new ItemList<IScope>();
    4847        IVariableInfo info = GetVariableInfo("SubScopesStore");
    4948        if (info.Local)
     
    6059        // restore sub-scopes
    6160        for (int i = 0; i < subScopesStore.Count; i++) {
    62           right.AddSubScope((IScope)subScopesStore[i]);
     61          right.AddSubScope(subScopesStore[i]);
    6362          IVariableInfo info = GetVariableInfo("SubScopesStore");
    6463          if (info.Local)
  • trunk/sources/HeuristicLab.Operators/CombinedOperator.cs

    r2 r40  
    4747      GetVariableInfo("InjectSubOperators").Local = true;
    4848      AddVariable(new Variable("InjectSubOperators", new BoolData(false)));
    49       AddVariableInfo(new VariableInfo("SubOperatorNames", "Variable names for injecting the sub-operators", typeof(ItemList), VariableKind.In));
     49      AddVariableInfo(new VariableInfo("SubOperatorNames", "Variable names for injecting the sub-operators", typeof(ItemList<StringData>), VariableKind.In));
    5050      GetVariableInfo("SubOperatorNames").Local = true;
    51       ItemList subOperatorNames = new ItemList();
    52       subOperatorNames.ItemType = typeof(StringData);
     51      ItemList<StringData> subOperatorNames = new ItemList<StringData>();
    5352      AddVariable(new Variable("SubOperatorNames", subOperatorNames));
    5453    }
     
    7574        bool inject = GetVariableValue<BoolData>("InjectSubOperators", scope, false).Data;
    7675        if (inject) {
    77           ItemList names = GetVariableValue<ItemList>("SubOperatorNames", scope, false);
     76          ItemList<StringData> names = GetVariableValue<ItemList<StringData>>("SubOperatorNames", scope, false);
    7877          for (int i = 0; i < SubOperators.Count; i++) {
    79             if (scope.GetVariable(names[i].ToString()) != null)
    80               scope.RemoveVariable(names[i].ToString());
    81             scope.AddVariable(new Variable(names[i].ToString(), SubOperators[i]));
     78            if (scope.GetVariable(names[i].Data) != null)
     79              scope.RemoveVariable(names[i].Data);
     80            scope.AddVariable(new Variable(names[i].Data, SubOperators[i]));
    8281          }
    8382        }
  • trunk/sources/HeuristicLab.Operators/DataCollector.cs

    r2 r40  
    3333
    3434    public DataCollector() {
    35       IVariableInfo variableNamesVariableInfo = new VariableInfo("VariableNames", "Names of variables whose values should be collected", typeof(ItemList), VariableKind.In);
     35      IVariableInfo variableNamesVariableInfo = new VariableInfo("VariableNames", "Names of variables whose values should be collected", typeof(ItemList<StringData>), VariableKind.In);
    3636      variableNamesVariableInfo.Local = true;
    3737      AddVariableInfo(variableNamesVariableInfo);
    38       ItemList variableNames = new ItemList();
    39       variableNames.ItemType = typeof(StringData);
     38      ItemList<StringData> variableNames = new ItemList<StringData>();
    4039      AddVariable(new Variable("VariableNames", variableNames));
    4140      AddVariableInfo(new VariableInfo("Values", "Collected values", typeof(ItemList), VariableKind.New | VariableKind.In | VariableKind.Out));
     
    4342
    4443    public override IOperation Apply(IScope scope) {
    45       ItemList names = GetVariableValue<ItemList>("VariableNames", scope, false);
     44      ItemList<StringData> names = GetVariableValue<ItemList<StringData>>("VariableNames", scope, false);
    4645      ItemList values = GetVariableValue<ItemList>("Values", scope, false, false);
    4746      if (values == null) {
     
    5655      ItemList currentValues = new ItemList();
    5756      for (int i = 0; i < names.Count; i++)
    58         currentValues.Add((IItem)scope.GetVariableValue(((StringData)names[i]).Data, true).Clone());
     57        currentValues.Add((IItem)scope.GetVariableValue(names[i].Data, true).Clone());
    5958      values.Add(currentValues);
    6059      return null;
  • trunk/sources/HeuristicLab.Selection.OffspringSelection/OffspringSelector.cs

    r2 r40  
    3838      AddVariableInfo(new VariableInfo("SelectionPressure", "Current selection pressure", typeof(DoubleData), VariableKind.New | VariableKind.Out));
    3939      AddVariableInfo(new VariableInfo("SuccessRatio", "Current success ratio", typeof(DoubleData), VariableKind.New | VariableKind.Out));
    40       AddVariableInfo(new VariableInfo("GoodChildren", "Temporarily store successful children", typeof(ItemList), VariableKind.New | VariableKind.Out | VariableKind.In | VariableKind.Deleted));
    41       AddVariableInfo(new VariableInfo("BadChildren", "Temporarily store unsuccessful children", typeof(ItemList), VariableKind.New | VariableKind.Out | VariableKind.In | VariableKind.Deleted));
     40      AddVariableInfo(new VariableInfo("GoodChildren", "Temporarily store successful children", typeof(ItemList<IScope>), VariableKind.New | VariableKind.Out | VariableKind.In | VariableKind.Deleted));
     41      AddVariableInfo(new VariableInfo("BadChildren", "Temporarily store unsuccessful children", typeof(ItemList<IScope>), VariableKind.New | VariableKind.Out | VariableKind.In | VariableKind.Deleted));
    4242    }
    4343
     
    5050
    5151      // retrieve good and bad children
    52       ItemList goodChildren = GetVariableValue<ItemList>("GoodChildren", scope, false, false);
     52      ItemList<IScope> goodChildren = GetVariableValue<ItemList<IScope>>("GoodChildren", scope, false, false);
    5353      if (goodChildren == null) {
    54         goodChildren = new ItemList();
    55         goodChildren.ItemType = typeof(IScope);
     54        goodChildren = new ItemList<IScope>();
    5655        IVariableInfo goodChildrenInfo = GetVariableInfo("GoodChildren");
    5756        if (goodChildrenInfo.Local)
     
    6059          scope.AddVariable(new Variable(goodChildrenInfo.ActualName, goodChildren));
    6160      }
    62       ItemList badChildren = GetVariableValue<ItemList>("BadChildren", scope, false, false);
     61      ItemList<IScope> badChildren = GetVariableValue<ItemList<IScope>>("BadChildren", scope, false, false);
    6362      if (badChildren == null) {
    64         badChildren = new ItemList();
    65         badChildren.ItemType = typeof(IScope);
     63        badChildren = new ItemList<IScope>();
    6664        IVariableInfo badChildrenInfo = GetVariableInfo("BadChildren");
    6765        if (badChildrenInfo.Local)
Note: See TracChangeset for help on using the changeset viewer.