[2] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Text;
|
---|
| 25 | using System.Xml;
|
---|
| 26 | using HeuristicLab.Core;
|
---|
| 27 | using HeuristicLab.Data;
|
---|
[1872] | 28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[2] | 29 |
|
---|
| 30 | namespace HeuristicLab.Logging {
|
---|
[1167] | 31 | /// <summary>
|
---|
| 32 | /// Represents a log object where to store a specific value that should be logged.
|
---|
| 33 | /// </summary>
|
---|
[2] | 34 | public class Log : ItemBase, IVisualizationItem {
|
---|
[1872] | 35 | [Storable]
|
---|
[2] | 36 | private ItemList myItems;
|
---|
[1167] | 37 | /// <summary>
|
---|
| 38 | /// Gets or sets the items of the current instance.
|
---|
| 39 | /// </summary>
|
---|
[2] | 40 | public ItemList Items {
|
---|
| 41 | get { return myItems; }
|
---|
| 42 | set { myItems = value; }
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 |
|
---|
[1167] | 46 | /// <summary>
|
---|
| 47 | /// Initializes a new instance of <see cref="Log"/>.
|
---|
| 48 | /// </summary>
|
---|
[2] | 49 | public Log() { }
|
---|
[1167] | 50 | /// <summary>
|
---|
| 51 | /// Initializes a new instance of <see cref="Log"/> with the given items.
|
---|
| 52 | /// </summary>
|
---|
| 53 | /// <param name="items">The list of items with which to initialize the current instance.</param>
|
---|
[2] | 54 | public Log(ItemList items) {
|
---|
| 55 | myItems = items;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
[1167] | 58 | /// <summary>
|
---|
| 59 | /// Clones the current instance (deep clone).
|
---|
| 60 | /// </summary>
|
---|
| 61 | /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
|
---|
| 62 | /// <see cref="Auxiliary"/>.</remarks>
|
---|
| 63 | /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param>
|
---|
| 64 | /// <returns>The cloned object as <see cref="Log"/>.</returns>
|
---|
[2] | 65 | public override object Clone(IDictionary<Guid, object> clonedObjects) {
|
---|
| 66 | Log clone = (Log)base.Clone(clonedObjects);
|
---|
| 67 | clone.myItems = (ItemList)Auxiliary.Clone(Items, clonedObjects);
|
---|
| 68 | return clone;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[1167] | 71 | /// <summary>
|
---|
| 72 | /// Creates an instance of <see cref="LogView"/> to represent the current instance visually.
|
---|
| 73 | /// </summary>
|
---|
| 74 | /// <returns>The created view as <see cref="LogView"/>.</returns>
|
---|
[2] | 75 | public override IView CreateView() {
|
---|
| 76 | return new LogView(this);
|
---|
| 77 | }
|
---|
| 78 |
|
---|
[1167] | 79 | /// <summary>
|
---|
| 80 | /// Occurs when the items have been changed.
|
---|
| 81 | /// </summary>
|
---|
[2] | 82 | public event EventHandler ItemsChanged;
|
---|
[1167] | 83 | /// <summary>
|
---|
| 84 | /// Fires a new <c>ItemsChanged</c> event.
|
---|
| 85 | /// </summary>
|
---|
[2] | 86 | protected virtual void OnItemsChanged() {
|
---|
| 87 | if (ItemsChanged != null)
|
---|
| 88 | ItemsChanged(this, new EventArgs());
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
| 91 | }
|
---|