Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/28/09 16:05:09 (15 years ago)
Author:
epitzer
Message:

Migrate HL.Routing.TSP to new persistence library. (#603)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Routing.TSP/3.3/TSPTour.cs

    r1530 r1699  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Permutation;
     29using HeuristicLab.Persistence.Default.Decomposers.Storable;
    2930
    3031namespace HeuristicLab.Routing.TSP {
     
    3334  /// </summary>
    3435  public class TSPTour : ItemBase, IVisualizationItem {
     36
     37    [Storable]
    3538    private DoubleMatrixData myCoordinates;
    3639    /// <summary>
     
    4144      set { myCoordinates = value; }
    4245    }
     46
     47    [Storable]
    4348    private Permutation.Permutation myTour;
    4449    /// <summary>
     
    109114      if (TourChanged != null)
    110115        TourChanged(this, new EventArgs());
    111     }
    112 
    113     #region Persistence Methods
    114     /// <summary>
    115     /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.
    116     /// </summary>
    117     /// <remarks>Calls <see cref="StorableBase.GetXmlNode"/> of base class <see cref="ItemBase"/>. <br/>
    118     /// The coordinates and the tour are saved as a child node with the tag names <c>Coordinates</c> and
    119     /// <c>Tour</c>.</remarks>
    120     /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>
    121     /// <param name="document">The <see cref="XmlDocument"/> where to save the data.</param>
    122     /// <param name="persistedObjects">The dictionary of all already persisted objects.
    123     /// (Needed to avoid cycles.)</param>
    124     /// <returns>The saved <see cref="XmlNode"/>.</returns>
    125     public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
    126       XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    127       node.AppendChild(PersistenceManager.Persist("Coordinates", Coordinates, document, persistedObjects));
    128       node.AppendChild(PersistenceManager.Persist("Tour", Tour, document, persistedObjects));
    129       return node;
    130     }
    131     /// <summary>
    132     /// Loads the persisted TSP tour from the specified <paramref name="node"/>.
    133     /// </summary>
    134     /// <remarks>Calls <see cref="StorableBase.Populate"/> of base class
    135     /// <see cref="ItemBase"/>.<br/>
    136     /// The coordinates and the tour must be saved as child nodes with the tag names <c>Coordinates</c>
    137     /// and <c>Tour</c> (see <see cref="GetXmlNode"/>).</remarks>
    138     /// <param name="node">The <see cref="XmlNode"/> where the TSP tour is saved.</param>
    139     /// <param name="restoredObjects">A dictionary of all already restored objects. (Needed to avoid cycles.)</param>
    140     public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
    141       base.Populate(node, restoredObjects);
    142       myCoordinates = (DoubleMatrixData)PersistenceManager.Restore(node.SelectSingleNode("Coordinates"), restoredObjects);
    143       myTour = (Permutation.Permutation)PersistenceManager.Restore(node.SelectSingleNode("Tour"), restoredObjects);
    144     }
    145     #endregion
     116    }   
    146117  }
    147118}
Note: See TracChangeset for help on using the changeset viewer.