April 2024 - This site, and Kamaelia are being updated. There is significant work needed, and PRs are welcome.

Axon.idGen

Unique ID generation

The methods of the idGen class are used to generate unique IDs in various forms (numbers, strings, etc) which are used to give microprocesses and other Axon objects a unique identifier and name.

Generating a new unique ID

Do not use the idGen class defined in this module directly. Instead, use any of these module methods to obtain a unique ID:

  • Axon.idGen.newId(thing) - returns a unique identifier as a string based on the class name of the object provided
  • Axon.idGen.strId(thing) - returns a unique identifier as a string based on the class name of the object provided
  • Axon.idGen.numId() - returns a unique identifier as a number
  • Axon.idGen.tupleId(thing) - returns both the numeric and string versions of a new unique id as a tuple (where the string version is based on the class name of the object provided)

Calling tupleId(thing) is not equivalent to calling numId() then strId(thing) because doing that would return two different id values!

Examples:

>>> x=Component.component()
>>> idGen.newId(x)
'Component.component_4'
>>> idGen.strId(x)
'Component.component_5'
>>> idGen.numId()
6
>>> idGen.tupleId(x)
(7, 'Component.component_7')

Axon.idGen.idGen

class idGen(object)

Unique ID creator.

Use numId(), strId(), and tupleId() methods to obtain unique IDs.

Methods defined here

idToString(self, thing, aNumId)

INTERNAL

Combines the 'str()' of the object's class with the id to form a string id

next(self)

INTERNAL

Returns the next unique id, incrementing the private class variable

nextId(self)

INTERNAL

Returns the next unique id, incrementing the private class variable

numId(self)

Allocates & returns the next available id

strId(self, thing)

Allocates & returns the next available id combined with the object's class name, in string form

tupleId(self, thing)

Allocates the next available id and returns it both as a tuple (num,str) containing both the numeric version and a string version where it is combined with the object's class name.

Feedback

Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!

Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.

-- Automatic documentation generator, 09 Dec 2009 at 04:00:25 UTC/GMT