#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; using System.Xml; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Core { /// /// Class for storing meta-information about variables/parameters of an operator. /// public class VariableInfo : ItemBase, IVariableInfo { [Storable] private string myActualName; /// /// Gets or sets the actual name of the current instance. /// /// Calls in the setter. public string ActualName { get { return myActualName; } set { if (myActualName != value) { myActualName = value; OnActualNameChanged(); } } } [Storable] private string myFormalName; /// /// Gets the formal name of the current instance. /// public string FormalName { get { return myFormalName; } } [Storable] private string myDescription; /// /// Gets the description of the current instance. /// public string Description { get { return myDescription; } } [Storable] private Type myDataType; /// /// Gets the data type of the parameter. /// public Type DataType { get { return myDataType; } } [Storable] private VariableKind myKind; /// /// Gets the kind of the parameter (input parameter, output parameter,...). /// public VariableKind Kind { get { return myKind; } } [Storable] private bool myLocal; /// /// Gets or sets a boolean value, whether the variable is a local one. /// /// Calls in the setter. public bool Local { get { return myLocal; } set { if (myLocal != value) { myLocal = value; OnLocalChanged(); } } } /// /// Initializes a new instance of with actual and formal name "Anonymous", /// no description, a null data type and the local flag set to false. The type of /// the variable is an input parameter. /// public VariableInfo() { myActualName = "Anonymous"; myFormalName = "Anonymous"; myDescription = ""; myDataType = null; myKind = VariableKind.In; myLocal = false; } /// /// Initializes a new instance of with the given parameters. /// /// Calls .
/// The formal name is assigned to the actual name, too.
/// The formal name of the current instance. /// The description of the current instance. /// The data type of the parameter. /// The type of the parameter. public VariableInfo(string formalName, string description, Type dataType, VariableKind kind) : this() { myActualName = formalName; myFormalName = formalName; myDescription = description; myDataType = dataType; myKind = kind; } /// /// Creates a new instance of to represent the current instance /// visually. /// /// The created view as . public override IView CreateView() { return new VariableInfoView(this); } /// /// Clones the current instance (deep clone). /// /// Dictionary of all already cloned objects. (Needed to avoid cycles.) /// The cloned object as . public override ICloneable Clone(ICloner cloner) { VariableInfo clone = new VariableInfo(); cloner.AddClonedObject(this, clone); clone.myActualName = ActualName; clone.myFormalName = FormalName; clone.myDescription = Description; clone.myDataType = DataType; clone.myKind = Kind; clone.myLocal = Local; return clone; } /// public event EventHandler ActualNameChanged; /// /// Fires a new ActualNameChanged event. /// protected virtual void OnActualNameChanged() { if (ActualNameChanged != null) ActualNameChanged(this, new EventArgs()); } /// public event EventHandler LocalChanged; /// /// Fires a new LocalChanged event. /// protected virtual void OnLocalChanged() { if (LocalChanged != null) LocalChanged(this, new EventArgs()); } } }