Kamaelia docs : 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, 01 Feb 2010 at 04:00:28 UTC/GMT

 

Kamaelia is an open source project originated from and guided by BBC Research. For more information browse the site or get in contact.

This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)

(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved

This web site is powered by the same code created for the bicker manor project. For more details, contact Michael Sparks at BBC Research directly (cf contact)