GUID

BlitzMax Forums/BlitzMax Programming/GUID

ziggy(Posted 2008) [#1]
does anybody have a function to generate a cross-platform real GUID?


Perturbatio(Posted 2008) [#2]
is this unique enough?




ziggy(Posted 2008) [#3]
I hope so... Not sure how a system GUID works to generate their IDs, but this seems enought for me


ImaginaryHuman(Posted 2008) [#4]
I just use one Long value representing a unique computer on the network and one Long value representing an object on the local computer. Together they form the `internal` and `external` viewpoints of an object's boundary, and to generate new ones I just add 1 to the previous counter. The only drawback perhaps is you have to store the previous counter permanently like in a file rather than basing it off the date/time, and you need an orchestrated way of giving each networked machine a local id number.


ziggy(Posted 2008) [#5]
I'm not using this for networks, just to identify instances of objects at runtime, in the same computer.


Perturbatio(Posted 2008) [#6]
I'm not using this for networks, just to identify instances of objects at runtime, in the same computer.

Couldn't you just use some sort of auto-incremented value?


Dreamora(Posted 2008) [#7]

function generateGUID:int()
  global guid:int = 0
  guid :+ 1
  return guid
end function



you mean something like this?


Perturbatio(Posted 2008) [#8]
you mean something like this?

that or:




Helios(Posted 2008) [#9]
@Dreamora: He's refering to Globally Unique Identifiers (http://en.wikipedia.org/wiki/Globally_Unique_Identifier). The idea is that these are so unique and you can be sure no other software is ever going to generate the same one.


Dreamora(Posted 2008) [#10]
Well that would be the hwnd, not?
At least if it shouldn't hold so forever. But as he is using them locally on a single machine, I don't see why above shouldn't work. Above or a modification of it using a static table. Outside stuff most likely can not be of interest for this usage, otherwise network would be relevant (-> network devices etc)


ImaginaryHuman(Posted 2008) [#11]
Why does it need to be unique if it is only within the same single computer and not over a network? All you need is an incremented integer value, there's nothing more to it.


ziggy(Posted 2008) [#12]
Becose several instances of different objects on different running applications may comunicate and identify internal data structures that have to be unique even when this data is transfered to different computers. think of it as the register signature of a OCX or the like. It has a real GUID generated by the OS. I need something that can be trusted at this level. I know there are some API on windows to generate real GUID, but I would need a BMX cross-platform implementation of this.


Koriolis(Posted 2008) [#13]
Here you'll find specifications and a sample implementation in C:
http://www.ics.uci.edu/~ejw/authoring/uuid-guid/draft-leach-uuids-guids-01.txt

Google is your friend :)


ziggy(Posted 2008) [#14]
Thanks! That's what I was looking for!


CGV(Posted 2008) [#15]
Microsoft has a GUID generator available for download here.


Scaremonger(Posted 2008) [#16]
Take a look at this