Mercurial > projects > orange
annotate orange/serialization/RegisterWrapper.d @ 15:9f6064f9505a
Changed from archive to serializer in the register wrappers.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 08 Aug 2010 21:26:11 +0200 |
parents | 470ab5270d0c |
children | 78e5fef4bbf2 |
rev | line source |
---|---|
0 | 1 /** |
2 * Copyright: Copyright (c) 2010 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Feb 4, 2010 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module orange.serialization.RegisterWrapper; | |
8 | |
9 import orange.serialization.archives.Archive; | |
10 import orange.serialization.Serializer; | |
11 | |
12 class RegisterBase | |
13 { | |
14 | |
15 } | |
16 | |
15
9f6064f9505a
Changed from archive to serializer in the register wrappers.
Jacob Carlborg <doob@me.com>
parents:
4
diff
changeset
|
17 class SerializeRegisterWrapper (T, SerializerType) : RegisterBase |
0 | 18 { |
19 private alias SerializerType.DataType DataType; | |
20 private void delegate (T, SerializerType, DataType) dg; | |
4
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
21 private bool isDelegate; |
0 | 22 |
23 this (void delegate (T, SerializerType, DataType) dg) | |
24 { | |
4
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
25 isDelegate = true; |
0 | 26 this.dg = dg; |
27 } | |
28 | |
29 this (void function (T, SerializerType, DataType) func) | |
30 { | |
4
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
31 dg.funcptr = func; |
0 | 32 } |
33 | |
34 void opCall (T value, SerializerType archive, DataType key) | |
35 { | |
4
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
36 if (dg && isDelegate) |
0 | 37 dg(value, archive, key); |
38 | |
4
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
39 else if (dg) |
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
40 dg.funcptr(value, archive, key); |
0 | 41 } |
42 } | |
43 | |
15
9f6064f9505a
Changed from archive to serializer in the register wrappers.
Jacob Carlborg <doob@me.com>
parents:
4
diff
changeset
|
44 class DeserializeRegisterWrapper (T, SerializerType) : RegisterBase |
0 | 45 { |
46 private alias SerializerType.DataType DataType; | |
47 private void delegate (ref T, SerializerType, DataType) dg; | |
4
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
48 private bool isDelegate; |
0 | 49 |
50 this (void delegate (ref T, SerializerType, DataType) dg) | |
51 { | |
4
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
52 isDelegate = true; |
0 | 53 this.dg = dg; |
54 } | |
55 | |
56 this (void function (ref T, SerializerType, DataType) func) | |
57 { | |
4
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
58 dg.funcptr = func; |
0 | 59 } |
60 | |
61 void opCall (ref T value, SerializerType archive, DataType key) | |
62 { | |
4
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
63 if (dg && isDelegate) |
0 | 64 dg(value, archive, key); |
65 | |
4
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
66 if (dg) |
470ab5270d0c
Simplified the implementation of RegisterWrapper. Fixed: the base class of an object was not serialized
Jacob Carlborg <doob@me.com>
parents:
0
diff
changeset
|
67 dg.funcptr(value, archive, key); |
0 | 68 } |
69 } |