[guid] - vversion 1, 4 and in one class?

Hello, Currently are two guid libraries in the vault. Is it possible to create one library containing the code for guid v1,v4,v5? Or better - could we get one guid class with the static member functions guid::create_v1(); guid::create_v4(), guid::create_v5()? Regards,Oliver

<Oliver.Kowalke@qimonda.com> wrote in news:B1EAFF2DAE7658488B631F25813CD91FCFC612@drsse602.eu.infineon.com:
Hello, Currently are two guid libraries in the vault. Is it possible to create one library containing the code for guid v1,v4,v5?
I am not very happy with the create_v1() function in guid_v3.zip. Really it just pretends to implement the specification correctly. Thus I removed it. guid_v5.zip has create_v4 (random number based) and create_v5 (name based) implemented correctly.
Or better - could we get one guid class with the static member functions guid::create_v1(); guid::create_v4(), guid::create_v5()?
Regards,Oliver _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Both create_v4() and create_v5() can be obtained from static functions, guid::create() - random number based (v4), and guid::create(guid const&, char const&, int) - name based (v5). I hope this answers your question. Andy

Hello Andy,
I am not very happy with the create_v1() function in guid_v3.zip. Really it just pretends to implement the specification correctly. Because MAC-address of the nic isn't used?
Thus I removed it. guid_v5.zip has create_v4 (random number based) and create_v5 (name based) implemented correctly. Both create_v4() and create_v5() can be obtained from static functions, guid::create() - random number based (v4), and guid::create(guid const&, char const&, int) - name based (v5).
How is your implementation of uuid v4 unique in space (guids genereated on several computers at the same time) and time? Regards, Oliver

<Oliver.Kowalke@qimonda.com> wrote in news:B1EAFF2DAE7658488B631F25813CD91FD388B7@drsse602.eu.infineon.com:
Hello Andy,
I am not very happy with the create_v1() function in guid_v3.zip. Really it just pretends to implement the specification correctly. Because MAC-address of the nic isn't used?
Yes, because the MAC-address is not used which increases the probability of duplicates. Also my implementation does not use stable storage and this is the least desirable implementation, because it will increase the frequency of creation of new clock sequence numbers, which increases the probability of duplicates. < snip >
How is your implementation of uuid v4 unique in space (guids genereated on several computers at the same time) and time?
My implementation of version 4 (random-number-based) guids may not be unique in space and time. It is based on boost::mt19937 to generate random numbers and it is seeded with std::time(0). Cryptographic-quality random numbers would reduce the probability of repeated values. Using version 5 (name-based) guid can be used to ensure that guids are unique in space (guids generated on several computers at the same time) and time. Generate a guid for each computer as the namespace_guid and pass a counter as the name to the create function. example: (not tested or compiled) const static guid computer_namespace_guid("{00000000-0000-0000-0000-000000000000}"); // or some other guid that never changes guid generate_guid() { // get unique string for computer // could be mac address const char* computer_name = get_unique_computer_name(); const static guid namespace_guid = guid::create(computer_namespace_guid, computer_name, strlen(computer_name)); static int count = 0; guid result = guid::create(namespace_guid, static_cast<char*>(&count), 4); ++count; return result; }
Regards, Oliver _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Andy.

Hello Andy,
My implementation of version 4 (random-number-based) guids may not be unique in space and time. It is based on boost::mt19937 to generate random numbers and it is seeded with std::time(0). Cryptographic-quality random numbers would reduce the probability of repeated values.
Using version 5 (name-based) guid can be used to ensure that guids are unique in space (guids generated on several computers at the same time) and time. Generate a guid for each computer as the namespace_guid and pass a counter as the name to the create function.
Because creating uuid v5 seams too expensive for me I could let one special computer (in my project == master) generate guids (unique in space). So I've make a decision wether uuid v4 or v1 should be used in order to be uinque in time?! Or do you have another suggestion? Regards,Oliver

<Oliver.Kowalke@qimonda.com> wrote in news:B1EAFF2DAE7658488B631F25813CD91FD819DC@drsse602.eu.infineon.com:
Hello Andy,
My implementation of version 4 (random-number-based) guids may not be unique in space and time. It is based on boost::mt19937 to generate random numbers and it is seeded with std::time(0). Cryptographic-quality random numbers would reduce the probability of repeated values.
Using version 5 (name-based) guid can be used to ensure that guids are unique in space (guids generated on several computers at the same time) and time. Generate a guid for each computer as the namespace_guid and pass a counter as the name to the create function.
Because creating uuid v5 seams too expensive for me I could let one special computer (in my project == master) generate guids (unique in space). So I've make a decision wether uuid v4 or v1 should be used in order to be uinque in time?! Or do you have another suggestion?
I have not done any profiling/timing on any of the functions that create a guid. A note about multiple threads: all 3 versions are thread safe, but the random-number-based (version 4) and the time-based (version 1) function need a mutex to ensure that only one thread is creating a guid at a time. The name-based (version 5) does not need a mutex. As to decide between time-based (version 1) and random-number-based (version 4) for which would be unique in time, I would expect the time- based (version 1) to be more unique in time since only the node is generated randomly and only the first time a guid is generated (until the program is restarted). Whereas the random-number-based (version 4) is all just random data. Andy.
Regards,Oliver _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Andy
-
Oliver.Kowalke@qimonda.com