
Janek Kozicki <janek_listy@wp.pl> wrote in news:20070506182937.0da237c8@absurd:
Dear Andy,
I remember that serialization library needs some sort of unique identifier. Currently it uses a class name. But Robert said several times that he will gladly allow using some other unique identifier. Is your library prepared for that?
I believe that my library can be used for this. I would gladly look into any issues. I do not know a lot about the Boost Serialization library but I do see the BOOST_CLASS_EXPORT_GUID macro. One could write: class my_class { public: static const my_class_guid("1234...."); }; BOOST_CLASS_EXPORT_GUID(my_class, my_class_guid.to_string());
When the identifier is assigned? - when the program starts?
I believe this is the case.
- when the code is compiled?
My guid library can not generate guids at compile time.
- when an attempt to read identifier for a given class is made?
Is the identifier the same across several program runs? (serialization library needs that to properly distinguish classes ;)
Yes, if one types in the guid as a string.
Is it possible to get an identifier of a class:
- during compilation (so it could be used in template metaprogramming, typedeffed enums or in #defines)
No.
- during runtime when only a polymorphic(!) class instance is provided (eg. I got a class Shape and classes Square and Circle deriving from it. Then I want to get a unique identifier to distinguish whether a pointer Shape* is a Square* or a Circle*)
yes.
- during runtime when only a type is provided? Not an instance of a class.
yes.
Is it possible to tell your library to assign numbers not random, but incrementing sequentially, starting from some given number? Maybe that's unfeasible, why?
yes. Just use one of the constructors.
Is the unique identifier an 'int' number, or is it custom? Maybe a string?
It is a custom type, a 16 byte number that has a string representation.
If the deadline can be extended till 11 or 12 May I should be able to write a review. Currently I completely have no time even to look at the documentation. However I'm curious to see your answers to my questions above.
I'm particularly interested in using your library in multimethods (see. Andrei Alexandrescu "Modern C++ Design" to check what's that ;) for constant time dispatch (classes will be indexed by their identifier).
Multimethods do something based on the dynamic type of two or more parameters. I see no reason why this could not work for multimethods. One way would be to have a virtual base class method return the guid of the class and each derived class would return the correct guid. The multimethod could determine what to do based on this information.
best regards
Andy.