#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; namespace HeuristicLab.Core { /// /// Represents a library of operators consisting of one . /// public class OperatorLibrary : ItemBase, IOperatorLibrary, IEditable { private IOperatorGroup myGroup; /// /// Gets the operator group of the current instance. /// public IOperatorGroup Group { get { return myGroup; } } /// /// Initializes a new instance of . /// public OperatorLibrary() { myGroup = new OperatorGroup(); } /// /// Creates a new instance of to display the current instance. /// /// The created view as . public override IView CreateView() { return new OperatorLibraryEditor(this); } /// /// Creates a new instance of to display the current instance. /// /// The created editor as . public virtual IEditor CreateEditor() { return new OperatorLibraryEditor(this); } /// /// Clones the current instance (deep clone). /// /// Deep clone through method of helper class /// . /// Dictionary of all already cloned objects. (Needed to avoid cycles.) /// The cloned object as . public override object Clone(IDictionary clonedObjects) { OperatorLibrary clone = new OperatorLibrary(); clonedObjects.Add(Guid, clone); clone.myGroup = (IOperatorGroup)Auxiliary.Clone(Group, clonedObjects); return clone; } #region Persistence Methods /// /// Saves the current instance as in the specified . /// /// Calls of base class .
/// The operator group is saved as a child node with the tag name OperatorGroup.
/// The (tag)name of the . /// The where to save the data. /// The dictionary of all already persisted objects. /// (Needed to avoid cycles.) /// The saved . public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary persistedObjects) { XmlNode node = base.GetXmlNode(name, document, persistedObjects); node.AppendChild(PersistenceManager.Persist("OperatorGroup", Group, document, persistedObjects)); return node; } /// /// Loads the persisted operator library from the specified . /// /// Calls of base class .
/// See for further information on how the data must be saved.
/// The where the operator library is saved. /// The dictionary of all already restored objects. /// (Needed to avoid cycles.) public override void Populate(XmlNode node, IDictionary restoredObjects) { base.Populate(node, restoredObjects); myGroup = (IOperatorGroup)PersistenceManager.Restore(node.SelectSingleNode("OperatorGroup"), restoredObjects); } #endregion } }