On 2011-08-07 21:28, dsimcha wrote:
Yeah, I was trying to wrap my head around the whole "key" concept. I
wasn't very successful. I also tried out Orange and filed a few bug
reports. It may be that Orange isn't the right tool for the job for MPI,
though modulo some bug fixing and polishing it could be extremely useful
in different cases with different sets of tradeoffs.

Every serialized value has a associated key. The key should be unique in its context but doesn't have to be unique in the whole document. A key can be explicitly chosen, in that case that key will be used, or the serialize can create a key (just a number that is incremented). Example:

class Foo
{
    int bar;
}

auto foo = new Foo;

When serializing "foo", it will get the key "0", chosen by the serializer. When "bar" is serialized it will use the explicit key "bar". This way the serialization process won't depend on the order of instance variables or struct members.

In addition to keys, all values have a associated id which is unique across the whole document. This is used for pointers and similar which reference other variables.

In addition to the bug reports I filed, why is it necessary to write any
serialization code to serialize through the base class? What's wrong
with just doing something like:

class Base {}
class Derived : Base {}

void main() {
auto serializer = new Serializer(new XMLArchive!());

// Introspect Derived and figure out all the details automatically.
serializer.register!(Derived);
}


I haven't thought about that, seems it would work. That will shorten the code a lot. This is a part that has not gone through the rewrite.

Note that all documentation on the wiki pages are outdated, they only refer to the first version, 0.0.1. The unit tests can be used as documentation to see how to use the new version and how it behaves.

--
/Jacob Carlborg

Reply via email to