Astron/Astron — pull request #111 by CFSworks (2013-10-24 17:31:44+00:00)
Title: StateServer: Use ordered maps to ensure dcfile-ordering on RAM fields.

(Tests pending on this. This pull request is intended for discussion and only includes code for ease of applying the change if we agree.)

Some applications may have very fickle objects that expect to receive state information in a specific order. In cases like this, the developer might want to use a certain ordering in their DC file to make sure the updates are applied in order. For example:

dclass DistributedHat {
uint8 hatType required broadcast;
uint8 hatColorIndex required broadcast;
};

In this case, required fields are sorted by their index, so the application is guaranteed to receive them from the SS in the dc file order.

However, in a case like:

dclass DistributedPlayer {
uint8 hasHat required broadcast;
uint8 hatType ram broadcast;
uint8 hatColorIndex ram broadcast;
};

...the State Server may conceivably reorder the RAM fields and put the color information before the type, causing the application to color a not-yet-loaded hat.

I feel like adding a specific ordering behavior to the Astron design is appropriate. I'm up for some discussion about whether it's better to do this sort of thing in the libraries or in the State Server itself, but I think the SS is the best place for such a change because it provides a guarantee that everything will follow this behavior.