#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.Core; using HeuristicLab.Data; namespace HeuristicLab.Logging { /// /// Represents a log object where to store a specific value that should be logged. /// public class Log : ItemBase, IVisualizationItem { private ItemList myItems; /// /// Gets or sets the items of the current instance. /// public ItemList Items { get { return myItems; } set { myItems = value; } } /// /// Initializes a new instance of . /// public Log() { } /// /// Initializes a new instance of with the given items. /// /// The list of items with which to initialize the current instance. public Log(ItemList items) { myItems = items; } /// /// Clones the current instance (deep clone). /// /// Deep clone through method of helper class /// . /// Dictionary of all already clone objects. (Needed to avoid cycles.) /// The cloned object as . public override object Clone(IDictionary clonedObjects) { Log clone = (Log)base.Clone(clonedObjects); clone.myItems = (ItemList)Auxiliary.Clone(Items, clonedObjects); return clone; } /// /// Creates an instance of to represent the current instance visually. /// /// The created view as . public override IView CreateView() { return new LogView(this); } /// /// Occurs when the items have been changed. /// public event EventHandler ItemsChanged; /// /// Fires a new ItemsChanged event. /// protected virtual void OnItemsChanged() { if (ItemsChanged != null) ItemsChanged(this, new EventArgs()); } #region Persistence Methods /// /// Saves the current instance as in the specified . /// /// The items of the current instance are saved as a child node with the tag name /// Items. /// 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("Items", Items, document, persistedObjects)); return node; } /// /// Loads the persisted item from the specified . /// /// Has to be saved in a special way, see for further information. /// The where the Log 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); myItems = (ItemList)PersistenceManager.Restore(node.SelectSingleNode("Items"), restoredObjects); } #endregion } }