Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Logging/3.3/Log.cs @ 2913

Last change on this file since 2913 was 2526, checked in by swagner, 15 years ago

Refactored cloning (#806)

File size: 2.8 KB
Line 
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
22using System;
23using System.Collections.Generic;
24using System.Text;
25using System.Xml;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Logging {
31  /// <summary>
32  /// Represents a log object where to store a specific value that should be logged.
33  /// </summary>
34  public class Log : ItemBase, IVisualizationItem {
35    [Storable]
36    private ItemList myItems;
37    /// <summary>
38    /// Gets or sets the items of the current instance.
39    /// </summary>
40    public ItemList Items {
41      get { return myItems; }
42      set { myItems = value; }
43    }
44
45
46    /// <summary>
47    /// Initializes a new instance of <see cref="Log"/>.
48    /// </summary>
49    public Log() { }
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>
54    public Log(ItemList items) {
55      myItems = items;
56    }
57
58    /// <summary>
59    /// Clones the current instance (deep clone).
60    /// </summary>
61    /// <remarks>Deep clone through <see cref="cloner.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>
65    public override IItem Clone(ICloner cloner) {
66      Log clone = (Log)base.Clone(cloner);
67      clone.myItems = (ItemList)cloner.Clone(Items);
68      return clone;
69    }
70
71    /// <summary>
72    /// Occurs when the items have been changed.
73    /// </summary>
74    public event EventHandler ItemsChanged;
75    /// <summary>
76    /// Fires a new <c>ItemsChanged</c> event.
77    /// </summary>
78    protected virtual void OnItemsChanged() {
79      if (ItemsChanged != null)
80        ItemsChanged(this, new EventArgs());
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.