Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/23/15 18:47:21 (9 years ago)
Author:
swagner
Message:

#2520: Worked on persistence overhaul

Location:
branches/PersistenceOverhaul/HeuristicLab.Persistence
Files:
19 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableAttribute.cs

    r12012 r13347  
    2121
    2222using System;
     23using System.Reflection;
    2324using System.Text;
    2425
     
    3738    Inherited = false)]
    3839  public class StorableAttribute : Attribute {
     40    public static bool IsStorable(MemberInfo memberInfo) {
     41      return Attribute.IsDefined(memberInfo, typeof(StorableAttribute), false);
     42    }
     43    public static StorableAttribute GetStorableAttribute(MemberInfo memberInfo) {
     44      return (StorableAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(StorableAttribute), false);
     45    }
    3946
    4047    /// <summary>
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableClassAttribute.cs

    r12012 r13347  
    3636    public StorableClassType Type { get; private set; }
    3737
     38    public Guid Guid { get; private set; }
     39    public bool Released { get; set; }
     40
    3841    /// <summary>
    3942    /// Mark a class to be serialize by the <c>StorableSerizlier</c>
    4043    /// </summary>
    4144    /// <param name="type">The storable class type.</param>
    42     public StorableClassAttribute(StorableClassType type) {
     45    public StorableClassAttribute(StorableClassType type, string guid) {
    4346      Type = type;
     47      Guid = new Guid(guid);
     48      Released = false;
    4449    }
    4550
     
    6166    }
    6267
     68    public static StorableClassAttribute GetStorableClassAttribute(Type type) {
     69      return (StorableClassAttribute)Attribute.GetCustomAttribute(type, typeof(StorableClassAttribute), false);
     70    }
     71
    6372  }
    6473}
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableConstructorAttribute.cs

    r12012 r13347  
    2121
    2222using System;
     23using System.Reflection;
    2324
    2425namespace HeuristicLab.Persistence.Default.CompositeSerializers.Storable {
     
    3435  /// </summary>
    3536  [AttributeUsage(AttributeTargets.Constructor, Inherited = false, AllowMultiple = false)]
    36   public sealed class StorableConstructorAttribute : Attribute { }
     37  public sealed class StorableConstructorAttribute : Attribute {
     38    public static bool IsStorableConstructor(ConstructorInfo constructorInfo) {
     39      return Attribute.IsDefined(constructorInfo, typeof(StorableConstructorAttribute));
     40    }
     41  }
    3742}
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableHookAttribute.cs

    r12012 r13347  
    2121
    2222using System;
     23using System.Linq;
     24using System.Reflection;
    2325
    2426namespace HeuristicLab.Persistence.Default.CompositeSerializers.Storable {
     
    5052  [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = true)]
    5153  public sealed class StorableHookAttribute : Attribute {
     54    public static bool IsStorableHook(MethodInfo methodInfo) {
     55      return Attribute.IsDefined(methodInfo, typeof(StorableHookAttribute), false);
     56    }
     57    public static StorableHookAttribute[] GetStorableHookAttributes(MethodInfo methodInfo) {
     58      return Attribute.GetCustomAttributes(methodInfo, false).OfType<StorableHookAttribute>().ToArray();
     59    }
    5260
    5361    private readonly HookType hookType;
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/ComponentInfo.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/Index.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3333
    3434    public Index() {
    35       indexes = new Dictionary<T, uint>();
    36       values = new Dictionary<uint, T>();
    37       nextIndex = 1;
     35      this.indexes = new Dictionary<T, uint>();
     36      this.values = new Dictionary<uint, T>();
     37      nextIndex = 0;
    3838    }
    39     public Index(IEnumerable<Tuple<uint, T>> values)
     39    public Index(IEnumerable<T> values)
    4040      : this() {
    4141      foreach (var value in values) {
    42         this.indexes.Add(value.Item2, value.Item1);
    43         this.values.Add(value.Item1, value.Item2);
     42        this.indexes.Add(value, nextIndex);
     43        this.values.Add(nextIndex, value);
    4444        nextIndex++;
    4545      }
     
    4747
    4848    public uint GetIndex(T value) {
    49       uint index = 0;
    50       indexes.TryGetValue(value, out index);
    51       if (index == 0) {
     49      uint index;
     50      if (!indexes.TryGetValue(value, out index)) {
    5251        index = nextIndex;
    5352        nextIndex++;
     
    6059      return values[index];
    6160    }
    62     public IEnumerable<Tuple<uint, T>> GetValues() {
    63       return values.Select(x => new Tuple<uint, T>(x.Key, x.Value));
     61    public IEnumerable<T> GetValues() {
     62      return values.Values;
    6463    }
    6564  }
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/Mapper.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using HeuristicLab.Persistence.Data;
    2625using HeuristicLab.PluginInfrastructure;
     26using Google.ProtocolBuffers;
     27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728
    2829namespace HeuristicLab.Persistence {
    29   public sealed class PersistenceMapper {
    30     private ShortIndex<ITransformer> transformers;
     30  public sealed class Mapper {
     31    private Index<ITransformer> transformers;
    3132    private Dictionary<Type, TypeInfo> typeInfos;
    32     private ShortIndex<Type> types;
     33    private Index<Type> types;
    3334    private Index<string> strings;
    34     private Index<PersistenceData> data;
    35     private Dictionary<object, uint> dataCache;
     35    private Index<Box> boxes;
     36    private Dictionary<object, uint> boxCache;
    3637    private Dictionary<uint, object> objectCache;
    3738
    38     public long Nodes { get; private set; }
     39    public long BoxCount { get; private set; }
    3940
    40     public PersistenceMapper() {
    41       transformers = new ShortIndex<ITransformer>();
     41    public Mapper() {
     42      transformers = new Index<ITransformer>();
    4243      typeInfos = new Dictionary<Type, TypeInfo>();
    43       types = new ShortIndex<Type>();
     44      types = new Index<Type>();
    4445      strings = new Index<string>();
    45       data = new Index<PersistenceData>();
    46       dataCache = new Dictionary<object, uint>(new ReferenceEqualityComparer<object>());
     46      boxes = new Index<Box>();
     47      boxCache = new Dictionary<object, uint>(new ReferenceEqualityComparer<object>());
    4748      objectCache = new Dictionary<uint, object>();
    4849
    49       Nodes = 0;
     50      BoxCount = 0;
    5051
    5152      foreach (var transformer in ApplicationManager.Manager.GetInstances<ITransformer>().OrderBy(x => x.Order)) {
    52         ushort id = transformers.GetIndex(transformer);
    53         transformer.Initialize(id);
     53        transformer.Initialize(transformers.GetIndex(transformer));
    5454      }
    5555    }
     
    5757    public TypeInfo GetTypeInfo(Type type) {
    5858      TypeInfo typeInfo;
    59       typeInfos.TryGetValue(type, out typeInfo);
    60       if (typeInfo == null) {
    61         var transformer = transformers.GetValues().Select(x => x.Item2).Where(x => x.CanTransformType(type)).FirstOrDefault();
     59      if (!typeInfos.TryGetValue(type, out typeInfo)) {
     60        var transformer = transformers.GetValues().Where(x => x.CanTransformType(type)).FirstOrDefault();
    6261        typeInfo = new TypeInfo(type, transformer);
    6362        typeInfos.Add(type, typeInfo);
     
    7271    }
    7372
    74     public ushort GetTypeId(Type type) {
     73    public uint GetTypeId(Type type) {
    7574      return types.GetIndex(type);
    7675    }
    77     public Type GetType(ushort typeId) {
     76    public Type GetType(uint typeId) {
    7877      return types.GetValue(typeId);
    7978    }
     
    8685    }
    8786
    88     public void Cache(object o, PersistenceData data) {
    89       dataCache.Add(o, this.data.GetIndex(data));
     87    public uint GetBoxId(object o) {
     88      uint boxId;
     89      if (boxCache.TryGetValue(o, out boxId)) return boxId;
     90
     91      if (o == null)
     92        boxId = boxes.GetIndex(null);
     93      else {
     94        var type = o.GetType();
     95        var typeInfo = GetTypeInfo(type);
     96        if (typeInfo.Transformer == null) throw new ArgumentException("Cannot serialize object of type " + o.GetType());
     97        BoxCount++;
     98        typeInfo.Used++;
     99        boxId = boxes.GetIndex(typeInfo.Transformer.ToBox(o, this));
     100      }
     101      boxCache.Add(o, boxId);
     102      return boxId;
    90103    }
    91     public void Cache(PersistenceData data, object o) {
    92       objectCache.Add(this.data.GetIndex(data), o);
    93     }
     104    public object GetObject(uint boxId) {
     105      object o;
     106      if (objectCache.TryGetValue(boxId, out o)) return o;
    94107
    95     public uint GetDataId(object o) {
    96       if (o == null) return 0;
    97       if (dataCache.ContainsKey(o)) return dataCache[o];
    98 
    99       var type = o.GetType();
    100       var typeInfo = GetTypeInfo(type);
    101       if (typeInfo.Transformer == null) throw new ArgumentException("Cannot serialize object of type " + o.GetType());
    102       Nodes++;
    103       typeInfo.Used++;
    104       return data.GetIndex(typeInfo.Transformer.ToData(o, this));
    105     }
    106     public object GetObject(uint dataId) {
    107       if (dataId == 0) return null;
    108       if (objectCache.ContainsKey(dataId)) return objectCache[dataId];
    109       var data = this.data.GetValue(dataId);
    110       var transformer = transformers.GetValue(data.TransformerId);
    111       return transformer.ToObject(data, this);
     108      var box = this.boxes.GetValue(boxId);
     109      if (box == null)
     110        o = null;
     111      else {
     112        var transformer = transformers.GetValue(box.TransformerId);
     113        o = transformer.ToObject(box, this);
     114      }
     115      objectCache.Add(boxId, o);
     116      return o;
    112117    }
    113118
     
    116121    }
    117122
    118     public static PersistenceMapper mapper;
    119     public static PersistenceBundle ToBundle(object o) {
    120       mapper = new PersistenceMapper();
    121       var bundle = new PersistenceBundle();
    122       bundle.RootId = mapper.GetDataId(o);
    123       bundle.TransformerGuids = mapper.transformers.GetValues().Select(x => new Tuple<ushort, Guid>(x.Item1, x.Item2.Guid)).ToArray();
    124       bundle.TypeNames = mapper.types.GetValues().Select(x => new Tuple<ushort, string>(x.Item1, x.Item2.AssemblyQualifiedName)).ToArray();
    125       bundle.Strings = mapper.strings.GetValues().ToArray();
    126       bundle.Data = mapper.data.GetValues().ToArray();
    127       return bundle;
     123    public static Bundle ToBundle(object o) {
     124      var mapper = new Mapper();
     125      var bundle = Bundle.CreateBuilder();
     126      bundle.RootBoxId = mapper.GetBoxId(o);
     127      bundle.AddRangeTransformerGuids(mapper.transformers.GetValues().Select(x => x.Guid).Select(x => ByteString.CopyFrom(x.ToByteArray())));
     128      bundle.AddRangeTypeGuids(mapper.types.GetValues().Select(x => mapper.typeInfos[x].StorableClassAttribute.Guid).Select(x => ByteString.CopyFrom(x.ToByteArray())));
     129      bundle.AddRangeStrings(mapper.strings.GetValues());
     130      bundle.AddRangeBoxes(mapper.boxes.GetValues());
     131      return bundle.Build();
    128132    }
    129     public static object ToObject(PersistenceBundle bundle) {
    130       mapper = new PersistenceMapper();
    131       mapper.types = new ShortIndex<Type>(bundle.TypeNames.Select(x => new Tuple<ushort, Type>(x.Item1, Type.GetType(x.Item2, true))));
    132       mapper.strings = new Index<string>(bundle.Strings);
    133       mapper.data = new Index<PersistenceData>(bundle.Data);
    134       mapper.transformers = new ShortIndex<ITransformer>(
    135         bundle.TransformerGuids.Select(x => new Tuple<ushort, ITransformer>(
    136           x.Item1,
    137           mapper.transformers.GetValues().Select(y => y.Item2).Where(y => y.Guid == x.Item2).First())
    138         )
    139       );
    140       foreach (var type in mapper.types.GetValues().Select(x => x.Item2))
     133    public static object ToObject(Bundle bundle) {
     134      var types = new Dictionary<Guid, Type>();
     135      foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) {
     136        foreach (var t in asm.GetTypes().Where(x => StorableClassAttribute.IsStorableClass(x)))
     137          types.Add(StorableClassAttribute.GetStorableClassAttribute(t).Guid, t);
     138      }
     139
     140      var mapper = new Mapper();
     141      mapper.types = new Index<Type>(bundle.TypeGuidsList.Select(x => new Guid(x.ToByteArray())).Select(x => types[x]));
     142      mapper.strings = new Index<string>(bundle.StringsList);
     143      mapper.boxes = new Index<Box>(bundle.BoxesList);
     144      mapper.transformers = new Index<ITransformer>(bundle.TransformerGuidsList.Select(x => new Guid(x.ToByteArray())).Select(x => mapper.transformers.GetValues().First(y => y.Guid == x)));
     145      foreach (var type in mapper.types.GetValues())
    141146        mapper.typeInfos.Add(type, new TypeInfo(type));
    142147
    143       return mapper.GetObject(bundle.RootId);
     148      return mapper.GetObject(bundle.RootBoxId);
    144149    }
    145150  }
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/ProtoBufSerializer.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System.IO;
    23 using HeuristicLab.Persistence.Data;
    2423
    2524namespace HeuristicLab.Persistence {
    2625  public sealed class ProtoBufSerializer : Serializer {
    27     protected override void SerializePersistenceBundle(PersistenceBundle bundle, Stream stream) {
    28       ProtoBuf.Serializer.Serialize<PersistenceBundle>(stream, bundle);
     26    protected override void SerializeBundle(Bundle bundle, Stream stream) {
     27      bundle.WriteTo(stream);
    2928    }
    3029
    31     protected override PersistenceBundle DeserializePersistenceBundle(Stream stream) {
    32       return ProtoBuf.Serializer.Deserialize<PersistenceBundle>(stream);
     30    protected override Bundle DeserializeBundle(Stream stream) {
     31      return Bundle.ParseFrom(stream);
    3332    }
    3433  }
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/ReferenceEqualityComparer.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/Serializer.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using System.IO;
    2323using System.IO.Compression;
    24 using HeuristicLab.Persistence.Data;
    2524
    2625namespace HeuristicLab.Persistence {
    2726  public abstract class Serializer : ISerializer {
    2827    public virtual void Serialize(object o, Stream stream) {
    29       SerializePersistenceBundle(PersistenceMapper.ToBundle(o), stream);
     28      SerializeBundle(Mapper.ToBundle(o), stream);
    3029    }
    3130    public virtual void Serialize(object o, string path) {
     
    4443      }
    4544    }
    46     protected abstract void SerializePersistenceBundle(PersistenceBundle bundle, Stream stream);
     45    protected abstract void SerializeBundle(Bundle bundle, Stream stream);
    4746
    4847    public virtual object Deserialize(Stream stream) {
    49       return PersistenceMapper.ToObject(DeserializePersistenceBundle(stream));
     48      return Mapper.ToObject(DeserializeBundle(stream));
    5049    }
    5150    public virtual object Deserialize(string path) {
     
    6362      }
    6463    }
    65     protected abstract PersistenceBundle DeserializePersistenceBundle(Stream stream);
     64    protected abstract Bundle DeserializeBundle(Stream stream);
    6665  }
    6766}
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/StorableAttribute.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/StorableClassAttribute.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727  public sealed class StorableClassAttribute : Attribute {
    2828    public Guid Guid { get; private set; }
    29     public int Version { get; set; }
    3029    public bool Released { get; set; }
    3130
    3231    public StorableClassAttribute(string guid) {
    3332      Guid = new Guid(guid);
    34       Version = 0;
    3533      Released = false;
    3634    }
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/Transformer.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
    23 using HeuristicLab.Persistence.Data;
    2423
    2524namespace HeuristicLab.Persistence {
    26   internal abstract class TransformerBase : ITransformer {
     25  internal abstract class Transformer : ITransformer {
    2726    public Guid Guid { get; private set; }
    28     public ushort Id { get; private set; }
    29     public ushort Order { get; private set; }
     27    public uint Id { get; private set; }
     28    public uint Order { get; private set; }
    3029
    31     protected TransformerBase() {
     30    protected Transformer() {
    3231      Guid = TransformerAttribute.GetGuid(this.GetType());
    3332      Order = TransformerAttribute.GetOrder(this.GetType());
     
    3534    }
    3635
    37     public void Initialize(ushort id) {
     36    public void Initialize(uint id) {
    3837      Id = id;
    3938    }
    4039
    4140    public abstract bool CanTransformType(Type type);
    42     public abstract PersistenceData ToData(object o, PersistenceMapper mapper);
    43     public abstract object ToObject(PersistenceData data, PersistenceMapper mapper);
     41    public abstract Box ToBox(object o, Mapper mapper);
     42    public abstract object ToObject(Box box, Mapper mapper);
    4443  }
    4544}
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/TransformerAttribute.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626  public sealed class TransformerAttribute : Attribute {
    2727    public Guid Guid { get; private set; }
    28     public ushort Order { get; private set; }
     28    public uint Order { get; private set; }
    2929
    30     public TransformerAttribute(string guid, ushort order) {
     30    public TransformerAttribute(string guid, uint order) {
    3131      Guid = new Guid(guid);
    3232      Order = order;
     
    4242      return GetTransformerAttribute(type).Guid;
    4343    }
    44     public static ushort GetOrder(Type type) {
     44    public static uint GetOrder(Type type) {
    4545      return GetTransformerAttribute(type).Order;
    4646    }
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Core/TypeInfo.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/HeuristicLab.Persistence-4.0.csproj

    r13326 r13347  
    4646  </ItemGroup>
    4747  <ItemGroup>
     48    <Compile Include="Core\ComponentInfo.cs" />
     49    <Compile Include="Core\Index.cs" />
     50    <Compile Include="Core\Mapper.cs" />
     51    <Compile Include="Core\ProtoBufSerializer.cs" />
     52    <Compile Include="Core\ReferenceEqualityComparer.cs" />
     53    <Compile Include="Core\Serializer.cs" />
     54    <Compile Include="Core\Transformer.cs" />
     55    <Compile Include="Core\TransformerAttribute.cs" />
     56    <Compile Include="Core\TypeInfo.cs" />
     57    <Compile Include="ISerializer.cs" />
     58    <Compile Include="ITransformer.cs" />
    4859    <Compile Include="Plugin.cs" />
    4960    <Compile Include="Properties\AssemblyInfo.cs" />
     
    6273      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    6374      <Private>False</Private>
     75    </ProjectReference>
     76    <ProjectReference Include="..\3.3\HeuristicLab.Persistence-3.3.csproj">
     77      <Project>{102bc7d3-0ef9-439c-8f6d-96ff0fdb8e1b}</Project>
     78      <Name>HeuristicLab.Persistence-3.3</Name>
    6479    </ProjectReference>
    6580  </ItemGroup>
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/ISerializer.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/ITransformer.cs

    r13326 r13347  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
    23 using HeuristicLab.Persistence.Data;
    2423
    2524namespace HeuristicLab.Persistence {
    2625  public interface ITransformer {
    2726    Guid Guid { get; }
    28     ushort Id { get; }
    29     ushort Order { get; }
     27    uint Id { get; }
     28    uint Order { get; }
    3029
    31     void Initialize(ushort id);
     30    void Initialize(uint id);
    3231
    3332    bool CanTransformType(Type type);
    34     PersistenceData ToData(object o, PersistenceMapper mapper);
    35     object ToObject(PersistenceData data, PersistenceMapper mapper);
     33    Box ToBox(object o, Mapper mapper);
     34    object ToObject(Box box, Mapper mapper);
    3635  }
    3736}
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Plugin.cs.frame

    r13326 r13347  
    2929  [PluginFile("HeuristicLab.Persistence-4.0.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.ProtobufCS", "2.4.1.473")]
     31  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    3132  public class HeuristicLabPersistencePlugin : PluginBase { }
    3233}
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Properties/AssemblyInfo.cs.frame

    r13326 r13347  
    2020#endregion
    2121
     22using System;
    2223using System.Reflection;
    2324using System.Runtime.CompilerServices;
     
    5354[assembly: AssemblyVersion("4.0.0.0")]
    5455[assembly: AssemblyFileVersion("4.0.0.$WCREV$")]
     56
     57[assembly: CLSCompliant(false)]
  • branches/PersistenceOverhaul/HeuristicLab.Persistence/4.0/Protos/PersistenceMessages.proto

    r13326 r13347  
    11package HeuristicLab.Persistence;
    22
    3 message PersistenceBox {
    4   required uint32 TransformerId = 1;
    5   required uint32 TypeId = 2;
     3message Bundle {
     4  repeated bytes transformer_guids = 1;
     5  repeated bytes type_guids = 2;
     6  repeated string strings = 3;
     7  repeated Box boxes = 4;
     8  required uint32 root_box_id = 5;
    69}
     10
     11message Box {
     12  optional uint32 transformer_id = 1;
     13  optional uint32 type_id = 2;
     14
     15  extensions 100 to max;
     16}
     17
     18// value boxes
     19message BoolBox {
     20  extend Box {
     21    required BoolBox bool = 100;
     22  }
     23  required bool value = 1;
     24}
     25message IntBox {
     26  extend Box {
     27    required IntBox int = 101;
     28  }
     29  required int32 value = 1;
     30}
     31message LongBox {
     32  extend Box {
     33    required LongBox long = 102;
     34  }
     35  required int64 value = 1;
     36}
     37message UnsignedIntBox {
     38  extend Box {
     39    required UnsignedIntBox unsigned_int = 103;
     40  }
     41  required uint32 value = 1;
     42}
     43message UnsignedLongBox {
     44  extend Box {
     45    required UnsignedLongBox unsigned_long = 104;
     46  }
     47  required uint64 value = 1;
     48}
     49message FloatBox {
     50  extend Box {
     51    required FloatBox float = 105;
     52  }
     53  required float value = 1;
     54}
     55message DoubleBox {
     56  extend Box {
     57    required DoubleBox double = 106;
     58  }
     59  required double value = 1;
     60}
     61message StringBox {
     62  extend Box {
     63    required StringBox string = 107;
     64  }
     65  required string value = 1;
     66}
     67message BytesBox {
     68  extend Box {
     69    required BytesBox bytes = 108;
     70  }
     71  required bytes value = 1;
     72}
     73
     74// array boxes
     75message ArrayBox {
     76  extend Box {
     77    required ArrayBox array = 120;
     78  }
     79  optional uint32 element_type_id = 1;
     80
     81  extensions 100 to max;
     82}
     83message BoolArrayBox {
     84  extend ArrayBox {
     85    required BoolArrayBox bool_array = 100;
     86  }
     87  repeated bool values = 1 [packed = true];
     88}
     89message IntArrayBox {
     90  extend ArrayBox {
     91    required IntArrayBox int_array = 101;
     92  }
     93  repeated int32 values = 1 [packed = true];
     94}
     95
     96// matrix boxes
     97message MatrixBox {
     98  extend Box {
     99    required MatrixBox matrix = 140;
     100  }
     101  optional uint32 element_type_id = 1;
     102  repeated uint32 lengths = 2 [packed = true];
     103
     104  extensions 100 to max;
     105}
     106message BoolMatrixBox {
     107  extend MatrixBox {
     108    required BoolMatrixBox bool_matrix = 100;
     109  }
     110  repeated bool values = 1 [packed = true];
     111}
     112message IntMatrixBox {
     113  extend MatrixBox {
     114    required IntMatrixBox int_matrix = 101;
     115  }
     116  repeated int32 values = 1 [packed = true];
     117}
     118
     119// composite boxes
     120message DictionaryBox {
     121  extend Box {
     122    required DictionaryBox dictionary = 160;
     123  }
     124  repeated uint32 key_ids = 1 [packed = true];
     125  repeated uint32 value_ids = 2 [packed = true];
     126  required uint32 comparer_id = 3;
     127}
Note: See TracChangeset for help on using the changeset viewer.