Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/27/09 15:29:27 (16 years ago)
Author:
epitzer
Message:

Migrate HL.Constraints-3.3 to new persistence library. (#603)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Constraints/3.3/OrConstraint.cs

    r1529 r1672  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
     28using HeuristicLab.Persistence.Default.Decomposers.Storable;
    2829
    2930namespace HeuristicLab.Constraints {
     
    3233  /// </summary>
    3334  public class OrConstraint : ConstraintBase, IViewable {
     35
     36    [Storable]
    3437    private ItemList<IConstraint> clauses;
    3538    /// <summary>
     
    6770    public override bool Check(IItem data) {
    6871      bool result = false;
    69       for (int i = 0 ; i < clauses.Count ; i++) {
     72      for (int i = 0; i < clauses.Count; i++) {
    7073        result = clauses[i].Check(data);
    7174        if (result) return true;
     
    9699      return clone;
    97100    }
    98 
    99     #region persistence
    100     /// <summary>
    101     /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.
    102     /// </summary>
    103     /// <remarks>The sub-constraints are saved as a child node with tag name
    104     /// <c>Clauses</c>.</remarks>
    105     /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>
    106     /// <param name="document">The <see cref="XmlDocument"/> where the data is saved.</param>
    107     /// <param name="persistedObjects">The dictionary of all already persisted objects.
    108     /// (Needed to avoid cycles.)</param>
    109     /// <returns>The saved <see cref="XmlNode"/>.</returns>
    110     public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {
    111       XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    112       XmlNode clausesNode = PersistenceManager.Persist("Clauses", Clauses, document, persistedObjects);
    113       node.AppendChild(clausesNode);
    114 
    115       return node;
    116     }
    117 
    118     /// <summary>
    119     /// Loads the persisted constraint from the specified <paramref name="node"/>.
    120     /// </summary>
    121     /// <remarks>The constraint must be saved in a specific way, see <see cref="GetXmlNode"/> for
    122     /// more information.</remarks>
    123     /// <param name="node">The <see cref="XmlNode"/> where the instance is saved.</param>
    124     /// <param name="restoredObjects">The dictionary of all already restored objects.
    125     /// (Needed to avoid cycles.)</param>
    126     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    127       base.Populate(node, restoredObjects);
    128       clauses = (ItemList<IConstraint>)PersistenceManager.Restore(node.SelectSingleNode("Clauses"), restoredObjects);
    129     }
    130     #endregion persistence
    131101  }
    132102}
Note: See TracChangeset for help on using the changeset viewer.