Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/19/15 09:57:06 (9 years ago)
Author:
mkommend
Message:

#2472: Moved cloning and persistence code near the default ctor for all new GP problems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/EvenParityProblem.cs

    r13267 r13269  
    5858    }
    5959
     60    #region item cloning and persistence
     61    // persistence
     62    [StorableConstructor]
     63    private EvenParityProblem(bool deserializing) : base(deserializing) { }
     64    [StorableHook(HookType.AfterDeserialization)]
     65    private void AfterDeserialization() {
     66      RegisterEventHandlers();
     67    }
     68
     69    // cloning
     70    private EvenParityProblem(EvenParityProblem original, Cloner cloner)
     71      : base(original, cloner) {
     72      RegisterEventHandlers();
     73    }
     74    public override IDeepCloneable Clone(Cloner cloner) {
     75      return new EvenParityProblem(this, cloner);
     76    }
     77    #endregion
     78
    6079    public EvenParityProblem()
    6180      : base() {
     
    109128
    110129      switch (node.Symbol.Name) {
    111         case "AND":  return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x & y);
    112         case "OR":   return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x | y);
     130        case "AND": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x & y);
     131        case "OR": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => x | y);
    113132        case "NAND": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => !(x & y));
    114         case "NOR":  return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => !(x | y));
     133        case "NOR": return binaryEval(node.GetSubtree(0), node.GetSubtree(1), (x, y) => !(x | y));
    115134        default: {
    116135            byte bitPos;
     
    126145    }
    127146
    128     #region item cloning and persistence
    129     // persistence
    130     [StorableConstructor]
    131     private EvenParityProblem(bool deserializing) : base(deserializing) { }
    132 
    133     [StorableHook(HookType.AfterDeserialization)]
    134     private void AfterDeserialization() {
    135       RegisterEventHandlers();
    136     }
    137 
    138     // cloning
    139     private EvenParityProblem(EvenParityProblem original, Cloner cloner)
    140       : base(original, cloner) {
    141       RegisterEventHandlers();
    142     }
    143     public override IDeepCloneable Clone(Cloner cloner) {
    144       return new EvenParityProblem(this, cloner);
    145     }
    146     #endregion
    147 
    148147    #region events
    149148    private void RegisterEventHandlers() {
Note: See TracChangeset for help on using the changeset viewer.