Started working on the modeller meta data and ran into some issues that somebody might have a good solution for.
The idea for the "model connectors" is to have them split into two parts. A "connector template" with a name, length and width that is referenced by all connector instances. Each connector instance is attached to a certain position at a certain face of the model. Since I want to allow editing of the connector templates, but don't want to go over all models and update them, connector instances only refer to the template instead of copying its values. So apart from the attributes listed above, there needs to be a immutable id that links connector templates and instances. So my initial thought was, to start counting from 1 and thus give each connector a unique integer value as its id. But here's the problem: if I create some connector templates and somebody else as well, they end up having the same id and things will get ugly when we both try to commit and merge our connector template data file. My idea would be to instead get a hash of, say, the host name where the editor runs and XOR that with the simple counter to get values that are locally and globally unique. Sounds about right? A similar issue appears with objects placed on the map. In the map data file, these objects are referenced by an id that is currently a simple integer as well. So again, if two developers add stuff to their map, they are in big trouble when trying to merge their changes. In addition, editing the map will actually change the ids of map objects, as their "order" in the map structure changes. Again, it would be desirable if there was support for distributed map editing, in that a) the same object always gets the same id, no matter where and when it gets added b) different objects always get a different id. A hash of the object path and file name might work, but that means it will no longer be possible to simply rename the file or move it to a different location. Any object attributes are also out of the question, as those might change as well. The only thing I can think of right now would be to create an immutable id together with the map object. Just as with the connector templates above, only one would actually create the model (we'll have that much coordination), but multiple people could use them to build different parts of a map. So again, host name hash XOR'd with a counter might provide for unique map object ids and the same code as for the connectors could be reused. Other ideas? I guess my main problem is that I don't really have any experience with hashes and such. Will a short string such as the host name provide for unique enough hashes that XORing with a counter will still avoid collisions. How long should the hash be? 32 bits would be convenient, and should be plenty. Or play it safe and use 64 bits? And is the XOR such a good idea, or would it be better to have the hash as prefix and then additional bits for the counter? So if anyone has any insights to share, that would be appreciated. Otherwise I guess I have some reading to do, since the last thing I want to do is changing the id generation algorithm after a lot of models and stuff have been created. Kai _______________________________________________ Adonthell-devel mailing list Adonthell-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/adonthell-devel